Skip to content

Commit

Permalink
Auto merge of #51492 - petrochenkov:hirident, r=<try>
Browse files Browse the repository at this point in the history
Use `Ident`s in HIR and remove emulation of hygiene with gensyms

continuation of #51072, part of #49300

Not all `Name`s in HIR are replaced with `Ident`s, only those needed for hygiene or already having attached spans.
  • Loading branch information
bors committed Jun 11, 2018
2 parents 18a00bd + 0dcd858 commit f006dd4
Show file tree
Hide file tree
Showing 65 changed files with 546 additions and 602 deletions.
54 changes: 27 additions & 27 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub enum FnKind<'a> {
ItemFn(Name, &'a Generics, Unsafety, Constness, Abi, &'a Visibility, &'a [Attribute]),

/// fn foo(&self)
Method(Name, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),

/// |x, y| {}
Closure(&'a [Attribute]),
Expand Down Expand Up @@ -421,14 +421,14 @@ pub fn walk_ident<'v, V: Visitor<'v>>(visitor: &mut V, ident: Ident) {
}

pub fn walk_label<'v, V: Visitor<'v>>(visitor: &mut V, label: &'v Label) {
visitor.visit_name(label.span, label.name);
visitor.visit_ident(label.ident);
}

pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime) {
visitor.visit_id(lifetime.id);
match lifetime.name {
LifetimeName::Name(name) => {
visitor.visit_name(lifetime.span, name);
LifetimeName::Ident(ident) => {
visitor.visit_ident(ident);
}
LifetimeName::Fresh(_) |
LifetimeName::Static |
Expand Down Expand Up @@ -634,7 +634,7 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V,
path_span: Span,
segment: &'v PathSegment) {
visitor.visit_name(path_span, segment.name);
visitor.visit_ident(segment.ident);
if let Some(ref parameters) = segment.parameters {
visitor.visit_path_parameters(path_span, parameters);
}
Expand All @@ -651,7 +651,7 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
type_binding: &'v TypeBinding) {
visitor.visit_id(type_binding.id);
visitor.visit_name(type_binding.span, type_binding.name);
visitor.visit_ident(type_binding.ident);
visitor.visit_ty(&type_binding.ty);
}

Expand Down Expand Up @@ -680,9 +680,9 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
PatKind::Ref(ref subpattern, _) => {
visitor.visit_pat(subpattern)
}
PatKind::Binding(_, canonical_id, ref pth1, ref optional_subpattern) => {
PatKind::Binding(_, canonical_id, ident, ref optional_subpattern) => {
visitor.visit_def_mention(Def::Local(canonical_id));
visitor.visit_name(pth1.span, pth1.node);
visitor.visit_ident(ident);
walk_list!(visitor, visit_pat, optional_subpattern);
}
PatKind::Lit(ref expression) => visitor.visit_expr(expression),
Expand All @@ -705,11 +705,11 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
visitor.visit_name(foreign_item.span, foreign_item.name);

match foreign_item.node {
ForeignItemFn(ref function_declaration, ref names, ref generics) => {
ForeignItemFn(ref function_declaration, ref param_names, ref generics) => {
visitor.visit_generics(generics);
visitor.visit_fn_decl(function_declaration);
for name in names {
visitor.visit_name(name.span, name.node);
for &param_name in param_names {
visitor.visit_ident(param_name);
}
}
ForeignItemStatic(ref typ, _) => visitor.visit_ty(typ),
Expand All @@ -735,8 +735,8 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
GenericParam::Lifetime(ref ld) => {
visitor.visit_id(ld.lifetime.id);
match ld.lifetime.name {
LifetimeName::Name(name) => {
visitor.visit_name(ld.lifetime.span, name);
LifetimeName::Ident(ident) => {
visitor.visit_ident(ident);
}
LifetimeName::Fresh(_) |
LifetimeName::Static |
Expand All @@ -747,7 +747,7 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
}
GenericParam::Type(ref ty_param) => {
visitor.visit_id(ty_param.id);
visitor.visit_name(ty_param.span, ty_param.name);
visitor.visit_ident(ty_param.ident);
walk_list!(visitor, visit_ty_param_bound, &ty_param.bounds);
walk_list!(visitor, visit_ty, &ty_param.default);
walk_list!(visitor, visit_attribute, ty_param.attrs.iter());
Expand Down Expand Up @@ -827,7 +827,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
}

pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) {
visitor.visit_name(trait_item.span, trait_item.name);
visitor.visit_ident(trait_item.ident);
walk_list!(visitor, visit_attribute, &trait_item.attrs);
visitor.visit_generics(&trait_item.generics);
match trait_item.node {
Expand All @@ -836,15 +836,15 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
visitor.visit_ty(ty);
walk_list!(visitor, visit_nested_body, default);
}
TraitItemKind::Method(ref sig, TraitMethod::Required(ref names)) => {
TraitItemKind::Method(ref sig, TraitMethod::Required(ref param_names)) => {
visitor.visit_id(trait_item.id);
visitor.visit_fn_decl(&sig.decl);
for name in names {
visitor.visit_name(name.span, name.node);
for &param_name in param_names {
visitor.visit_ident(param_name);
}
}
TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => {
visitor.visit_fn(FnKind::Method(trait_item.name,
visitor.visit_fn(FnKind::Method(trait_item.ident,
sig,
None,
&trait_item.attrs),
Expand All @@ -863,9 +863,9 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai

pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref: &'v TraitItemRef) {
// NB: Deliberately force a compilation error if/when new fields are added.
let TraitItemRef { id, name, ref kind, span, ref defaultness } = *trait_item_ref;
let TraitItemRef { id, ident, ref kind, span: _, ref defaultness } = *trait_item_ref;
visitor.visit_nested_trait_item(id);
visitor.visit_name(span, name);
visitor.visit_ident(ident);
visitor.visit_associated_item_kind(kind);
visitor.visit_defaultness(defaultness);
}
Expand All @@ -875,16 +875,16 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
let ImplItem {
id: _,
hir_id: _,
name,
ident,
ref vis,
ref defaultness,
ref attrs,
ref generics,
ref node,
span
span: _,
} = *impl_item;

visitor.visit_name(span, name);
visitor.visit_ident(ident);
visitor.visit_vis(vis);
visitor.visit_defaultness(defaultness);
walk_list!(visitor, visit_attribute, attrs);
Expand All @@ -896,7 +896,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
visitor.visit_nested_body(body);
}
ImplItemKind::Method(ref sig, body_id) => {
visitor.visit_fn(FnKind::Method(impl_item.name,
visitor.visit_fn(FnKind::Method(impl_item.ident,
sig,
Some(&impl_item.vis),
&impl_item.attrs),
Expand All @@ -914,9 +914,9 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt

pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
// NB: Deliberately force a compilation error if/when new fields are added.
let ImplItemRef { id, name, ref kind, span, ref vis, ref defaultness } = *impl_item_ref;
let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref;
visitor.visit_nested_impl_item(id);
visitor.visit_name(span, name);
visitor.visit_ident(ident);
visitor.visit_associated_item_kind(kind);
visitor.visit_vis(vis);
visitor.visit_defaultness(defaultness);
Expand Down
Loading

0 comments on commit f006dd4

Please sign in to comment.