@@ -33,7 +33,7 @@ use rustc_session::parse::feature_err;
33
33
use rustc_span:: edit_distance:: find_best_match_for_name;
34
34
use rustc_span:: hygiene:: DesugaringKind ;
35
35
use rustc_span:: source_map:: Spanned ;
36
- use rustc_span:: { Ident , Span , Symbol , kw, sym} ;
36
+ use rustc_span:: { Ident , ModernIdent , Span , Symbol , kw, sym} ;
37
37
use rustc_trait_selection:: infer:: InferCtxtExt ;
38
38
use rustc_trait_selection:: traits:: { self , ObligationCauseCode , ObligationCtxt } ;
39
39
use tracing:: { debug, instrument, trace} ;
@@ -2035,7 +2035,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2035
2035
let mut remaining_fields = variant
2036
2036
. fields
2037
2037
. iter_enumerated ( )
2038
- . map ( |( i, field) | ( field. ident ( tcx) . normalize_to_macros_2_0 ( ) , ( i, field) ) )
2038
+ . map ( |( i, field) | ( ModernIdent :: new ( field. ident ( tcx) ) , ( i, field) ) )
2039
2039
. collect :: < UnordMap < _ , _ > > ( ) ;
2040
2040
2041
2041
let mut seen_fields = FxHashMap :: default ( ) ;
@@ -2072,7 +2072,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2072
2072
self . dcx ( ) . emit_err ( FieldMultiplySpecifiedInInitializer {
2073
2073
span : field. ident . span ,
2074
2074
prev_span : * prev_span,
2075
- ident,
2075
+ ident : ident . 0 ,
2076
2076
} )
2077
2077
} else {
2078
2078
self . report_unknown_field (
@@ -2388,7 +2388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2388
2388
adt_ty : Ty < ' tcx > ,
2389
2389
span : Span ,
2390
2390
full_span : Span ,
2391
- remaining_fields : UnordMap < Ident , ( FieldIdx , & ty:: FieldDef ) > ,
2391
+ remaining_fields : UnordMap < ModernIdent , ( FieldIdx , & ty:: FieldDef ) > ,
2392
2392
variant : & ' tcx ty:: VariantDef ,
2393
2393
hir_fields : & ' tcx [ hir:: ExprField < ' tcx > ] ,
2394
2394
args : GenericArgsRef < ' tcx > ,
@@ -2818,15 +2818,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2818
2818
fn find_adt_field (
2819
2819
& self ,
2820
2820
base_def : ty:: AdtDef < ' tcx > ,
2821
- ident : Ident ,
2821
+ ident : ModernIdent ,
2822
2822
) -> Option < ( FieldIdx , & ' tcx ty:: FieldDef ) > {
2823
2823
// No way to find a field in an enum.
2824
2824
if base_def. is_enum ( ) {
2825
2825
return None ;
2826
2826
}
2827
2827
2828
2828
for ( field_idx, field) in base_def. non_enum_variant ( ) . fields . iter_enumerated ( ) {
2829
- if field. ident ( self . tcx ) . normalize_to_macros_2_0 ( ) == ident {
2829
+ if ModernIdent :: new ( field. ident ( self . tcx ) ) == ident {
2830
2830
// We found the field we wanted.
2831
2831
return Some ( ( field_idx, field) ) ;
2832
2832
}
@@ -3449,10 +3449,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3449
3449
matches : & impl Fn ( & ty:: FieldDef , Ty < ' tcx > ) -> bool ,
3450
3450
candidate_field : & ty:: FieldDef ,
3451
3451
subst : GenericArgsRef < ' tcx > ,
3452
- mut field_path : Vec < Ident > ,
3452
+ mut field_path : Vec < ModernIdent > ,
3453
3453
mod_id : DefId ,
3454
3454
hir_id : HirId ,
3455
- ) -> Option < Vec < Ident > > {
3455
+ ) -> Option < Vec < ModernIdent > > {
3456
3456
debug ! (
3457
3457
"check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}" ,
3458
3458
span, candidate_field, field_path
@@ -3463,7 +3463,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3463
3463
// up to a depth of three
3464
3464
None
3465
3465
} else {
3466
- field_path. push ( candidate_field. ident ( self . tcx ) . normalize_to_macros_2_0 ( ) ) ;
3466
+ field_path. push ( ModernIdent :: new ( candidate_field. ident ( self . tcx ) ) ) ;
3467
3467
let field_ty = candidate_field. ty ( self . tcx , subst) ;
3468
3468
if matches ( candidate_field, field_ty) {
3469
3469
return Some ( field_path) ;
@@ -3860,10 +3860,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3860
3860
let Some ( ( index, variant) ) = container_def
3861
3861
. variants ( )
3862
3862
. iter_enumerated ( )
3863
- . find ( |( _, v) | v. ident ( self . tcx ) . normalize_to_macros_2_0 ( ) == ident)
3863
+ . find ( |( _, v) | ModernIdent :: new ( v. ident ( self . tcx ) ) == ident)
3864
3864
else {
3865
3865
self . dcx ( )
3866
- . create_err ( NoVariantNamed { span : ident. span , ident, ty : container } )
3866
+ . create_err ( NoVariantNamed {
3867
+ span : ident. span ,
3868
+ ident : ident. 0 ,
3869
+ ty : container,
3870
+ } )
3867
3871
. with_span_label ( field. span , "variant not found" )
3868
3872
. emit_unless_delay ( container. references_error ( ) ) ;
3869
3873
break ;
@@ -3886,13 +3890,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3886
3890
let Some ( ( subindex, field) ) = variant
3887
3891
. fields
3888
3892
. iter_enumerated ( )
3889
- . find ( |( _, f) | f. ident ( self . tcx ) . normalize_to_macros_2_0 ( ) == subident)
3893
+ . find ( |( _, f) | ModernIdent :: new ( f. ident ( self . tcx ) ) == subident)
3890
3894
else {
3891
3895
self . dcx ( )
3892
3896
. create_err ( NoFieldOnVariant {
3893
3897
span : ident. span ,
3894
3898
container,
3895
- ident,
3899
+ ident : ident . 0 ,
3896
3900
field : subfield,
3897
3901
enum_span : field. span ,
3898
3902
field_span : subident. span ,
@@ -3918,7 +3922,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3918
3922
if field. vis . is_accessible_from ( sub_def_scope, self . tcx ) {
3919
3923
self . tcx . check_stability ( field. did , Some ( expr. hir_id ) , expr. span , None ) ;
3920
3924
} else {
3921
- self . private_field_err ( ident, container_def. did ( ) ) . emit ( ) ;
3925
+ self . private_field_err ( ident. 0 , container_def. did ( ) ) . emit ( ) ;
3922
3926
}
3923
3927
3924
3928
// Save the index of all fields regardless of their visibility in case
@@ -3936,7 +3940,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3936
3940
let fields = & container_def. non_enum_variant ( ) . fields ;
3937
3941
if let Some ( ( index, field) ) = fields
3938
3942
. iter_enumerated ( )
3939
- . find ( |( _, f) | f. ident ( self . tcx ) . normalize_to_macros_2_0 ( ) == ident)
3943
+ . find ( |( _, f) | ModernIdent :: new ( f. ident ( self . tcx ) ) == ident)
3940
3944
{
3941
3945
let field_ty = self . field_ty ( expr. span , field, args) ;
3942
3946
@@ -3953,7 +3957,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3953
3957
if field. vis . is_accessible_from ( def_scope, self . tcx ) {
3954
3958
self . tcx . check_stability ( field. did , Some ( expr. hir_id ) , expr. span , None ) ;
3955
3959
} else {
3956
- self . private_field_err ( ident, container_def. did ( ) ) . emit ( ) ;
3960
+ self . private_field_err ( ident. 0 , container_def. did ( ) ) . emit ( ) ;
3957
3961
}
3958
3962
3959
3963
// Save the index of all fields regardless of their visibility in case
0 commit comments