Skip to content
/ rust Public
forked from rust-lang/rust

Commit d35e830

Browse files
committed
Avoid a node_id_to_def_id call by just storing DefIds instead of NodeIds
1 parent 33a6820 commit d35e830

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

compiler/rustc_resolve/src/late.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5007,8 +5007,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
50075007
return false;
50085008
}
50095009
let Some(local_did) = did.as_local() else { return true };
5010-
let node_id = self.r.def_id_to_node_id(local_did);
5011-
!self.r.proc_macros.contains(&node_id)
5010+
!self.r.proc_macros.contains(&local_did)
50125011
}
50135012

50145013
fn resolve_doc_links(&mut self, attrs: &[Attribute], maybe_exported: MaybeExported<'_>) {

compiler/rustc_resolve/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ pub struct Resolver<'ra, 'tcx> {
12001200
trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
12011201
/// A list of proc macro LocalDefIds, written out in the order in which
12021202
/// they are declared in the static array generated by proc_macro_harness.
1203-
proc_macros: Vec<NodeId>,
1203+
proc_macros: Vec<LocalDefId>,
12041204
confused_type_with_std_module: FxIndexMap<Span, Span>,
12051205
/// Whether lifetime elision was successful.
12061206
lifetime_elision_allowed: FxHashSet<NodeId>,
@@ -1640,7 +1640,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16401640
}
16411641

16421642
pub fn into_outputs(self) -> ResolverOutputs {
1643-
let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect();
1643+
let proc_macros = self.proc_macros;
16441644
let expn_that_defined = self.expn_that_defined;
16451645
let extern_crate_map = self.extern_crate_map;
16461646
let maybe_unused_trait_imports = self.maybe_unused_trait_imports;

compiler/rustc_resolve/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
462462
}
463463

464464
fn declare_proc_macro(&mut self, id: NodeId) {
465-
self.proc_macros.push(id)
465+
self.proc_macros.push(self.local_def_id(id))
466466
}
467467

468468
fn append_stripped_cfg_item(&mut self, parent_node: NodeId, ident: Ident, cfg: ast::MetaItem) {

0 commit comments

Comments
 (0)