Only store a LocalDefId in hir::ForeignItem.

This commit is contained in:
Camille GILLOT 2021-02-01 00:33:38 +01:00
parent 786a80e9ea
commit 996dc8d5c5
32 changed files with 133 additions and 110 deletions

View file

@ -111,7 +111,7 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
self.lctx.allocate_hir_id_counter(item.id); self.lctx.allocate_hir_id_counter(item.id);
self.lctx.with_hir_id_owner(item.id, |lctx| { self.lctx.with_hir_id_owner(item.id, |lctx| {
let hir_item = lctx.lower_foreign_item(item); let hir_item = lctx.lower_foreign_item(item);
let id = hir::ForeignItemId { hir_id: hir_item.hir_id }; let id = hir_item.foreign_item_id();
lctx.foreign_items.insert(id, hir_item); lctx.foreign_items.insert(id, hir_item);
lctx.modules.get_mut(&lctx.current_module).unwrap().foreign_items.insert(id); lctx.modules.get_mut(&lctx.current_module).unwrap().foreign_items.insert(id);
}); });
@ -711,7 +711,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> { fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
let def_id = self.resolver.local_def_id(i.id); let def_id = self.resolver.local_def_id(i.id);
hir::ForeignItem { hir::ForeignItem {
hir_id: self.lower_node_id(i.id), def_id,
ident: i.ident, ident: i.ident,
attrs: self.lower_attrs(&i.attrs), attrs: self.lower_attrs(&i.attrs),
kind: match i.kind { kind: match i.kind {
@ -746,7 +746,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef<'hir> { fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef<'hir> {
hir::ForeignItemRef { hir::ForeignItemRef {
id: hir::ForeignItemId { hir_id: self.lower_node_id(i.id) }, id: hir::ForeignItemId { def_id: self.lower_node_id(i.id).expect_owner() },
ident: i.ident, ident: i.ident,
span: i.span, span: i.span,
vis: self.lower_visibility(&i.vis, Some(i.id)), vis: self.lower_visibility(&i.vis, Some(i.id)),

View file

@ -2783,7 +2783,14 @@ pub enum AssocItemKind {
// so it can fetched later. // so it can fetched later.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Debug)]
pub struct ForeignItemId { pub struct ForeignItemId {
pub hir_id: HirId, pub def_id: LocalDefId,
}
impl ForeignItemId {
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id)
}
} }
/// A reference from a foreign block to one of its items. This /// A reference from a foreign block to one of its items. This
@ -2801,17 +2808,27 @@ pub struct ForeignItemRef<'hir> {
pub vis: Visibility<'hir>, pub vis: Visibility<'hir>,
} }
#[derive(Debug, HashStable_Generic)] #[derive(Debug)]
pub struct ForeignItem<'hir> { pub struct ForeignItem<'hir> {
#[stable_hasher(project(name))]
pub ident: Ident, pub ident: Ident,
pub attrs: &'hir [Attribute], pub attrs: &'hir [Attribute],
pub kind: ForeignItemKind<'hir>, pub kind: ForeignItemKind<'hir>,
pub hir_id: HirId, pub def_id: LocalDefId,
pub span: Span, pub span: Span,
pub vis: Visibility<'hir>, pub vis: Visibility<'hir>,
} }
impl ForeignItem<'_> {
pub fn hir_id(&self) -> HirId {
// Items are always HIR owners.
HirId::make_owner(self.def_id)
}
pub fn foreign_item_id(&self) -> ForeignItemId {
ForeignItemId { def_id: self.def_id }
}
}
/// An item within an `extern` block. /// An item within an `extern` block.
#[derive(Debug, HashStable_Generic)] #[derive(Debug, HashStable_Generic)]
pub enum ForeignItemKind<'hir> { pub enum ForeignItemKind<'hir> {
@ -2923,9 +2940,9 @@ impl<'hir> Node<'hir> {
match self { match self {
Node::Item(Item { def_id, .. }) Node::Item(Item { def_id, .. })
| Node::TraitItem(TraitItem { def_id, .. }) | Node::TraitItem(TraitItem { def_id, .. })
| Node::ImplItem(ImplItem { def_id, .. }) => Some(HirId::make_owner(*def_id)), | Node::ImplItem(ImplItem { def_id, .. })
Node::ForeignItem(ForeignItem { hir_id, .. }) | Node::ForeignItem(ForeignItem { def_id, .. }) => Some(HirId::make_owner(*def_id)),
| Node::Field(StructField { hir_id, .. }) Node::Field(StructField { hir_id, .. })
| Node::AnonConst(AnonConst { hir_id, .. }) | Node::AnonConst(AnonConst { hir_id, .. })
| Node::Expr(Expr { hir_id, .. }) | Node::Expr(Expr { hir_id, .. })
| Node::Stmt(Stmt { hir_id, .. }) | Node::Stmt(Stmt { hir_id, .. })
@ -2960,5 +2977,5 @@ mod size_asserts {
rustc_data_structures::static_assert_size!(super::Item<'static>, 200); rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144); rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144);
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168); rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 160); rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 152);
} }

View file

@ -836,7 +836,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) {
} }
pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v ForeignItem<'v>) { pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v ForeignItem<'v>) {
visitor.visit_id(foreign_item.hir_id); visitor.visit_id(foreign_item.hir_id());
visitor.visit_vis(&foreign_item.vis); visitor.visit_vis(&foreign_item.vis);
visitor.visit_ident(foreign_item.ident); visitor.visit_ident(foreign_item.ident);

View file

@ -1,8 +1,8 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use crate::hir::{ use crate::hir::{
BodyId, Expr, ForeignItemId, ImplItem, ImplItemId, Item, ItemId, Mod, TraitItem, TraitItemId, BodyId, Expr, ForeignItem, ForeignItemId, ImplItem, ImplItemId, Item, ItemId, Mod, TraitItem,
Ty, VisibilityKind, TraitItemId, Ty, VisibilityKind,
}; };
use crate::hir_id::{HirId, ItemLocalId}; use crate::hir_id::{HirId, ItemLocalId};
use rustc_span::def_id::{DefPathHash, LocalDefId}; use rustc_span::def_id::{DefPathHash, LocalDefId};
@ -62,11 +62,11 @@ impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ImplItemId {
} }
impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ForeignItemId { impl<HirCtx: crate::HashStableContext> ToStableHashKey<HirCtx> for ForeignItemId {
type KeyType = (DefPathHash, ItemLocalId); type KeyType = DefPathHash;
#[inline] #[inline]
fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) { fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash {
self.hir_id.to_stable_hash_key(hcx) hcx.local_def_path_hash(self.def_id)
} }
} }
@ -97,7 +97,7 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ItemId {
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItemId { impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItemId {
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
hcx.hash_reference_to_item(self.hir_id, hasher) hcx.hash_reference_to_item(self.hir_id(), hasher)
} }
} }
@ -176,6 +176,20 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
} }
} }
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ForeignItem<'_> {
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
let ForeignItem { def_id: _, ident, ref attrs, ref kind, span, ref vis } = *self;
hcx.hash_hir_item_like(|hcx| {
ident.name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
kind.hash_stable(hcx, hasher);
span.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
});
}
}
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Item<'_> { impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Item<'_> {
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
let Item { ident, ref attrs, def_id: _, ref kind, ref vis, span } = *self; let Item { ident, ref attrs, def_id: _, ref kind, ref vis, span } = *self;

View file

@ -462,7 +462,7 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
} }
fn visit_foreign_item(&mut self, item: &hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, item: &hir::ForeignItem<'_>) {
self.check_item(item.hir_id, item.span); self.check_item(item.hir_id(), item.span);
} }
} }

