Skip to content

Commit 36db25a

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent 056c1e4 commit 36db25a

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

12261226
mods_with_parse_errors: FxHashSet<DefId>,
12271227

1228+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1229+
/// don't need to run it more than once.
1230+
all_crate_macros_already_registered: bool,
1231+
12281232
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12291233
// that were encountered during resolution. These names are used to generate item names
12301234
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1602,6 +1606,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16021606
all_macro_rules: Default::default(),
16031607
delegation_fn_sigs: Default::default(),
16041608
glob_delegation_invoc_ids: Default::default(),
1609+
all_crate_macros_already_registered: false,
16051610
impl_unexpanded_invocations: Default::default(),
16061611
impl_binding_keys: Default::default(),
16071612
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)