@@ -38,6 +38,7 @@ use syntax::ext::hygiene::ExpnId;
3838use syntax:: feature_gate:: is_builtin_attr;
3939use syntax:: parse:: token:: { self , Token } ;
4040use syntax:: { span_err, struct_span_err} ;
41+ use syntax:: source_map:: { respan, Spanned } ;
4142use syntax:: symbol:: { kw, sym} ;
4243use syntax:: visit:: { self , Visitor } ;
4344
@@ -301,7 +302,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
301302 }
302303 }
303304
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 > > ) {
305306 if !field_names. is_empty ( ) {
306307 self . r . field_names . insert ( def_id, field_names) ;
307308 }
@@ -752,12 +753,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
752753 }
753754
754755 // 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| {
756757 let field_vis = self . resolve_visibility ( & field. vis ) ;
757758 if ctor_vis. is_at_least ( field_vis, & * self . r ) {
758759 ctor_vis = field_vis;
759760 }
760- field. ident . map ( |ident| ident. name )
761+ respan ( field. span , field . ident . map_or ( kw :: Invalid , |ident| ident. name ) )
761762 } ) . collect ( ) ;
762763 let item_def_id = self . r . definitions . local_def_id ( item. id ) ;
763764 self . insert_field_names ( item_def_id, field_names) ;
@@ -779,9 +780,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
779780 self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
780781
781782 // 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| {
783784 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 ) )
785786 } ) . collect ( ) ;
786787 let item_def_id = self . r . definitions . local_def_id ( item. id ) ;
787788 self . insert_field_names ( item_def_id, field_names) ;
@@ -895,7 +896,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
895896 // Record some extra data for better diagnostics.
896897 match res {
897898 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 ) ;
899901 self . insert_field_names ( def_id, field_names) ;
900902 }
901903 Res :: Def ( DefKind :: Method , def_id) => {
0 commit comments