Avoid a node_id_to_def_id call by just storing DefIds instead of NodeIds

This commit is contained in:
Oli Scherer 2025-04-11 09:34:29 +00:00
parent 33a6820c2f
commit d35e830aad
3 changed files with 4 additions and 5 deletions

View file

@ -5007,8 +5007,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
return false;
}
let Some(local_did) = did.as_local() else { return true };
let node_id = self.r.def_id_to_node_id(local_did);
!self.r.proc_macros.contains(&node_id)
!self.r.proc_macros.contains(&local_did)
}
fn resolve_doc_links(&mut self, attrs: &[Attribute], maybe_exported: MaybeExported<'_>) {

View file

@ -1200,7 +1200,7 @@ pub struct Resolver<'ra, 'tcx> {
trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
/// A list of proc macro LocalDefIds, written out in the order in which
/// they are declared in the static array generated by proc_macro_harness.
proc_macros: Vec<NodeId>,
proc_macros: Vec<LocalDefId>,
confused_type_with_std_module: FxIndexMap<Span, Span>,
/// Whether lifetime elision was successful.
lifetime_elision_allowed: FxHashSet<NodeId>,
@ -1640,7 +1640,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
pub fn into_outputs(self) -> ResolverOutputs {
let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect();
let proc_macros = self.proc_macros;
let expn_that_defined = self.expn_that_defined;
let extern_crate_map = self.extern_crate_map;
let maybe_unused_trait_imports = self.maybe_unused_trait_imports;

View file

@ -462,7 +462,7 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
}
fn declare_proc_macro(&mut self, id: NodeId) {
self.proc_macros.push(id)
self.proc_macros.push(self.local_def_id(id))
}
fn append_stripped_cfg_item(&mut self, parent_node: NodeId, ident: Ident, cfg: ast::MetaItem) {