diff options
| author | bors <bors@rust-lang.org> | 2023-05-18 18:53:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-18 18:53:49 +0000 |
| commit | d3f416dc063fc478c7250873246cb2d4136d8c42 (patch) | |
| tree | e3cfd0c6362969617988405e53bc6dd6f95a1e7b /compiler/rustc_resolve/src/lib.rs | |
| parent | fdd030127cc68afec44a8d3f6341525dd34e50ae (diff) | |
| parent | 5b098109765f4198bdff016a856610f3425a2167 (diff) | |
Auto merge of #110493 - bvanjoi:new_disambiguated_key, r=petrochenkov
fix(resolve): only disambiguate binding key during define - close https://github.com/rust-lang/rust/issues/110164 - discussion: https://github.com/rust-lang/rust/pull/110264#discussion_r1168895468 r? `@petrochenkov`
Diffstat (limited to 'compiler/rustc_resolve/src/lib.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 323b78fcd98..14a3671c01d 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -469,6 +469,13 @@ struct BindingKey { disambiguator: u32, } +impl BindingKey { + fn new(ident: Ident, ns: Namespace) -> Self { + let ident = ident.normalize_to_macros_2_0(); + BindingKey { ident, ns, disambiguator: 0 } + } +} + type Resolutions<'a> = RefCell<FxIndexMap<BindingKey, &'a RefCell<NameResolution<'a>>>>; /// One node in the tree of modules. @@ -943,6 +950,7 @@ pub struct Resolver<'a, 'tcx> { empty_module: Module<'a>, module_map: FxHashMap<DefId, Module<'a>>, binding_parent_modules: FxHashMap<Interned<'a, NameBinding<'a>>, Module<'a>>, + underscore_disambiguator: u32, /// Maps glob imports to the names of items actually imported. @@ -1595,7 +1603,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { import_ids } - fn new_key(&mut self, ident: Ident, ns: Namespace) -> BindingKey { + fn new_disambiguated_key(&mut self, ident: Ident, ns: Namespace) -> BindingKey { let ident = ident.normalize_to_macros_2_0(); let disambiguator = if ident.name == kw::Underscore { self.underscore_disambiguator += 1; |
