@@ -30,7 +30,7 @@ use rustc_middle::metadata::ModChild;
3030use rustc_middle:: ty:: { self , DefIdTree } ;
3131use rustc_session:: cstore:: CrateStore ;
3232use rustc_span:: hygiene:: { ExpnId , LocalExpnId , MacroKind } ;
33- use rustc_span:: source_map:: { respan, Spanned } ;
33+ use rustc_span:: source_map:: respan;
3434use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3535use rustc_span:: Span ;
3636
@@ -329,10 +329,12 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
329329 . iter ( )
330330 . map ( |field| respan ( field. span , field. ident . map_or ( kw:: Empty , |ident| ident. name ) ) )
331331 . collect ( ) ;
332- self . insert_field_names ( def_id, field_names) ;
332+ self . r . field_names . insert ( def_id, field_names) ;
333333 }
334334
335- fn insert_field_names ( & mut self , def_id : DefId , field_names : Vec < Spanned < Symbol > > ) {
335+ fn insert_field_names_extern ( & mut self , def_id : DefId ) {
336+ let field_names =
337+ self . r . cstore ( ) . struct_field_names_untracked ( def_id, self . r . session ) . collect ( ) ;
336338 self . r . field_names . insert ( def_id, field_names) ;
337339 }
338340
@@ -995,8 +997,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
995997 let cstore = self . r . cstore ( ) ;
996998 match res {
997999 Res :: Def ( DefKind :: Struct , def_id) => {
998- let field_names =
999- cstore. struct_field_names_untracked ( def_id, self . r . session ) . collect ( ) ;
10001000 if let Some ( ( ctor_kind, ctor_def_id) ) = cstore. ctor_untracked ( def_id) {
10011001 let ctor_res = Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id) ;
10021002 let ctor_vis = cstore. visibility_untracked ( ctor_def_id) ;
@@ -1006,13 +1006,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10061006 . struct_constructors
10071007 . insert ( def_id, ( ctor_res, ctor_vis, field_visibilities) ) ;
10081008 }
1009- self . insert_field_names ( def_id, field_names) ;
1010- }
1011- Res :: Def ( DefKind :: Union , def_id) => {
1012- let field_names =
1013- cstore. struct_field_names_untracked ( def_id, self . r . session ) . collect ( ) ;
1014- self . insert_field_names ( def_id, field_names) ;
1009+ self . insert_field_names_extern ( def_id)
10151010 }
1011+ Res :: Def ( DefKind :: Union , def_id) => self . insert_field_names_extern ( def_id) ,
10161012 Res :: Def ( DefKind :: AssocFn , def_id) => {
10171013 if cstore. fn_has_self_parameter_untracked ( def_id, self . r . session ) {
10181014 self . r . has_self . insert ( def_id) ;
@@ -1514,20 +1510,16 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
15141510 } ;
15151511
15161512 // Define a constructor name in the value namespace.
1517- let fields_id = if let Some ( ( ctor_kind, ctor_node_id) ) = CtorKind :: from_ast ( & variant. data ) {
1513+ if let Some ( ( ctor_kind, ctor_node_id) ) = CtorKind :: from_ast ( & variant. data ) {
15181514 let ctor_def_id = self . r . local_def_id ( ctor_node_id) ;
15191515 let ctor_res =
15201516 Res :: Def ( DefKind :: Ctor ( CtorOf :: Variant , ctor_kind) , ctor_def_id. to_def_id ( ) ) ;
15211517 self . r . define ( parent, ident, ValueNS , ( ctor_res, ctor_vis, variant. span , expn_id) ) ;
15221518 self . r . visibilities . insert ( ctor_def_id, ctor_vis) ;
1523- ctor_def_id
1524- } else {
1525- def_id
1526- } ;
1519+ }
15271520
15281521 // Record field names for error reporting.
1529- // FIXME: Always use non-ctor id as the key.
1530- self . insert_field_names_local ( fields_id. to_def_id ( ) , & variant. data ) ;
1522+ self . insert_field_names_local ( def_id. to_def_id ( ) , & variant. data ) ;
15311523
15321524 visit:: walk_variant ( self , variant) ;
15331525 }
0 commit comments