Skip to content

Commit ac878bc

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent 40cdc7e commit ac878bc

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
@@ -181,6 +181,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
181181
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can
182182
/// find them for suggestions.
183183
pub(crate) fn register_macros_for_all_crates(&mut self) {
184+
if self.all_crate_macros_already_registered {
185+
return;
186+
}
187+
self.all_crate_macros_already_registered = true;
184188
let def_ids = self.cstore().all_proc_macro_def_ids();
185189
for def_id in def_ids {
186190
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
@@ -1216,6 +1216,10 @@ pub struct Resolver<'ra, 'tcx> {
12161216

12171217
mods_with_parse_errors: FxHashSet<DefId>,
12181218

1219+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1220+
/// don't need to run it more than once.
1221+
all_crate_macros_already_registered: bool,
1222+
12191223
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12201224
// that were encountered during resolution. These names are used to generate item names
12211225
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1594,6 +1598,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15941598
all_macro_rules: Default::default(),
15951599
delegation_fn_sigs: Default::default(),
15961600
glob_delegation_invoc_ids: Default::default(),
1601+
all_crate_macros_already_registered: false,
15971602
impl_unexpanded_invocations: Default::default(),
15981603
impl_binding_keys: Default::default(),
15991604
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)