@@ -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 : AsRef < Resolver < ' ra , ' tcx > > > (
660
660
self ,
661
661
resolver : & R ,
662
- mut f : impl FnMut ( & R , Ident , Namespace , NameBinding < ' ra > ) ,
662
+ mut f : impl FnMut ( & R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
663
663
) {
664
664
for ( key, name_resolution) in resolver. as_ref ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
665
665
if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -671,7 +671,7 @@ impl<'ra> Module<'ra> {
671
671
fn for_each_child_mut < ' tcx , R : AsMut < Resolver < ' ra , ' tcx > > > (
672
672
self ,
673
673
resolver : & mut R ,
674
- mut f : impl FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
674
+ mut f : impl FnMut ( & mut R , Macros20NormalizedIdent , Namespace , NameBinding < ' ra > ) ,
675
675
) {
676
676
for ( key, name_resolution) in resolver. as_mut ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
677
677
if let Some ( binding) = name_resolution. borrow ( ) . best_binding ( ) {
@@ -690,7 +690,7 @@ impl<'ra> Module<'ra> {
690
690
return ;
691
691
}
692
692
if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , def_id) = binding. res ( ) {
693
- collected_traits. push ( ( name, binding, r. as_ref ( ) . get_module ( def_id) ) )
693
+ collected_traits. push ( ( name. 0 , binding, r. as_ref ( ) . get_module ( def_id) ) )
694
694
}
695
695
} ) ;
696
696
* traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1049,7 +1049,7 @@ pub struct Resolver<'ra, 'tcx> {
1049
1049
graph_root : Module < ' ra > ,
1050
1050
1051
1051
prelude : Option < Module < ' ra > > ,
1052
- extern_prelude : FxIndexMap < Ident , ExternPreludeEntry < ' ra > > ,
1052
+ extern_prelude : FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' ra > > ,
1053
1053
1054
1054
/// N.B., this is used only for better diagnostics, not name resolution itself.
1055
1055
field_names : LocalDefIdMap < Vec < Ident > > ,
@@ -1482,19 +1482,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1482
1482
let mut invocation_parents = FxHashMap :: default ( ) ;
1483
1483
invocation_parents. insert ( LocalExpnId :: ROOT , InvocationParent :: ROOT ) ;
1484
1484
1485
- let mut extern_prelude: FxIndexMap < Ident , ExternPreludeEntry < ' _ > > = tcx
1485
+ let mut extern_prelude: FxIndexMap < Macros20NormalizedIdent , ExternPreludeEntry < ' _ > > = tcx
1486
1486
. sess
1487
1487
. opts
1488
1488
. externs
1489
1489
. iter ( )
1490
1490
. filter ( |( _, entry) | entry. add_prelude )
1491
- . map ( |( name, _) | ( Ident :: from_str ( name) , Default :: default ( ) ) )
1491
+ . map ( |( name, _) | {
1492
+ (
1493
+ unsafe {
1494
+ Macros20NormalizedIdent :: new_without_normalize ( Ident :: from_str ( name) )
1495
+ } ,
1496
+ Default :: default ( ) ,
1497
+ )
1498
+ } )
1492
1499
. collect ( ) ;
1493
1500
1494
1501
if !attr:: contains_name ( attrs, sym:: no_core) {
1495
- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
1502
+ extern_prelude
1503
+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: core) , Default :: default ( ) ) ;
1496
1504
if !attr:: contains_name ( attrs, sym:: no_std) {
1497
- extern_prelude. insert ( Ident :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
1505
+ extern_prelude
1506
+ . insert ( Macros20NormalizedIdent :: with_dummy_span ( sym:: std) , Default :: default ( ) ) ;
1498
1507
}
1499
1508
}
1500
1509
@@ -2005,7 +2014,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2005
2014
// Avoid marking `extern crate` items that refer to a name from extern prelude,
2006
2015
// but not introduce it, as used if they are accessed from lexical scope.
2007
2016
if used == Used :: Scope {
2008
- if let Some ( entry) = self . extern_prelude . get ( & ident . normalize_to_macros_2_0 ( ) ) {
2017
+ if let Some ( entry) = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident ) ) {
2009
2018
if !entry. introduced_by_item && entry. binding == Some ( used_binding) {
2010
2019
return ;
2011
2020
}
@@ -2168,7 +2177,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2168
2177
return None ;
2169
2178
}
2170
2179
2171
- let norm_ident = ident . normalize_to_macros_2_0 ( ) ;
2180
+ let norm_ident = Macros20NormalizedIdent :: new ( ident ) ;
2172
2181
let binding = self . extern_prelude . get ( & norm_ident) . cloned ( ) . and_then ( |entry| {
2173
2182
Some ( if let Some ( binding) = entry. binding {
2174
2183
if finalize {
0 commit comments