@@ -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
@@ -659,7 +659,7 @@ impl<'ra> Module<'ra> {
659
659
fn for_each_child < ' tcx , R , F > ( self , resolver : & mut R , mut f : F )
660
660
where
661
661
R : AsMut < Resolver < ' ra , ' tcx > > ,
662
- F : FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
662
+ F : FnMut ( & mut R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
663
663
{
664
664
for ( key, name_resolution) in resolver. as_mut ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
665
665
if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -681,7 +681,7 @@ impl<'ra> Module<'ra> {
681
681
return ;
682
682
}
683
683
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) ) )
685
685
}
686
686
} ) ;
687
687
* traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1040,7 +1040,7 @@ pub struct Resolver<'ra, 'tcx> {
1040
1040
graph_root : Module < ' ra > ,
1041
1041
1042
1042
prelude : Option < Module < ' ra > > ,
1043
- extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1043
+ extern_prelude : FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' ra > > ,
1044
1044
1045
1045
/// N.B., this is used only for better diagnostics, not name resolution itself.
1046
1046
field_names : LocalDefIdMap < Vec < Ident > > ,
@@ -1467,19 +1467,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1467
1467
let mut invocation_parents = FxHashMap :: default ( ) ;
1468
1468
invocation_parents. insert ( LocalExpnId :: ROOT , InvocationParent :: ROOT ) ;
1469
1469
1470
- let mut extern_prelude: FxIndexMap < Ident , ExternPreludeEntry < ' _ > > = tcx
1470
+ let mut extern_prelude: FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' _ > > = tcx
1471
1471
. sess
1472
1472
. opts
1473
1473
. externs
1474
1474
. iter ( )
1475
1475
. 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
+ } )
1477
1484
. collect ( ) ;
1478
1485
1479
1486
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 ( ) ) ;
1481
1489
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 ( ) ) ;
1483
1492
}
1484
1493
}
1485
1494
@@ -1983,7 +1992,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1983
1992
// Avoid marking `extern crate` items that refer to a name from extern prelude,
1984
1993
// but not introduce it, as used if they are accessed from lexical scope.
1985
1994
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 ) ) {
1987
1996
if !entry. introduced_by_item && entry. binding == Some ( used_binding) {
1988
1997
return ;
1989
1998
}
@@ -2146,7 +2155,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2146
2155
return None ;
2147
2156
}
2148
2157
2149
- let norm_ident = ident . normalize_to_macros_2_0 ( ) ;
2158
+ let norm_ident = Macros20NormalizedIdent :: new ( ident ) ;
2150
2159
let binding = self . extern_prelude . get ( & norm_ident) . cloned ( ) . and_then ( |entry| {
2151
2160
Some ( if let Some ( binding) = entry. binding {
2152
2161
if finalize {
0 commit comments