@@ -580,6 +580,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
580
580
581
581
// Encode the items.
582
582
i = self . position ( ) ;
583
+ self . encode_def_ids ( ) ;
583
584
self . encode_info_for_items ( ) ;
584
585
let item_bytes = self . position ( ) - i;
585
586
@@ -716,6 +717,18 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
716
717
}
717
718
718
719
impl EncodeContext < ' a , ' tcx > {
720
+ fn encode_def_ids ( & mut self ) {
721
+ if self . is_proc_macro {
722
+ return ;
723
+ }
724
+ let tcx = self . tcx ;
725
+ let hir = tcx. hir ( ) ;
726
+ for local_id in hir. iter_local_def_id ( ) {
727
+ let def_id = local_id. to_def_id ( ) ;
728
+ record ! ( self . tables. span[ def_id] <- tcx. def_span( def_id) ) ;
729
+ }
730
+ }
731
+
719
732
fn encode_variances_of ( & mut self , def_id : DefId ) {
720
733
debug ! ( "EncodeContext::encode_variances_of({:?})" , def_id) ;
721
734
record ! ( self . tables. variances[ def_id] <- & self . tcx. variances_of( def_id) [ ..] ) ;
@@ -742,7 +755,6 @@ impl EncodeContext<'a, 'tcx> {
742
755
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Variant ) ;
743
756
record ! ( self . tables. kind[ def_id] <- EntryKind :: Variant ( self . lazy( data) ) ) ;
744
757
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
745
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
746
758
record ! ( self . tables. attributes[ def_id] <- & self . tcx. get_attrs( def_id) [ ..] ) ;
747
759
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
748
760
record ! ( self . tables. children[ def_id] <- variant. fields. iter( ) . map( |f| {
@@ -783,7 +795,6 @@ impl EncodeContext<'a, 'tcx> {
783
795
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Variant ) ;
784
796
record ! ( self . tables. kind[ def_id] <- EntryKind :: Variant ( self . lazy( data) ) ) ;
785
797
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
786
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
787
798
self . encode_stability ( def_id) ;
788
799
self . encode_deprecation ( def_id) ;
789
800
self . encode_item_type ( def_id) ;
@@ -836,7 +847,6 @@ impl EncodeContext<'a, 'tcx> {
836
847
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Mod ) ;
837
848
record ! ( self . tables. kind[ def_id] <- EntryKind :: Mod ( self . lazy( data) ) ) ;
838
849
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
839
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
840
850
record ! ( self . tables. attributes[ def_id] <- attrs) ;
841
851
if self . is_proc_macro {
842
852
record ! ( self . tables. children[ def_id] <- & [ ] ) ;
@@ -868,7 +878,6 @@ impl EncodeContext<'a, 'tcx> {
868
878
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Field ) ;
869
879
record ! ( self . tables. kind[ def_id] <- EntryKind :: Field ) ;
870
880
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
871
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
872
881
record ! ( self . tables. attributes[ def_id] <- variant_data. fields( ) [ field_index] . attrs) ;
873
882
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
874
883
self . encode_ident_span ( def_id, field. ident ) ;
@@ -895,7 +904,6 @@ impl EncodeContext<'a, 'tcx> {
895
904
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Struct ) ;
896
905
record ! ( self . tables. kind[ def_id] <- EntryKind :: Struct ( self . lazy( data) , adt_def. repr) ) ;
897
906
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
898
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
899
907
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
900
908
self . encode_stability ( def_id) ;
901
909
self . encode_deprecation ( def_id) ;
@@ -1003,7 +1011,6 @@ impl EncodeContext<'a, 'tcx> {
1003
1011
}
1004
1012
}
1005
1013
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1006
- record ! ( self . tables. span[ def_id] <- ast_item. span) ;
1007
1014
record ! ( self . tables. attributes[ def_id] <- ast_item. attrs) ;
1008
1015
self . encode_ident_span ( def_id, ast_item. ident ) ;
1009
1016
self . encode_stability ( def_id) ;
@@ -1110,7 +1117,6 @@ impl EncodeContext<'a, 'tcx> {
1110
1117
}
1111
1118
}
1112
1119
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1113
- record ! ( self . tables. span[ def_id] <- ast_item. span) ;
1114
1120
record ! ( self . tables. attributes[ def_id] <- ast_item. attrs) ;
1115
1121
self . encode_ident_span ( def_id, impl_item. ident ) ;
1116
1122
self . encode_stability ( def_id) ;
@@ -1368,7 +1374,6 @@ impl EncodeContext<'a, 'tcx> {
1368
1374
record ! ( self . tables. def_kind[ def_id] <- def_kind) ;
1369
1375
record ! ( self . tables. kind[ def_id] <- entry_kind) ;
1370
1376
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1371
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
1372
1377
record ! ( self . tables. attributes[ def_id] <- item. attrs) ;
1373
1378
record ! ( self . tables. expn_that_defined[ def_id] <- self . tcx. expansion_that_defined( def_id) ) ;
1374
1379
// FIXME(eddyb) there should be a nicer way to do this.
@@ -1489,7 +1494,6 @@ impl EncodeContext<'a, 'tcx> {
1489
1494
record ! ( self . tables. def_kind[ def_id] <- DefKind :: Macro ( MacroKind :: Bang ) ) ;
1490
1495
record ! ( self . tables. kind[ def_id] <- EntryKind :: MacroDef ( self . lazy( macro_def. ast. clone( ) ) ) ) ;
1491
1496
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1492
- record ! ( self . tables. span[ def_id] <- macro_def. span) ;
1493
1497
record ! ( self . tables. attributes[ def_id] <- macro_def. attrs) ;
1494
1498
self . encode_ident_span ( def_id, macro_def. ident ) ;
1495
1499
self . encode_stability ( def_id) ;
@@ -1505,7 +1509,6 @@ impl EncodeContext<'a, 'tcx> {
1505
1509
) {
1506
1510
record ! ( self . tables. def_kind[ def_id] <- def_kind) ;
1507
1511
record ! ( self . tables. kind[ def_id] <- kind) ;
1508
- record ! ( self . tables. span[ def_id] <- self . tcx. def_span( def_id) ) ;
1509
1512
if encode_type {
1510
1513
self . encode_item_type ( def_id) ;
1511
1514
}
@@ -1533,7 +1536,6 @@ impl EncodeContext<'a, 'tcx> {
1533
1536
1534
1537
_ => bug ! ( "closure that is neither generator nor closure" ) ,
1535
1538
}
1536
- record ! ( self . tables. span[ def_id. to_def_id( ) ] <- self . tcx. def_span( def_id) ) ;
1537
1539
record ! ( self . tables. attributes[ def_id. to_def_id( ) ] <- & self . tcx. get_attrs( def_id. to_def_id( ) ) [ ..] ) ;
1538
1540
self . encode_item_type ( def_id. to_def_id ( ) ) ;
1539
1541
if let ty:: Closure ( def_id, substs) = * ty. kind ( ) {
@@ -1559,7 +1561,6 @@ impl EncodeContext<'a, 'tcx> {
1559
1561
1560
1562
record ! ( self . tables. def_kind[ def_id. to_def_id( ) ] <- DefKind :: AnonConst ) ;
1561
1563
record ! ( self . tables. kind[ def_id. to_def_id( ) ] <- EntryKind :: AnonConst ( qualifs, const_data) ) ;
1562
- record ! ( self . tables. span[ def_id. to_def_id( ) ] <- self . tcx. def_span( def_id) ) ;
1563
1564
self . encode_item_type ( def_id. to_def_id ( ) ) ;
1564
1565
self . encode_generics ( def_id. to_def_id ( ) ) ;
1565
1566
self . encode_explicit_predicates ( def_id. to_def_id ( ) ) ;
@@ -1605,6 +1606,8 @@ impl EncodeContext<'a, 'tcx> {
1605
1606
let tcx = self . tcx ;
1606
1607
let hir = tcx. hir ( ) ;
1607
1608
1609
+ record ! ( self . tables. span[ LOCAL_CRATE . as_def_id( ) ] <- hir. span( hir:: CRATE_HIR_ID ) ) ;
1610
+
1608
1611
let proc_macro_decls_static = tcx. proc_macro_decls_static ( LOCAL_CRATE ) . unwrap ( ) . index ;
1609
1612
let stability = tcx. lookup_stability ( DefId :: local ( CRATE_DEF_INDEX ) ) . copied ( ) ;
1610
1613
let macros = self . lazy ( hir. krate ( ) . proc_macros . iter ( ) . map ( |p| p. owner . local_def_index ) ) ;
@@ -1836,7 +1839,6 @@ impl EncodeContext<'a, 'tcx> {
1836
1839
}
1837
1840
}
1838
1841
record ! ( self . tables. visibility[ def_id] <- self . tcx. visibility( def_id) ) ;
1839
- record ! ( self . tables. span[ def_id] <- nitem. span) ;
1840
1842
record ! ( self . tables. attributes[ def_id] <- nitem. attrs) ;
1841
1843
self . encode_ident_span ( def_id, nitem. ident ) ;
1842
1844
self . encode_stability ( def_id) ;
0 commit comments