@@ -29,7 +29,6 @@ use rustc_middle::metadata::ModChild;
29
29
use rustc_middle:: { bug, ty} ;
30
30
use rustc_session:: cstore:: CrateStore ;
31
31
use rustc_span:: hygiene:: { ExpnId , LocalExpnId , MacroKind } ;
32
- use rustc_span:: source_map:: respan;
33
32
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
34
33
use rustc_span:: Span ;
35
34
@@ -130,12 +129,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
130
129
} ;
131
130
132
131
let expn_id = self . cstore ( ) . module_expansion_untracked ( def_id, & self . tcx . sess ) ;
133
- let span = self . cstore ( ) . get_span_untracked ( def_id, & self . tcx . sess ) ;
134
132
Some ( self . new_module (
135
133
parent,
136
134
ModuleKind :: Def ( def_kind, def_id, name) ,
137
135
expn_id,
138
- span ,
136
+ self . def_span ( def_id ) ,
139
137
// FIXME: Account for `#[no_implicit_prelude]` attributes.
140
138
parent. map_or ( false , |module| module. no_implicit_prelude ) ,
141
139
) )
@@ -328,13 +326,13 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
328
326
}
329
327
}
330
328
331
- fn insert_field_names_local ( & mut self , def_id : DefId , vdata : & ast:: VariantData ) {
332
- let field_names = vdata
333
- . fields ( )
334
- . iter ( )
335
- . map ( |field| respan ( field . span , field . ident . map_or ( kw :: Empty , |ident| ident . name ) ) )
336
- . collect ( ) ;
337
- self . r . field_names . insert ( def_id, field_names ) ;
329
+ fn insert_field_def_ids ( & mut self , def_id : LocalDefId , vdata : & ast:: VariantData ) {
330
+ if vdata . fields ( ) . iter ( ) . any ( |field| field . is_placeholder ) {
331
+ // The fields are not expanded yet.
332
+ return ;
333
+ }
334
+ let def_ids = vdata . fields ( ) . iter ( ) . map ( |field| self . r . local_def_id ( field . id ) . to_def_id ( ) ) ;
335
+ self . r . field_def_ids . insert ( def_id, self . r . tcx . arena . alloc_from_iter ( def_ids ) ) ;
338
336
}
339
337
340
338
fn insert_field_visibilities_local ( & mut self , def_id : DefId , vdata : & ast:: VariantData ) {
@@ -346,12 +344,6 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
346
344
self . r . field_visibility_spans . insert ( def_id, field_vis) ;
347
345
}
348
346
349
- fn insert_field_names_extern ( & mut self , def_id : DefId ) {
350
- let field_names =
351
- self . r . cstore ( ) . struct_field_names_untracked ( def_id, self . r . tcx . sess ) . collect ( ) ;
352
- self . r . field_names . insert ( def_id, field_names) ;
353
- }
354
-
355
347
fn block_needs_anonymous_module ( & mut self , block : & Block ) -> bool {
356
348
// If any statements are items, we need to create an anonymous module
357
349
block
@@ -749,7 +741,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
749
741
self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
750
742
751
743
// Record field names for error reporting.
752
- self . insert_field_names_local ( def_id , vdata) ;
744
+ self . insert_field_def_ids ( local_def_id , vdata) ;
753
745
self . insert_field_visibilities_local ( def_id, vdata) ;
754
746
755
747
// If this is a tuple or unit struct, define a name
@@ -789,7 +781,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
789
781
790
782
self . r
791
783
. struct_constructors
792
- . insert ( def_id , ( ctor_res, ctor_vis. to_def_id ( ) , ret_fields) ) ;
784
+ . insert ( local_def_id , ( ctor_res, ctor_vis. to_def_id ( ) , ret_fields) ) ;
793
785
}
794
786
}
795
787
@@ -798,7 +790,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
798
790
self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
799
791
800
792
// Record field names for error reporting.
801
- self . insert_field_names_local ( def_id , vdata) ;
793
+ self . insert_field_def_ids ( local_def_id , vdata) ;
802
794
self . insert_field_visibilities_local ( def_id, vdata) ;
803
795
}
804
796
@@ -1004,32 +996,6 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1004
996
| Res :: SelfCtor ( ..)
1005
997
| Res :: Err => bug ! ( "unexpected resolution: {:?}" , res) ,
1006
998
}
1007
- // Record some extra data for better diagnostics.
1008
- match res {
1009
- Res :: Def ( DefKind :: Struct , def_id) => {
1010
- let cstore = self . r . cstore ( ) ;
1011
- if let Some ( ( ctor_kind, ctor_def_id) ) = cstore. ctor_untracked ( def_id) {
1012
- let ctor_res = Res :: Def ( DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) , ctor_def_id) ;
1013
- let ctor_vis = cstore. visibility_untracked ( ctor_def_id) ;
1014
- let field_visibilities =
1015
- cstore. struct_field_visibilities_untracked ( def_id) . collect ( ) ;
1016
- drop ( cstore) ;
1017
- self . r
1018
- . struct_constructors
1019
- . insert ( def_id, ( ctor_res, ctor_vis, field_visibilities) ) ;
1020
- } else {
1021
- drop ( cstore) ;
1022
- }
1023
- self . insert_field_names_extern ( def_id)
1024
- }
1025
- Res :: Def ( DefKind :: Union , def_id) => self . insert_field_names_extern ( def_id) ,
1026
- Res :: Def ( DefKind :: AssocFn , def_id) => {
1027
- if self . r . cstore ( ) . fn_has_self_parameter_untracked ( def_id, self . r . tcx . sess ) {
1028
- self . r . has_self . insert ( def_id) ;
1029
- }
1030
- }
1031
- _ => { }
1032
- }
1033
999
}
1034
1000
1035
1001
fn add_macro_use_binding (
@@ -1426,7 +1392,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1426
1392
AssocItemKind :: Const ( ..) => ( DefKind :: AssocConst , ValueNS ) ,
1427
1393
AssocItemKind :: Fn ( box Fn { ref sig, .. } ) => {
1428
1394
if sig. decl . has_self ( ) {
1429
- self . r . has_self . insert ( def_id ) ;
1395
+ self . r . has_self . insert ( local_def_id ) ;
1430
1396
}
1431
1397
( DefKind :: AssocFn , ValueNS )
1432
1398
}
@@ -1540,7 +1506,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
1540
1506
}
1541
1507
1542
1508
// Record field names for error reporting.
1543
- self . insert_field_names_local ( def_id. to_def_id ( ) , & variant. data ) ;
1509
+ self . insert_field_def_ids ( def_id, & variant. data ) ;
1544
1510
self . insert_field_visibilities_local ( def_id. to_def_id ( ) , & variant. data ) ;
1545
1511
1546
1512
visit:: walk_variant ( self , variant) ;
0 commit comments