View file

@ -660,11 +660,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
} }
fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'_>) { fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'_>) {
let def_id = cx.tcx.hir().local_def_id(foreign_item.hir_id); let (article, desc) = cx.tcx.article_and_description(foreign_item.def_id.to_def_id());
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
self.check_missing_docs_attrs( self.check_missing_docs_attrs(
cx, cx,
Some(foreign_item.hir_id), Some(foreign_item.hir_id()),
&foreign_item.attrs, &foreign_item.attrs,
foreign_item.span, foreign_item.span,
article, article,
@ -1365,7 +1364,7 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
self.perform_lint( self.perform_lint(
cx, cx,
"item", "item",
foreign_item.hir_id, foreign_item.hir_id(),
&foreign_item.vis, &foreign_item.vis,
foreign_item.span, foreign_item.span,
true, true,
@ -2675,10 +2674,7 @@ impl ClashingExternDeclarations {
/// Insert a new foreign item into the seen set. If a symbol with the same name already exists /// Insert a new foreign item into the seen set. If a symbol with the same name already exists
/// for the item, return its HirId without updating the set. /// for the item, return its HirId without updating the set.
fn insert(&mut self, tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> Option<HirId> { fn insert(&mut self, tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> Option<HirId> {
let hid = fi.hir_id; let did = fi.def_id.to_def_id();
let local_did = tcx.hir().local_def_id(fi.hir_id);
let did = local_did.to_def_id();
let instance = Instance::new(did, ty::List::identity_for_item(tcx, did)); let instance = Instance::new(did, ty::List::identity_for_item(tcx, did));
let name = Symbol::intern(tcx.symbol_name(instance).name); let name = Symbol::intern(tcx.symbol_name(instance).name);
if let Some(&hir_id) = self.seen_decls.get(&name) { if let Some(&hir_id) = self.seen_decls.get(&name) {
@ -2687,7 +2683,7 @@ impl ClashingExternDeclarations {
// This lets us avoid emitting "knock-on" diagnostics. // This lets us avoid emitting "knock-on" diagnostics.
Some(hir_id) Some(hir_id)
} else { } else {
self.seen_decls.insert(name, hid) self.seen_decls.insert(name, fi.hir_id())
} }
} }
@ -2695,16 +2691,15 @@ impl ClashingExternDeclarations {
/// the name specified in a #[link_name = ...] attribute if one was specified, else, just the /// the name specified in a #[link_name = ...] attribute if one was specified, else, just the
/// symbol's name. /// symbol's name.
fn name_of_extern_decl(tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> SymbolName { fn name_of_extern_decl(tcx: TyCtxt<'_>, fi: &hir::ForeignItem<'_>) -> SymbolName {
let did = tcx.hir().local_def_id(fi.hir_id);
if let Some((overridden_link_name, overridden_link_name_span)) = if let Some((overridden_link_name, overridden_link_name_span)) =
tcx.codegen_fn_attrs(did).link_name.map(|overridden_link_name| { tcx.codegen_fn_attrs(fi.def_id).link_name.map(|overridden_link_name| {
// FIXME: Instead of searching through the attributes again to get span // FIXME: Instead of searching through the attributes again to get span
// information, we could have codegen_fn_attrs also give span information back for // information, we could have codegen_fn_attrs also give span information back for
// where the attribute was defined. However, until this is found to be a // where the attribute was defined. However, until this is found to be a
// bottleneck, this does just fine. // bottleneck, this does just fine.
( (
overridden_link_name, overridden_link_name,
tcx.get_attrs(did.to_def_id()) tcx.get_attrs(fi.def_id.to_def_id())
.iter() .iter()
.find(|at| tcx.sess.check_name(at, sym::link_name)) .find(|at| tcx.sess.check_name(at, sym::link_name))
.unwrap() .unwrap()
@ -2932,10 +2927,10 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
let tcx = cx.tcx; let tcx = cx.tcx;
if let Some(existing_hid) = self.insert(tcx, this_fi) { if let Some(existing_hid) = self.insert(tcx, this_fi) {
let existing_decl_ty = tcx.type_of(tcx.hir().local_def_id(existing_hid)); let existing_decl_ty = tcx.type_of(tcx.hir().local_def_id(existing_hid));
let this_decl_ty = tcx.type_of(tcx.hir().local_def_id(this_fi.hir_id)); let this_decl_ty = tcx.type_of(this_fi.def_id);
debug!( debug!(
"ClashingExternDeclarations: Comparing existing {:?}: {:?} to this {:?}: {:?}", "ClashingExternDeclarations: Comparing existing {:?}: {:?} to this {:?}: {:?}",
existing_hid, existing_decl_ty, this_fi.hir_id, this_decl_ty existing_hid, existing_decl_ty, this_fi.def_id, this_decl_ty
); );
// Check that the declarations match. // Check that the declarations match.
if !Self::structurally_same_type( if !Self::structurally_same_type(
@ -2957,7 +2952,7 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
// Finally, emit the diagnostic. // Finally, emit the diagnostic.
tcx.struct_span_lint_hir( tcx.struct_span_lint_hir(
CLASHING_EXTERN_DECLARATIONS, CLASHING_EXTERN_DECLARATIONS,
this_fi.hir_id, this_fi.hir_id(),
get_relevant_span(this_fi), get_relevant_span(this_fi),
|lint| { |lint| {
let mut expected_str = DiagnosticStyledString::new(); let mut expected_str = DiagnosticStyledString::new();

View file

@ -155,8 +155,8 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
} }
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| { self.with_lint_attrs(it.hir_id(), &it.attrs, |cx| {
cx.with_param_env(it.hir_id, |cx| { cx.with_param_env(it.hir_id(), |cx| {
lint_callback!(cx, check_foreign_item, it); lint_callback!(cx, check_foreign_item, it);
hir_visit::walk_foreign_item(cx, it); hir_visit::walk_foreign_item(cx, it);
lint_callback!(cx, check_foreign_item_post, it); lint_callback!(cx, check_foreign_item_post, it);

View file

@ -583,7 +583,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
} }
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem<'tcx>) {
self.with_lint_attrs(it.hir_id, &it.attrs, |builder| { self.with_lint_attrs(it.hir_id(), &it.attrs, |builder| {
intravisit::walk_foreign_item(builder, it); intravisit::walk_foreign_item(builder, it);
}) })
} }

View file

@ -1262,15 +1262,15 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDeclarations { impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDeclarations {
fn check_foreign_item(&mut self, cx: &LateContext<'_>, it: &hir::ForeignItem<'_>) { fn check_foreign_item(&mut self, cx: &LateContext<'_>, it: &hir::ForeignItem<'_>) {
let mut vis = ImproperCTypesVisitor { cx, mode: CItemKind::Declaration }; let mut vis = ImproperCTypesVisitor { cx, mode: CItemKind::Declaration };
let abi = cx.tcx.hir().get_foreign_abi(it.hir_id); let abi = cx.tcx.hir().get_foreign_abi(it.hir_id());
if !vis.is_internal_abi(abi) { if !vis.is_internal_abi(abi) {
match it.kind { match it.kind {
hir::ForeignItemKind::Fn(ref decl, _, _) => { hir::ForeignItemKind::Fn(ref decl, _, _) => {
vis.check_foreign_fn(it.hir_id, decl); vis.check_foreign_fn(it.hir_id(), decl);
} }
hir::ForeignItemKind::Static(ref ty, _) => { hir::ForeignItemKind::Static(ref ty, _) => {
vis.check_foreign_static(it.hir_id, ty.span); vis.check_foreign_static(it.hir_id(), ty.span);
} }
hir::ForeignItemKind::Type => (), hir::ForeignItemKind::Type => (),
} }

View file

@ -4,25 +4,23 @@ use rustc_middle::middle::cstore::ForeignModule;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> { crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
let mut collector = Collector { tcx, modules: Vec::new() }; let mut collector = Collector { modules: Vec::new() };
tcx.hir().krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
collector.modules collector.modules
} }
struct Collector<'tcx> { struct Collector {
tcx: TyCtxt<'tcx>,
modules: Vec<ForeignModule>, modules: Vec<ForeignModule>,
} }
impl ItemLikeVisitor<'tcx> for Collector<'tcx> { impl ItemLikeVisitor<'tcx> for Collector {
fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
let items = match it.kind { let items = match it.kind {
hir::ItemKind::ForeignMod { items, .. } => items, hir::ItemKind::ForeignMod { items, .. } => items,
_ => return, _ => return,
}; };
let foreign_items = let foreign_items = items.iter().map(|it| it.id.def_id.to_def_id()).collect();
items.iter().map(|it| self.tcx.hir().local_def_id(it.id.hir_id).to_def_id()).collect();
self.modules.push(ForeignModule { foreign_items, def_id: it.def_id.to_def_id() }); self.modules.push(ForeignModule { foreign_items, def_id: it.def_id.to_def_id() });
} }

View file

@ -1411,8 +1411,7 @@ impl EncodeContext<'a, 'tcx> {
hir::ItemKind::ForeignMod { items, .. } => record!(self.tables.children[def_id] <- hir::ItemKind::ForeignMod { items, .. } => record!(self.tables.children[def_id] <-
items items
.iter() .iter()
.map(|foreign_item| tcx.hir().local_def_id( .map(|foreign_item| foreign_item.id.def_id.local_def_index)
foreign_item.id.hir_id).local_def_index)
), ),
hir::ItemKind::Enum(..) => record!(self.tables.children[def_id] <- hir::ItemKind::Enum(..) => record!(self.tables.children[def_id] <-
self.tcx.adt_def(def_id).variants.iter().map(|v| { self.tcx.adt_def(def_id).variants.iter().map(|v| {
@ -1859,8 +1858,7 @@ impl Visitor<'tcx> for EncodeContext<'a, 'tcx> {
} }
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem<'tcx>) {
intravisit::walk_foreign_item(self, ni); intravisit::walk_foreign_item(self, ni);
let def_id = self.tcx.hir().local_def_id(ni.hir_id); self.encode_info_for_foreign_item(ni.def_id.to_def_id(), ni);
self.encode_info_for_foreign_item(def_id.to_def_id(), ni);
} }
fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) { fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
intravisit::walk_generics(self, generics); intravisit::walk_generics(self, generics);

View file

@ -354,14 +354,10 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
} }
fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) { fn visit_foreign_item(&mut self, fi: &'hir ForeignItem<'hir>) {
debug_assert_eq!( self.with_dep_node_owner(fi.def_id, fi, |this, hash| {
fi.hir_id.owner, this.insert_with_hash(fi.span, fi.hir_id(), Node::ForeignItem(fi), hash);
self.definitions.opt_hir_id_to_local_def_id(fi.hir_id).unwrap()
);
self.with_dep_node_owner(fi.hir_id.owner, fi, |this, hash| {
this.insert_with_hash(fi.span, fi.hir_id, Node::ForeignItem(fi), hash);
this.with_parent(fi.hir_id, |this| { this.with_parent(fi.hir_id(), |this| {
intravisit::walk_foreign_item(this, fi); intravisit::walk_foreign_item(this, fi);
}); });
}); });

View file

@ -322,7 +322,7 @@ impl<'hir> Map<'hir> {
} }
pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> { pub fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> {
match self.find(id.hir_id).unwrap() { match self.find(id.hir_id()).unwrap() {
Node::ForeignItem(item) => item, Node::ForeignItem(item) => item,
_ => bug!(), _ => bug!(),
} }

View file

@ -1110,7 +1110,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) {
let target = Target::from_foreign_item(f_item); let target = Target::from_foreign_item(f_item);
self.check_attributes( self.check_attributes(
f_item.hir_id, f_item.hir_id(),
&f_item.attrs, &f_item.attrs,
&f_item.span, &f_item.span,
target, target,

View file

@ -453,9 +453,13 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) {
use hir::ForeignItemKind::{Fn, Static}; use hir::ForeignItemKind::{Fn, Static};
if matches!(foreign_item.kind, Static(..) | Fn(..)) if matches!(foreign_item.kind, Static(..) | Fn(..))
&& has_allow_dead_code_or_lang_attr(self.tcx, foreign_item.hir_id, &foreign_item.attrs) && has_allow_dead_code_or_lang_attr(
self.tcx,
foreign_item.hir_id(),
&foreign_item.attrs,
)
{ {
self.worklist.push(foreign_item.hir_id); self.worklist.push(foreign_item.hir_id());
} }
} }
} }
@ -542,8 +546,8 @@ impl DeadVisitor<'tcx> {
} }
fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem<'_>) -> bool { fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem<'_>) -> bool {
!self.symbol_is_live(fi.hir_id) !self.symbol_is_live(fi.hir_id())
&& !has_allow_dead_code_or_lang_attr(self.tcx, fi.hir_id, &fi.attrs) && !has_allow_dead_code_or_lang_attr(self.tcx, fi.hir_id(), &fi.attrs)
} }
// id := HIR id of an item's definition. // id := HIR id of an item's definition.
@ -649,7 +653,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem<'tcx>) {
if self.should_warn_about_foreign_item(fi) { if self.should_warn_about_foreign_item(fi) {
self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name, "used"); self.warn_dead_code(fi.hir_id(), fi.span, fi.ident.name, "used");
} }
intravisit::walk_foreign_item(self, fi); intravisit::walk_foreign_item(self, fi);
} }

View file

@ -39,7 +39,7 @@ impl<'v, 'tcx> ItemLikeVisitor<'v> for DiagnosticItemCollector<'tcx> {
} }
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) {
self.observe_item(foreign_item.attrs, foreign_item.hir_id); self.observe_item(foreign_item.attrs, foreign_item.hir_id());
} }
} }

View file

@ -71,7 +71,7 @@ impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
fn visit_foreign_item(&mut self, i: &'hir hir::ForeignItem<'hir>) { fn visit_foreign_item(&mut self, i: &'hir hir::ForeignItem<'hir>) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map); let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.hir_id, |this| intravisit::walk_foreign_item(this, i)); inner_visitor.check(i.hir_id(), |this| intravisit::walk_foreign_item(this, i));
} }
} }

View file

@ -130,7 +130,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
} }
fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem<'v>) { fn visit_foreign_item(&mut self, i: &'v hir::ForeignItem<'v>) {
self.record("ForeignItem", Id::Node(i.hir_id), i); self.record("ForeignItem", Id::Node(i.hir_id()), i);
hir_visit::walk_foreign_item(self, i) hir_visit::walk_foreign_item(self, i)
} }

View file

@ -459,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
self.annotate( self.annotate(
i.hir_id, i.hir_id(),
&i.attrs, &i.attrs,
i.span, i.span,
AnnotationKind::Required, AnnotationKind::Required,
@ -594,7 +594,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
} }
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
self.check_missing_stability(i.hir_id, i.span); self.check_missing_stability(i.hir_id(), i.span);
intravisit::walk_foreign_item(self, i); intravisit::walk_foreign_item(self, i);
} }

View file

@ -685,7 +685,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
hir::ItemKind::ForeignMod { items, .. } => { hir::ItemKind::ForeignMod { items, .. } => {
for foreign_item in items { for foreign_item in items {
if foreign_item.vis.node.is_pub() { if foreign_item.vis.node.is_pub() {
self.update(foreign_item.id.hir_id, item_level); self.update(foreign_item.id.hir_id(), item_level);
} }
} }
} }
@ -800,9 +800,9 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
// Visit everything, but foreign items have their own levels. // Visit everything, but foreign items have their own levels.
hir::ItemKind::ForeignMod { items, .. } => { hir::ItemKind::ForeignMod { items, .. } => {
for foreign_item in items { for foreign_item in items {
let foreign_item_level = self.get(foreign_item.id.hir_id); let foreign_item_level = self.get(foreign_item.id.hir_id());
if foreign_item_level.is_some() { if foreign_item_level.is_some() {
self.reach(foreign_item.id.hir_id, foreign_item_level) self.reach(foreign_item.id.hir_id(), foreign_item_level)
.generics() .generics()
.predicates() .predicates()
.ty(); .ty();
@ -1653,7 +1653,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
} }
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
if self.access_levels.is_reachable(item.hir_id) { if self.access_levels.is_reachable(item.hir_id()) {
intravisit::walk_foreign_item(self, item) intravisit::walk_foreign_item(self, item)
} }
} }
@ -1982,8 +1982,8 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
// Subitems of foreign modules have their own publicity. // Subitems of foreign modules have their own publicity.
hir::ItemKind::ForeignMod { items, .. } => { hir::ItemKind::ForeignMod { items, .. } => {
for foreign_item in items { for foreign_item in items {
let vis = tcx.visibility(tcx.hir().local_def_id(foreign_item.id.hir_id)); let vis = tcx.visibility(foreign_item.id.def_id);
self.check(foreign_item.id.hir_id, vis).generics().predicates().ty(); self.check(foreign_item.id.hir_id(), vis).generics().predicates().ty();
} }
} }
// Subitems of structs and unions have their own publicity. // Subitems of structs and unions have their own publicity.

View file

@ -1449,14 +1449,14 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
} }
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem<'tcx>) {
let access = access_from!(self.save_ctxt, item, item.hir_id); let access = access_from!(self.save_ctxt, item, item.hir_id());
match item.kind { match item.kind {
hir::ForeignItemKind::Fn(decl, _, ref generics) => { hir::ForeignItemKind::Fn(decl, _, ref generics) => {
if let Some(fn_data) = self.save_ctxt.get_extern_item_data(item) { if let Some(fn_data) = self.save_ctxt.get_extern_item_data(item) {
down_cast_data!(fn_data, DefData, item.span); down_cast_data!(fn_data, DefData, item.span);
self.process_generic_params(generics, &fn_data.qualname, item.hir_id); self.process_generic_params(generics, &fn_data.qualname, item.hir_id());
self.dumper.dump_def(&access, fn_data); self.dumper.dump_def(&access, fn_data);
} }

View file

@ -137,7 +137,7 @@ impl<'tcx> SaveContext<'tcx> {
} }
pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data> { pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data> {
let def_id = self.tcx.hir().local_def_id(item.hir_id).to_def_id(); let def_id = item.def_id.to_def_id();
let qualname = format!("::{}", self.tcx.def_path_str(def_id)); let qualname = format!("::{}", self.tcx.def_path_str(def_id));
match item.kind { match item.kind {
hir::ForeignItemKind::Fn(ref decl, arg_names, ref generics) => { hir::ForeignItemKind::Fn(ref decl, arg_names, ref generics) => {
@ -156,7 +156,7 @@ impl<'tcx> SaveContext<'tcx> {
unsafety: hir::Unsafety::Unsafe, unsafety: hir::Unsafety::Unsafe,
// functions in extern block cannot be const // functions in extern block cannot be const
constness: hir::Constness::NotConst, constness: hir::Constness::NotConst,
abi: self.tcx.hir().get_foreign_abi(item.hir_id), abi: self.tcx.hir().get_foreign_abi(item.hir_id()),
// functions in extern block cannot be async // functions in extern block cannot be async
asyncness: hir::IsAsync::NotAsync, asyncness: hir::IsAsync::NotAsync,
}, },

View file

@ -736,14 +736,14 @@ impl<'hir> Sig for hir::Variant<'hir> {
impl<'hir> Sig for hir::ForeignItem<'hir> { impl<'hir> Sig for hir::ForeignItem<'hir> {
fn make(&self, offset: usize, _parent_id: Option<hir::HirId>, scx: &SaveContext<'_>) -> Result { fn make(&self, offset: usize, _parent_id: Option<hir::HirId>, scx: &SaveContext<'_>) -> Result {
let id = Some(self.hir_id); let id = Some(self.hir_id());
match self.kind { match self.kind {
hir::ForeignItemKind::Fn(decl, _, ref generics) => { hir::ForeignItemKind::Fn(decl, _, ref generics) => {
let mut text = String::new(); let mut text = String::new();
text.push_str("fn "); text.push_str("fn ");
let mut sig = let mut sig =
name_and_generics(text, offset, generics, self.hir_id, self.ident, scx)?; name_and_generics(text, offset, generics, self.hir_id(), self.ident, scx)?;
sig.text.push('('); sig.text.push('(');
for i in decl.inputs { for i in decl.inputs {
@ -774,7 +774,7 @@ impl<'hir> Sig for hir::ForeignItem<'hir> {
} }
let name = self.ident.to_string(); let name = self.ident.to_string();
let defs = vec![SigElement { let defs = vec![SigElement {
id: id_from_hir_id(self.hir_id, scx), id: id_from_def_id(self.def_id.to_def_id()),
start: offset + text.len(), start: offset + text.len(),
end: offset + text.len() + name.len(), end: offset + text.len() + name.len(),
}]; }];
@ -790,7 +790,7 @@ impl<'hir> Sig for hir::ForeignItem<'hir> {
let mut text = "type ".to_owned(); let mut text = "type ".to_owned();
let name = self.ident.to_string(); let name = self.ident.to_string();
let defs = vec![SigElement { let defs = vec![SigElement {
id: id_from_hir_id(self.hir_id, scx), id: id_from_def_id(self.def_id.to_def_id()),
start: offset + text.len(), start: offset + text.len(),
end: offset + text.len() + name.len(), end: offset + text.len() + name.len(),
}]; }];

View file

@ -73,6 +73,6 @@ impl hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'tcx> {
} }
fn visit_foreign_item(&mut self, foreign_item: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, foreign_item: &'tcx hir::ForeignItem<'tcx>) {
self.process_attrs(foreign_item.hir_id); self.process_attrs(foreign_item.hir_id());
} }
} }

View file

@ -776,7 +776,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
} }
} else { } else {
for item in items { for item in items {
let def_id = tcx.hir().local_def_id(item.id.hir_id); let def_id = item.id.def_id;
let generics = tcx.generics_of(def_id); let generics = tcx.generics_of(def_id);
let own_counts = generics.own_counts(); let own_counts = generics.own_counts();
if generics.params.len() - own_counts.lifetimes != 0 { if generics.params.len() - own_counts.lifetimes != 0 {

View file

@ -9,7 +9,6 @@ use crate::require_same_types;
use rustc_errors::struct_span_err; use rustc_errors::struct_span_err;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::subst::Subst; use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
@ -21,7 +20,6 @@ use std::iter;
fn equate_intrinsic_type<'tcx>( fn equate_intrinsic_type<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
it: &hir::ForeignItem<'_>, it: &hir::ForeignItem<'_>,
def_id: DefId,
n_tps: usize, n_tps: usize,
sig: ty::PolyFnSig<'tcx>, sig: ty::PolyFnSig<'tcx>,
) { ) {
@ -35,7 +33,7 @@ fn equate_intrinsic_type<'tcx>(
} }
} }
let i_n_tps = tcx.generics_of(def_id).own_counts().types; let i_n_tps = tcx.generics_of(it.def_id).own_counts().types;
if i_n_tps != n_tps { if i_n_tps != n_tps {
let span = match it.kind { let span = match it.kind {
hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span, hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span,
@ -51,8 +49,8 @@ fn equate_intrinsic_type<'tcx>(
} }
let fty = tcx.mk_fn_ptr(sig); let fty = tcx.mk_fn_ptr(sig);
let cause = ObligationCause::new(it.span, it.hir_id, ObligationCauseCode::IntrinsicType); let cause = ObligationCause::new(it.span, it.hir_id(), ObligationCauseCode::IntrinsicType);
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(def_id)), fty); require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(it.def_id)), fty);
} }
/// Returns `true` if the given intrinsic is unsafe to call or not. /// Returns `true` if the given intrinsic is unsafe to call or not.
@ -100,8 +98,7 @@ pub fn intrinsic_operation_unsafety(intrinsic: Symbol) -> hir::Unsafety {
/// and in `library/core/src/intrinsics.rs`. /// and in `library/core/src/intrinsics.rs`.
pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
let param = |n| tcx.mk_ty_param(n, Symbol::intern(&format!("P{}", n))); let param = |n| tcx.mk_ty_param(n, Symbol::intern(&format!("P{}", n)));
let def_id = tcx.hir().local_def_id(it.hir_id).to_def_id(); let intrinsic_name = tcx.item_name(it.def_id.to_def_id());
let intrinsic_name = tcx.item_name(def_id);
let name_str = intrinsic_name.as_str(); let name_str = intrinsic_name.as_str();
let mk_va_list_ty = |mutbl| { let mk_va_list_ty = |mutbl| {
@ -370,7 +367,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
}; };
let sig = tcx.mk_fn_sig(inputs.into_iter(), output, false, unsafety, Abi::RustIntrinsic); let sig = tcx.mk_fn_sig(inputs.into_iter(), output, false, unsafety, Abi::RustIntrinsic);
let sig = ty::Binder::bind(sig); let sig = ty::Binder::bind(sig);
equate_intrinsic_type(tcx, it, def_id, n_tps, sig) equate_intrinsic_type(tcx, it, n_tps, sig)
} }
/// Type-check `extern "platform-intrinsic" { ... }` functions. /// Type-check `extern "platform-intrinsic" { ... }` functions.
@ -380,7 +377,6 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
tcx.mk_ty_param(n, name) tcx.mk_ty_param(n, name)
}; };
let def_id = tcx.hir().local_def_id(it.hir_id).to_def_id();
let name = it.ident.name; let name = it.ident.name;
let (n_tps, inputs, output) = match name { let (n_tps, inputs, output) = match name {
@ -464,5 +460,5 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
Abi::PlatformIntrinsic, Abi::PlatformIntrinsic,
); );
let sig = ty::Binder::dummy(sig); let sig = ty::Binder::dummy(sig);
equate_intrinsic_type(tcx, it, def_id, n_tps, sig) equate_intrinsic_type(tcx, it, n_tps, sig)
} }

View file

@ -154,10 +154,10 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let it = tcx.hir().foreign_item(it.id); let it = tcx.hir().foreign_item(it.id);
match it.kind { match it.kind {
hir::ForeignItemKind::Fn(ref decl, ..) => { hir::ForeignItemKind::Fn(ref decl, ..) => {
check_item_fn(tcx, it.hir_id, it.ident, it.span, decl) check_item_fn(tcx, it.hir_id(), it.ident, it.span, decl)
} }
hir::ForeignItemKind::Static(ref ty, ..) => { hir::ForeignItemKind::Static(ref ty, ..) => {
check_item_type(tcx, it.hir_id, ty.span, true) check_item_type(tcx, it.hir_id(), ty.span, true)
} }
hir::ForeignItemKind::Type => (), hir::ForeignItemKind::Type => (),
} }

View file

@ -728,12 +728,11 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
hir::ItemKind::ForeignMod { items, .. } => { hir::ItemKind::ForeignMod { items, .. } => {
for item in items { for item in items {
let item = tcx.hir().foreign_item(item.id); let item = tcx.hir().foreign_item(item.id);
let def_id = tcx.hir().local_def_id(item.hir_id); tcx.ensure().generics_of(item.def_id);
tcx.ensure().generics_of(def_id); tcx.ensure().type_of(item.def_id);
tcx.ensure().type_of(def_id); tcx.ensure().predicates_of(item.def_id);
tcx.ensure().predicates_of(def_id);
if let hir::ForeignItemKind::Fn(..) = item.kind { if let hir::ForeignItemKind::Fn(..) = item.kind {
tcx.ensure().fn_sig(def_id); tcx.ensure().fn_sig(item.def_id);
} }
} }
} }

View file

@ -110,7 +110,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) {
if let hir::ForeignItemKind::Fn(..) = foreign_item.kind { if let hir::ForeignItemKind::Fn(..) = foreign_item.kind {
self.visit_node_helper(foreign_item.hir_id); self.visit_node_helper(foreign_item.hir_id());
} }
} }
} }

View file

@ -171,7 +171,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem<'_>) {
if let hir::ForeignItemKind::Fn(..) = foreign_item.kind { if let hir::ForeignItemKind::Fn(..) = foreign_item.kind {
self.add_inferreds_for_item(foreign_item.hir_id); self.add_inferreds_for_item(foreign_item.hir_id());
} }
} }
} }

View file

@ -2239,10 +2239,10 @@ fn clean_use_statement(
impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) { impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
fn clean(&self, cx: &DocContext<'_>) -> Item { fn clean(&self, cx: &DocContext<'_>) -> Item {
let (item, renamed) = self; let (item, renamed) = self;
cx.with_param_env(cx.tcx.hir().local_def_id(item.hir_id).to_def_id(), || { cx.with_param_env(item.def_id.to_def_id(), || {
let kind = match item.kind { let kind = match item.kind {
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => { hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
let abi = cx.tcx.hir().get_foreign_abi(item.hir_id); let abi = cx.tcx.hir().get_foreign_abi(item.hir_id());
let (generics, decl) = enter_impl_trait(cx, || { let (generics, decl) = enter_impl_trait(cx, || {
(generics.clean(cx), (&**decl, &names[..]).clean(cx)) (generics.clean(cx), (&**decl, &names[..]).clean(cx))
}); });
@ -2264,7 +2264,7 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
}; };
Item::from_hir_id_and_parts( Item::from_hir_id_and_parts(
item.hir_id, item.hir_id(),
Some(renamed.unwrap_or(item.ident.name)), Some(renamed.unwrap_or(item.ident.name)),
kind, kind,
cx, cx,

View file

@ -1080,9 +1080,15 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>
} }
fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem<'_>) { fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem<'_>) {
self.visit_testable(item.ident.to_string(), &item.attrs, item.hir_id, item.span, |this| { self.visit_testable(
intravisit::walk_foreign_item(this, item); item.ident.to_string(),
}); &item.attrs,
item.hir_id(),
item.span,
|this| {
intravisit::walk_foreign_item(this, item);
},
);
} }
fn visit_variant( fn visit_variant(