Skip to content

Commit 4c6f79d

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent 967ff9b commit 4c6f79d

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
@@ -213,6 +213,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
213213
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can
214214
/// find them for suggestions.
215215
pub(crate) fn register_macros_for_all_crates(&mut self) {
216+
if self.all_crate_macros_already_registered {
217+
return;
218+
}
219+
self.all_crate_macros_already_registered = true;
216220
let def_ids = self.cstore().all_proc_macro_def_ids();
217221
for def_id in def_ids {
218222
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
@@ -1243,6 +1243,10 @@ pub struct Resolver<'ra, 'tcx> {
12431243

12441244
mods_with_parse_errors: FxHashSet<DefId>,
12451245

1246+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1247+
/// don't need to run it more than once.
1248+
all_crate_macros_already_registered: bool,
1249+
12461250
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12471251
// that were encountered during resolution. These names are used to generate item names
12481252
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1637,6 +1641,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16371641
all_macro_rules: Default::default(),
16381642
delegation_fn_sigs: Default::default(),
16391643
glob_delegation_invoc_ids: Default::default(),
1644+
all_crate_macros_already_registered: false,
16401645
impl_unexpanded_invocations: Default::default(),
16411646
impl_binding_keys: Default::default(),
16421647
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)