Skip to content

Commit 9750397

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent 532d1ff commit 9750397

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
@@ -1266,6 +1266,10 @@ pub struct Resolver<'ra, 'tcx> {
12661266

12671267
mods_with_parse_errors: FxHashSet<DefId>,
12681268

1269+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1270+
/// don't need to run it more than once.
1271+
all_crate_macros_already_registered: bool,
1272+
12691273
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12701274
// that were encountered during resolution. These names are used to generate item names
12711275
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1662,6 +1666,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16621666
all_macro_rules: Default::default(),
16631667
delegation_fn_sigs: Default::default(),
16641668
glob_delegation_invoc_ids: Default::default(),
1669+
all_crate_macros_already_registered: false,
16651670
impl_unexpanded_invocations: Default::default(),
16661671
impl_binding_keys: Default::default(),
16671672
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)