@@ -71,7 +71,7 @@ use rustc_query_system::ich::StableHashingContext;
71
71
use rustc_session:: lint:: builtin:: PRIVATE_MACRO_USE ;
72
72
use rustc_session:: lint:: { BuiltinLintDiag , LintBuffer } ;
73
73
use rustc_span:: hygiene:: { ExpnId , LocalExpnId , MacroKind , SyntaxContext , Transparency } ;
74
- use rustc_span:: { DUMMY_SP , Ident , Span , Symbol , kw, sym} ;
74
+ use rustc_span:: { DUMMY_SP , Ident , Macros20NormalizedIdent , Span , Symbol , kw, sym} ;
75
75
use smallvec:: { SmallVec , smallvec} ;
76
76
use tracing:: debug;
77
77
@@ -531,7 +531,7 @@ impl ModuleKind {
531
531
struct BindingKey {
532
532
/// The identifier for the binding, always the `normalize_to_macros_2_0` version of the
533
533
/// identifier.
534
- ident : Ident ,
534
+ ident : Macros20NormalizedIdent ,
535
535
ns : Namespace ,
536
536
/// When we add an underscore binding (with ident `_`) to some module, this field has
537
537
/// a non-zero value that uniquely identifies this binding in that module.
@@ -543,7 +543,7 @@ struct BindingKey {
543
543
544
544
impl BindingKey {
545
545
fn new ( ident : Ident , ns : Namespace ) -> Self {
546
- BindingKey { ident : ident . normalize_to_macros_2_0 ( ) , ns, disambiguator : 0 }
546
+ BindingKey { ident : Macros20NormalizedIdent :: new ( ident ) , ns, disambiguator : 0 }
547
547
}
548
548
549
549
fn new_disambiguated (
@@ -552,7 +552,7 @@ impl BindingKey {
552
552
disambiguator : impl FnOnce ( ) -> u32 ,
553
553
) -> BindingKey {
554
554
let disambiguator = if ident. name == kw:: Underscore { disambiguator ( ) } else { 0 } ;
555
- BindingKey { ident : ident . normalize_to_macros_2_0 ( ) , ns, disambiguator }
555
+ BindingKey { ident : Macros20NormalizedIdent :: new ( ident ) , ns, disambiguator }
556
556
}
557
557
}
558
558
@@ -593,7 +593,8 @@ struct ModuleData<'ra> {
593
593
globs : RefCell < Vec < Import < ' ra > > > ,
594
594
595
595
/// Used to memoize the traits in this module for faster searches through all traits in scope.
596
- traits : RefCell < Option < Box < [ ( Ident , NameBinding < ' ra > , Option < Module < ' ra > > ) ] > > > ,
596
+ traits :
597
+ RefCell < Option < Box < [ ( Macros20NormalizedIdent , NameBinding < ' ra > , Option < Module < ' ra > > ) ] > > > ,
597
598
598
599
/// Span of the module itself. Used for error reporting.
599
600
span : Span ,
@@ -659,7 +660,7 @@ impl<'ra> Module<'ra> {
659
660
fn for_each_child < ' tcx , R : AsRef < Resolver < ' ra , ' tcx > > > (
660
661
self ,
661
662
resolver : & R ,
662
- mut f : impl FnMut ( & R , Ident , Namespace , NameBinding < ' ra > ) ,
663
+ mut f : impl FnMut ( & R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
663
664
) {
664
665
for ( key, name_resolution) in resolver. as_ref ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
665
666
if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -671,7 +672,7 @@ impl<'ra> Module<'ra> {
671
672
fn for_each_child_mut < ' tcx , R : AsMut < Resolver < ' ra , ' tcx > > > (
672
673
self ,
673
674
resolver : & mut R ,
674
- mut f : impl FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
675
+ mut f : impl FnMut ( & mut R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
675
676
) {
676
677
for ( key, name_resolution) in resolver. as_mut ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
677
678
if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -1054,7 +1055,7 @@ pub struct Resolver<'ra, 'tcx> {
1054
1055
graph_root : Module < ' ra > ,
1055
1056
1056
1057
prelude : Option < Module < ' ra > > ,
1057
- extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1058
+ extern_prelude : FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' ra > > ,
1058
1059
1059
1060
/// N.B., this is used only for better diagnostics, not name resolution itself.
1060
1061
field_names : LocalDefIdMap < Vec < Ident > > ,
@@ -1499,17 +1500,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1499
1500
&& let name = Symbol :: intern ( name)
1500
1501
&& name. can_be_raw ( )
1501
1502
{
1502
- Some ( ( Ident :: with_dummy_span ( name) , Default :: default ( ) ) )
1503
+ Some ( ( Macros20NormalizedIdent :: with_dummy_span ( name) , Default :: default ( ) ) )
1503
1504
} else {
1504
1505
None
1505
1506
}
1506
1507
} )
1507
1508
. collect ( ) ;
1508
1509
1509
1510
if !attr:: contains_name ( attrs, sym:: no_core) {
1510
- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
1511
+ extern_prelude
1512
+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
1511
1513
if !attr:: contains_name ( attrs, sym:: no_std) {
1512
- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
1514
+ extern_prelude
1515
+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
1513
1516
}
1514
1517
}
1515
1518
@@ -1879,7 +1882,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1879
1882
for & ( trait_name, trait_binding, trait_module) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
1880
1883
if self . trait_may_have_item ( trait_module, assoc_item) {
1881
1884
let def_id = trait_binding. res ( ) . def_id ( ) ;
1882
- let import_ids = self . find_transitive_imports ( & trait_binding. kind , trait_name) ;
1885
+ let import_ids = self . find_transitive_imports ( & trait_binding. kind , trait_name. 0 ) ;
1883
1886
found_traits. push ( TraitCandidate { def_id, import_ids } ) ;
1884
1887
}
1885
1888
}
@@ -2020,7 +2023,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2020
2023
// Avoid marking `extern crate` items that refer to a name from extern prelude,
2021
2024
// but not introduce it, as used if they are accessed from lexical scope.
2022
2025
if used == Used :: Scope {
2023
- if let Some ( entry) = self . extern_prelude . get ( & ident . normalize_to_macros_2_0 ( ) ) {
2026
+ if let Some ( entry) = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident ) ) {
2024
2027
if !entry. introduced_by_item && entry. binding . get ( ) == Some ( used_binding) {
2025
2028
return ;
2026
2029
}
@@ -2179,7 +2182,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2179
2182
2180
2183
fn extern_prelude_get ( & mut self , ident : Ident , finalize : bool ) -> Option < NameBinding < ' ra > > {
2181
2184
let mut record_use = None ;
2182
- let entry = self . extern_prelude . get ( & ident . normalize_to_macros_2_0 ( ) ) ;
2185
+ let entry = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident ) ) ;
2183
2186
let binding = entry. and_then ( |entry| match entry. binding . get ( ) {
2184
2187
Some ( binding) if binding. is_import ( ) => {
2185
2188
if finalize {
0 commit comments