Rename ast::Variant_::name into ident + Fix rebase

This commit is contained in:
Vadim Petrochenkov 2018-03-19 01:21:30 +03:00
parent 43ad972318
commit 62000c072e
21 changed files with 30 additions and 38 deletions

View file

@ -1358,7 +1358,7 @@ impl<'a> LoweringContext<'a> {
fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
Spanned {
node: hir::Variant_ {
name: v.node.name.name,
name: v.node.ident.name,
attrs: self.lower_attrs(&v.node.attrs),
data: self.lower_variant_data(&v.node.data),
disr_expr: v.node

View file

@ -132,7 +132,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
for v in &enum_definition.variants {
let variant_def_index =
this.create_def(v.node.data.id(),
DefPathData::EnumVariant(v.node.name.name.as_str()),
DefPathData::EnumVariant(v.node.ident.name.as_str()),
REGULAR_SPACE,
v.span);
this.with_parent(variant_def_index, |this| {

View file

@ -377,7 +377,7 @@ impl UnusedImportBraces {
let node_ident;
match items[0].0.kind {
ast::UseTreeKind::Simple(rename) => {
let orig_ident = items[0].0.prefix.segments.last().unwrap().identifier;
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
if orig_ident.name == keywords::SelfValue.name() {
return;
} else {

View file

@ -423,7 +423,7 @@ impl<'a> Resolver<'a> {
parent: Module<'a>,
vis: ty::Visibility,
expansion: Mark) {
let ident = variant.node.name;
let ident = variant.node.ident;
let def_id = self.definitions.local_def_id(variant.node.data.id());
// Define a name in the type namespace.

View file

@ -851,7 +851,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
// `visit::walk_variant` without the discriminant expression.
self.visit_variant_data(&variant.node.data,
variant.node.name,
variant.node.ident,
generics,
item_id,
variant.span);
@ -3988,7 +3988,7 @@ impl<'a> Resolver<'a> {
ast::VisibilityKind::Restricted { ref path, id, .. } => {
// Visibilities are resolved as global by default, add starting root segment.
let segments = path.make_root().iter().chain(path.segments.iter())
.map(|seg| respan(seg.span, seg.identifier))
.map(|seg| seg.ident)
.collect::<Vec<_>>();
let def = self.smart_resolve_path_fragment(id, None, &segments, path.span,
PathSource::Visibility).base_def();

View file

@ -663,7 +663,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
let access = access_from!(self.save_ctxt, item);
for variant in &enum_definition.variants {
let name = variant.node.name.name.to_string();
let name = variant.node.ident.name.to_string();
let mut qualname = enum_data.qualname.clone();
qualname.push_str("::");
qualname.push_str(&name);

View file

@ -297,7 +297,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
filter!(self.span_utils, sub_span, item.span, None);
let variants_str = def.variants
.iter()
.map(|v| v.node.name.to_string())
.map(|v| v.node.ident.to_string())
.collect::<Vec<_>>()
.join(", ");
let value = format!("{}::{{{}}}", name, variants_str);

View file

@ -692,7 +692,7 @@ impl Sig for ast::StructField {
impl Sig for ast::Variant_ {
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
let mut text = self.name.to_string();
let mut text = self.ident.to_string();
match self.data {
ast::VariantData::Struct(ref fields, id) => {
let name_def = SigElement {

View file

@ -1866,7 +1866,7 @@ pub struct EnumDef {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Variant_ {
pub name: Ident,
pub ident: Ident,
pub attrs: Vec<Attribute>,
pub data: VariantData,
/// Explicit discriminant, e.g. `Foo = 1`
@ -1900,7 +1900,7 @@ impl UseTree {
match self.kind {
UseTreeKind::Simple(Some(rename)) => rename,
UseTreeKind::Simple(None) =>
self.prefix.segments.last().expect("empty prefix in a simple import").identifier,
self.prefix.segments.last().expect("empty prefix in a simple import").ident,
_ => panic!("`UseTree::ident` can only be used on a simple import"),
}
}

View file

@ -204,7 +204,7 @@ impl<'a> StripUnconfigured<'a> {
self.configure(v).map(|v| {
Spanned {
node: ast::Variant_ {
name: v.node.name,
ident: v.node.ident,
attrs: v.node.attrs,
data: self.configure_variant_data(v.node.data),
disr_expr: v.node.disr_expr,

View file

@ -1022,7 +1022,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
body)
}
fn variant(&self, span: Span, name: Ident, tys: Vec<P<ast::Ty>> ) -> ast::Variant {
fn variant(&self, span: Span, ident: Ident, tys: Vec<P<ast::Ty>> ) -> ast::Variant {
let fields: Vec<_> = tys.into_iter().map(|ty| {
ast::StructField {
span: ty.span,
@ -1042,7 +1042,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
respan(span,
ast::Variant_ {
name,
ident,
attrs: Vec::new(),
data: vdata,
disr_expr: None,

View file

@ -430,7 +430,7 @@ pub fn noop_fold_global_asm<T: Folder>(ga: P<GlobalAsm>,
pub fn noop_fold_variant<T: Folder>(v: Variant, fld: &mut T) -> Variant {
Spanned {
node: Variant_ {
name: fld.fold_ident(v.node.name),
ident: fld.fold_ident(v.node.ident),
attrs: fold_attrs(v.node.attrs, fld),
data: fld.fold_variant_data(v.node.data),
disr_expr: v.node.disr_expr.map(|e| fld.fold_expr(e)),

View file

@ -873,10 +873,8 @@ mod tests {
== P(ast::Pat{
id: ast::DUMMY_NODE_ID,
node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable),
Spanned{ span:sp(0, 1),
node: Ident::from_str("b")
},
None),
Ident::new(Symbol::intern("b"), sp(0, 1)),
None),
span: sp(0,1)}));
parser_done(parser);
})
@ -912,9 +910,7 @@ mod tests {
node: PatKind::Ident(
ast::BindingMode::ByValue(
ast::Mutability::Immutable),
Spanned{
span: sp(6,7),
node: Ident::from_str("b")},
Ident::new(Symbol::intern("b"), sp(6, 7)),
None
),
span: sp(6,7)

View file

@ -6323,7 +6323,7 @@ impl<'a> Parser<'a> {
}
let vr = ast::Variant_ {
name: ident,
ident,
attrs: variant_attrs,
data: struct_def,
disr_expr,

View file

@ -1540,7 +1540,7 @@ impl<'a> State<'a> {
pub fn print_variant(&mut self, v: &ast::Variant) -> io::Result<()> {
self.head("")?;
let generics = ast::Generics::default();
self.print_struct(&v.node.data, &generics, v.node.name, v.span, false)?;
self.print_struct(&v.node.data, &generics, v.node.ident, v.span, false)?;
match v.node.disr_expr {
Some(ref d) => {
self.s.space()?;
@ -3194,7 +3194,7 @@ mod tests {
let ident = ast::Ident::from_str("principal_skinner");
let var = codemap::respan(syntax_pos::DUMMY_SP, ast::Variant_ {
name: ident,
ident,
attrs: Vec::new(),
// making this up as I go.... ?
data: ast::VariantData::Unit(ast::DUMMY_NODE_ID),

View file

@ -293,8 +293,8 @@ pub fn walk_variant<'a, V>(visitor: &mut V,
item_id: NodeId)
where V: Visitor<'a>,
{
visitor.visit_ident(variant.span, variant.node.name);
visitor.visit_variant_data(&variant.node.data, variant.node.name,
visitor.visit_ident(variant.span, variant.node.ident);
visitor.visit_variant_data(&variant.node.data, variant.node.ident,
generics, item_id, variant.span);
walk_list!(visitor, visit_expr, &variant.node.disr_expr);
walk_list!(visitor, visit_attribute, &variant.node.attrs);

View file

@ -177,7 +177,7 @@ fn cs_clone(name: &str,
vdata = vdata_;
}
EnumMatching(.., variant, ref af) => {
ctor_path = cx.path(trait_span, vec![substr.type_ident, variant.node.name]);
ctor_path = cx.path(trait_span, vec![substr.type_ident, variant.node.ident]);
all_fields = af;
vdata = &variant.node.data;
}

View file

@ -61,7 +61,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<E
// based on the "shape".
let (ident, is_struct) = match *substr.fields {
Struct(vdata, _) => (substr.type_ident, vdata.is_struct()),
EnumMatching(_, _, v, _) => (v.node.name, v.node.data.is_struct()),
EnumMatching(_, _, v, _) => (v.node.ident, v.node.data.is_struct()),
EnumNonMatchingCollapsed(..) |
StaticStruct(..) |
StaticEnum(..) => cx.span_bug(span, "nonsensical .fields in `#[derive(Debug)]`"),

View file

@ -277,7 +277,7 @@ fn encodable_substructure(cx: &mut ExtCtxt,
}
let blk = cx.lambda_stmts_1(trait_span, stmts, blkarg);
let name = cx.expr_str(trait_span, variant.node.name.name);
let name = cx.expr_str(trait_span, variant.node.ident.name);
let call = cx.expr_method_call(trait_span,
blkencoder,
cx.ident_of("emit_enum_variant"),

View file

@ -1538,10 +1538,9 @@ impl<'a> MethodDef<'a> {
let summary = enum_def.variants
.iter()
.map(|v| {
let ident = v.node.name;
let sp = v.span.with_ctxt(trait_.span.ctxt());
let summary = trait_.summarise_struct(cx, &v.node.data);
(ident, sp, summary)
(v.node.ident, sp, summary)
})
.collect();
self.call_substructure_method(cx,
@ -1667,9 +1666,8 @@ impl<'a> TraitDef<'a> {
prefix: &str,
mutbl: ast::Mutability)
-> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [ast::Attribute])>) {
let variant_ident = variant.node.name;
let sp = variant.span.with_ctxt(self.span.ctxt());
let variant_path = cx.path(sp, vec![enum_ident, variant_ident]);
let variant_path = cx.path(sp, vec![enum_ident, variant.node.ident]);
let use_temporaries = false; // enums can't be repr(packed)
self.create_struct_pattern(cx, variant_path, &variant.node.data, prefix, mutbl,
use_temporaries)

View file

@ -134,8 +134,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Assign(make_x(), e)));
},
10 => {
let ident = Spanned { span: DUMMY_SP, node: Ident::from_str("f") };
iter_exprs(depth - 1, &mut |e| g(ExprKind::Field(e, ident)));
iter_exprs(depth - 1, &mut |e| g(ExprKind::Field(e, Ident::from_str("f"))));
},
11 => {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Range(
@ -151,8 +150,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Ret(Some(e))));
},
14 => {
let seg = PathSegment::new(Ident::from_str("S"), DUMMY_SP);
let path = Path { segments: vec![seg], span: DUMMY_SP };
let path = Path::from_ident(DUMMY_SP, Ident::from_str("S"));
g(ExprKind::Struct(path, vec![], Some(make_x())));
},
15 => {