@@ -71,7 +71,7 @@ use rustc_query_system::ich::StableHashingContext;
7171use rustc_session:: lint:: builtin:: PRIVATE_MACRO_USE ;
7272use rustc_session:: lint:: { BuiltinLintDiag , LintBuffer } ;
7373use 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} ;
7575use smallvec:: { SmallVec , smallvec} ;
7676use tracing:: debug;
7777
@@ -531,7 +531,7 @@ impl ModuleKind {
531531struct BindingKey {
532532 /// The identifier for the binding, always the `normalize_to_macros_2_0` version of the
533533 /// identifier.
534- ident : Ident ,
534+ ident : Macros20NormalizedIdent ,
535535 ns : Namespace ,
536536 /// When we add an underscore binding (with ident `_`) to some module, this field has
537537 /// a non-zero value that uniquely identifies this binding in that module.
@@ -543,7 +543,7 @@ struct BindingKey {
543543
544544impl BindingKey {
545545 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 }
547547 }
548548
549549 fn new_disambiguated (
@@ -552,7 +552,7 @@ impl BindingKey {
552552 disambiguator : impl FnOnce ( ) -> u32 ,
553553 ) -> BindingKey {
554554 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 }
556556 }
557557}
558558
@@ -659,7 +659,7 @@ impl<'ra> Module<'ra> {
659659 fn for_each_child < ' tcx , R , F > ( self , resolver : & mut R , mut f : F )
660660 where
661661 R : AsMut < Resolver < ' ra , ' tcx > > ,
662- F : FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
662+ F : FnMut ( & mut R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
663663 {
664664 for ( key, name_resolution) in resolver. as_mut ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
665665 if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -681,7 +681,7 @@ impl<'ra> Module<'ra> {
681681 return ;
682682 }
683683 if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , def_id) = binding. res ( ) {
684- collected_traits. push ( ( name, binding, r. as_mut ( ) . get_module ( def_id) ) )
684+ collected_traits. push ( ( name. 0 , binding, r. as_mut ( ) . get_module ( def_id) ) )
685685 }
686686 } ) ;
687687 * traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1040,7 +1040,7 @@ pub struct Resolver<'ra, 'tcx> {
10401040 graph_root : Module < ' ra > ,
10411041
10421042 prelude : Option < Module < ' ra > > ,
1043- extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1043+ extern_prelude : FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' ra > > ,
10441044
10451045 /// N.B., this is used only for better diagnostics, not name resolution itself.
10461046 field_names : LocalDefIdMap < Vec < Ident > > ,
@@ -1467,19 +1467,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14671467 let mut invocation_parents = FxHashMap :: default ( ) ;
14681468 invocation_parents. insert ( LocalExpnId :: ROOT , InvocationParent :: ROOT ) ;
14691469
1470- let mut extern_prelude: FxIndexMap < Ident , ExternPreludeEntry < ' _ > > = tcx
1470+ let mut extern_prelude: FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' _ > > = tcx
14711471 . sess
14721472 . opts
14731473 . externs
14741474 . iter ( )
14751475 . filter ( |( _, entry) | entry. add_prelude )
1476- . map ( |( name, _) | ( Ident :: from_str ( name) , Default :: default ( ) ) )
1476+ . map ( |( name, _) | {
1477+ (
1478+ unsafe {
1479+ Macros20NormalizedIdent :: new_without_normalize ( Ident :: from_str ( name) )
1480+ } ,
1481+ Default :: default ( ) ,
1482+ )
1483+ } )
14771484 . collect ( ) ;
14781485
14791486 if !attr:: contains_name ( attrs, sym:: no_core) {
1480- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
1487+ extern_prelude
1488+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
14811489 if !attr:: contains_name ( attrs, sym:: no_std) {
1482- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
1490+ extern_prelude
1491+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
14831492 }
14841493 }
14851494
@@ -1983,7 +1992,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19831992 // Avoid marking `extern crate` items that refer to a name from extern prelude,
19841993 // but not introduce it, as used if they are accessed from lexical scope.
19851994 if used == Used :: Scope {
1986- if let Some ( entry) = self . extern_prelude . get ( & ident . normalize_to_macros_2_0 ( ) ) {
1995+ if let Some ( entry) = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident ) ) {
19871996 if !entry. introduced_by_item && entry. binding == Some ( used_binding) {
19881997 return ;
19891998 }
@@ -2146,7 +2155,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
21462155 return None ;
21472156 }
21482157
2149- let norm_ident = ident . normalize_to_macros_2_0 ( ) ;
2158+ let norm_ident = Macros20NormalizedIdent :: new ( ident ) ;
21502159 let binding = self . extern_prelude . get ( & norm_ident) . cloned ( ) . and_then ( |entry| {
21512160 Some ( if let Some ( binding) = entry. binding {
21522161 if finalize {
0 commit comments