Skip to content

Commit 7197d32

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent e2f5c69 commit 7197d32

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
191191
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can
192192
/// find them for suggestions.
193193
pub(crate) fn register_macros_for_all_crates(&mut self) {
194+
if self.all_crate_macros_already_registered {
195+
return;
196+
}
197+
self.all_crate_macros_already_registered = true;
194198
let def_ids = self.cstore().all_proc_macro_def_ids();
195199
for def_id in def_ids {
196200
self.get_macro_by_def_id(def_id);

compiler/rustc_resolve/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,10 @@ pub struct Resolver<'ra, 'tcx> {
12281228

12291229
mods_with_parse_errors: FxHashSet<DefId>,
12301230

1231+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1232+
/// don't need to run it more than once.
1233+
all_crate_macros_already_registered: bool,
1234+
12311235
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12321236
// that were encountered during resolution. These names are used to generate item names
12331237
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1589,6 +1593,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15891593
all_macro_rules: Default::default(),
15901594
delegation_fn_sigs: Default::default(),
15911595
glob_delegation_invoc_ids: Default::default(),
1596+
all_crate_macros_already_registered: false,
15921597
impl_unexpanded_invocations: Default::default(),
15931598
impl_binding_keys: Default::default(),
15941599
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)