@@ -38,6 +38,7 @@ use syntax::ext::hygiene::ExpnId;
38
38
use syntax:: feature_gate:: is_builtin_attr;
39
39
use syntax:: parse:: token:: { self , Token } ;
40
40
use syntax:: { span_err, struct_span_err} ;
41
+ use syntax:: source_map:: { respan, Spanned } ;
41
42
use syntax:: symbol:: { kw, sym} ;
42
43
use syntax:: visit:: { self , Visitor } ;
43
44
@@ -301,7 +302,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
301
302
}
302
303
}
303
304
304
- fn insert_field_names ( & mut self , def_id : DefId , field_names : Vec < Name > ) {
305
+ fn insert_field_names ( & mut self , def_id : DefId , field_names : Vec < Spanned < Name > > ) {
305
306
if !field_names. is_empty ( ) {
306
307
self . r . field_names . insert ( def_id, field_names) ;
307
308
}
@@ -752,12 +753,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
752
753
}
753
754
754
755
// Record field names for error reporting.
755
- let field_names = struct_def. fields ( ) . iter ( ) . filter_map ( |field| {
756
+ let field_names = struct_def. fields ( ) . iter ( ) . map ( |field| {
756
757
let field_vis = self . resolve_visibility ( & field. vis ) ;
757
758
if ctor_vis. is_at_least ( field_vis, & * self . r ) {
758
759
ctor_vis = field_vis;
759
760
}
760
- field. ident . map ( |ident| ident. name )
761
+ respan ( field. span , field . ident . map_or ( kw :: Invalid , |ident| ident. name ) )
761
762
} ) . collect ( ) ;
762
763
let item_def_id = self . r . definitions . local_def_id ( item. id ) ;
763
764
self . insert_field_names ( item_def_id, field_names) ;
@@ -779,9 +780,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
779
780
self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
780
781
781
782
// Record field names for error reporting.
782
- let field_names = vdata. fields ( ) . iter ( ) . filter_map ( |field| {
783
+ let field_names = vdata. fields ( ) . iter ( ) . map ( |field| {
783
784
self . resolve_visibility ( & field. vis ) ;
784
- field. ident . map ( |ident| ident. name )
785
+ respan ( field. span , field . ident . map_or ( kw :: Invalid , |ident| ident. name ) )
785
786
} ) . collect ( ) ;
786
787
let item_def_id = self . r . definitions . local_def_id ( item. id ) ;
787
788
self . insert_field_names ( item_def_id, field_names) ;
@@ -895,7 +896,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
895
896
// Record some extra data for better diagnostics.
896
897
match res {
897
898
Res :: Def ( DefKind :: Struct , def_id) | Res :: Def ( DefKind :: Union , def_id) => {
898
- let field_names = self . r . cstore . struct_field_names_untracked ( def_id) ;
899
+ let field_names =
900
+ self . r . cstore . struct_field_names_untracked ( def_id, self . r . session ) ;
899
901
self . insert_field_names ( def_id, field_names) ;
900
902
}
901
903
Res :: Def ( DefKind :: Method , def_id) => {
0 commit comments