Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4b55791

Browse files
resolve: Change the underscore disambiguator to avoid regressions
1 parent 67b57f6 commit 4b55791

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

‎compiler/rustc_resolve/src/imports.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
350350
// because they can be fetched by glob imports from those modules, and bring traits
351351
// into scope both directly and through glob imports.
352352
let key = BindingKey::new_disambiguated(ident, ns, || {
353-
(module.0.0.lazy_resolutions.borrow().len() + 1).try_into().unwrap()
353+
module.underscore_disambiguator.update(|d| d + 1);
354+
module.underscore_disambiguator.get()
354355
});
355356
self.update_resolution(module, key, warn_ambiguity, |this, resolution| {
356357
if let Some(old_binding) = resolution.best_binding() {

‎compiler/rustc_resolve/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ struct ModuleData<'ra> {
579579
lazy_resolutions: Resolutions<'ra>,
580580
/// True if this is a module from other crate that needs to be populated on access.
581581
populate_on_access: Cell<bool>,
582+
/// Used to disambiguate underscore items (`const _: T = ...`) in the module.
583+
underscore_disambiguator: Cell<u32>,
582584

583585
/// Macro invocations that can expand into items in this module.
584586
unexpanded_invocations: RefCell<FxHashSet<LocalExpnId>>,
@@ -639,6 +641,7 @@ impl<'ra> ModuleData<'ra> {
639641
kind,
640642
lazy_resolutions: Default::default(),
641643
populate_on_access: Cell::new(is_foreign),
644+
underscore_disambiguator: Cell::new(0),
642645
unexpanded_invocations: Default::default(),
643646
no_implicit_prelude,
644647
glob_importers: RefCell::new(Vec::new()),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /