diff options
Diffstat (limited to 'compiler/rustc_hir')
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/intravisit.rs | 48 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/stable_hash_impls.rs | 9 |
3 files changed, 29 insertions, 31 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index b688922a311..4696a4bd9ab 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -831,8 +831,6 @@ pub struct OwnerNodes<'tcx> { pub nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>, /// Content of local bodies. pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>, - /// Non-owning definitions contained in this owner. - pub local_id_to_def_id: SortedMap<ItemLocalId, LocalDefId>, } impl<'tcx> OwnerNodes<'tcx> { @@ -862,7 +860,6 @@ impl fmt::Debug for OwnerNodes<'_> { .collect::<Vec<_>>(), ) .field("bodies", &self.bodies) - .field("local_id_to_def_id", &self.local_id_to_def_id) .field("hash_without_bodies", &self.hash_without_bodies) .field("hash_including_bodies", &self.hash_including_bodies) .finish() diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 02641b7cf8f..f632babab0b 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -67,6 +67,7 @@ use crate::hir::*; use rustc_ast::walk_list; use rustc_ast::{Attribute, Label}; +use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -364,7 +365,7 @@ pub trait Visitor<'v>: Sized { fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) { walk_fn_decl(self, fd) } - fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl<'v>, b: BodyId, _: Span, id: HirId) { + fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl<'v>, b: BodyId, _: Span, id: LocalDefId) { walk_fn(self, fk, fd, b, id) } fn visit_use(&mut self, path: &'v UsePath<'v>, hir_id: HirId) { @@ -468,13 +469,16 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { visitor.visit_ty(typ); visitor.visit_nested_body(body); } - ItemKind::Fn(ref sig, ref generics, body_id) => visitor.visit_fn( - FnKind::ItemFn(item.ident, generics, sig.header), - sig.decl, - body_id, - item.span, - item.hir_id(), - ), + ItemKind::Fn(ref sig, ref generics, body_id) => { + visitor.visit_id(item.hir_id()); + visitor.visit_fn( + FnKind::ItemFn(item.ident, generics, sig.header), + sig.decl, + body_id, + item.span, + item.owner_id.def_id, + ) + } ItemKind::Macro(..) => { visitor.visit_id(item.hir_id()); } @@ -733,7 +737,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) walk_list!(visitor, visit_arm, arms); } ExprKind::Closure(&Closure { - def_id: _, + def_id, binder: _, bound_generic_params, fn_decl, @@ -745,7 +749,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) constness: _, }) => { walk_list!(visitor, visit_generic_param, bound_generic_params); - visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, expression.hir_id) + visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, def_id) } ExprKind::Block(ref block, ref opt_label) => { walk_list!(visitor, visit_label, opt_label); @@ -923,9 +927,8 @@ pub fn walk_fn<'v, V: Visitor<'v>>( function_kind: FnKind<'v>, function_declaration: &'v FnDecl<'v>, body_id: BodyId, - id: HirId, + _: LocalDefId, ) { - visitor.visit_id(id); visitor.visit_fn_decl(function_declaration); walk_fn_kind(visitor, function_kind); visitor.visit_nested_body(body_id) @@ -953,26 +956,30 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai let TraitItem { ident, generics, ref defaultness, ref kind, span, owner_id: _ } = *trait_item; let hir_id = trait_item.hir_id(); visitor.visit_ident(ident); - visitor.visit_generics(generics); - visitor.visit_defaultness(defaultness); + visitor.visit_generics(&generics); + visitor.visit_defaultness(&defaultness); + visitor.visit_id(hir_id); match *kind { TraitItemKind::Const(ref ty, default) => { - visitor.visit_id(hir_id); visitor.visit_ty(ty); walk_list!(visitor, visit_nested_body, default); } TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => { - visitor.visit_id(hir_id); visitor.visit_fn_decl(sig.decl); for ¶m_name in param_names { visitor.visit_ident(param_name); } } TraitItemKind::Fn(ref sig, TraitFn::Provided(body_id)) => { - visitor.visit_fn(FnKind::Method(ident, sig), sig.decl, body_id, span, hir_id); + visitor.visit_fn( + FnKind::Method(ident, sig), + sig.decl, + body_id, + span, + trait_item.owner_id.def_id, + ); } TraitItemKind::Type(bounds, ref default) => { - visitor.visit_id(hir_id); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_ty, default); } @@ -1002,9 +1009,9 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_ident(ident); visitor.visit_generics(generics); visitor.visit_defaultness(defaultness); + visitor.visit_id(impl_item.hir_id()); match *kind { ImplItemKind::Const(ref ty, body) => { - visitor.visit_id(impl_item.hir_id()); visitor.visit_ty(ty); visitor.visit_nested_body(body); } @@ -1014,11 +1021,10 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt sig.decl, body_id, impl_item.span, - impl_item.hir_id(), + impl_item.owner_id.def_id, ); } ImplItemKind::Type(ref ty) => { - visitor.visit_id(impl_item.hir_id()); visitor.visit_ty(ty); } } diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index 23423e8f3b3..85d0e02d0b6 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -100,13 +100,8 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable<HirCtx> for OwnerNodes<' // `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing // the body satisfies the condition of two nodes being different have different // `hash_stable` results. - let OwnerNodes { - hash_including_bodies, - hash_without_bodies: _, - nodes: _, - bodies: _, - local_id_to_def_id: _, - } = *self; + let OwnerNodes { hash_including_bodies, hash_without_bodies: _, nodes: _, bodies: _ } = + *self; hash_including_bodies.hash_stable(hcx, hasher); } } |
