@@ -31,7 +31,7 @@ use rustc_middle::query::Providers;
31
31
use rustc_middle:: traits:: specialization_graph;
32
32
use rustc_middle:: ty:: codec:: TyEncoder ;
33
33
use rustc_middle:: ty:: fast_reject:: { self , SimplifiedType , TreatParams } ;
34
- use rustc_middle:: ty:: { self , SymbolName , Ty , TyCtxt } ;
34
+ use rustc_middle:: ty:: { self , AssocItemContainer , SymbolName , Ty , TyCtxt } ;
35
35
use rustc_middle:: util:: common:: to_readable_str;
36
36
use rustc_serialize:: { opaque, Decodable , Decoder , Encodable , Encoder } ;
37
37
use rustc_session:: config:: { CrateType , OptLevel } ;
@@ -1416,6 +1416,18 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1416
1416
if let DefKind :: Generator = def_kind {
1417
1417
self . encode_info_for_generator ( local_id) ;
1418
1418
}
1419
+ if let DefKind :: Trait | DefKind :: Impl { .. } = def_kind {
1420
+ let associated_item_def_ids = self . tcx . associated_item_def_ids ( def_id) ;
1421
+ record_array ! ( self . tables. associated_item_or_field_def_ids[ def_id] <-
1422
+ associated_item_def_ids. iter( ) . map( |& def_id| {
1423
+ assert!( def_id. is_local( ) ) ;
1424
+ def_id. index
1425
+ } )
1426
+ ) ;
1427
+ for & def_id in associated_item_def_ids {
1428
+ self . encode_info_for_assoc_item ( def_id) ;
1429
+ }
1430
+ }
1419
1431
if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
1420
1432
self . encode_info_for_adt ( local_id) ;
1421
1433
}
@@ -1523,41 +1535,28 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1523
1535
record_defaulted_array ! ( self . tables. explicit_item_bounds[ def_id] <- bounds) ;
1524
1536
}
1525
1537
1526
- fn encode_info_for_trait_item ( & mut self , def_id : DefId ) {
1527
- debug ! ( "EncodeContext::encode_info_for_trait_item({:?})" , def_id) ;
1538
+ # [ tracing :: instrument ( level = "debug" , skip ( self ) ) ]
1539
+ fn encode_info_for_assoc_item ( & mut self , def_id : DefId ) {
1528
1540
let tcx = self . tcx ;
1541
+ let item = tcx. associated_item ( def_id) ;
1529
1542
1530
- let defaultness = tcx. defaultness ( def_id. expect_local ( ) ) ;
1531
- self . tables . defaultness . set_some ( def_id. index , defaultness) ;
1532
- let trait_item = tcx. associated_item ( def_id) ;
1533
- self . tables . assoc_container . set_some ( def_id. index , trait_item. container ) ;
1543
+ self . tables . defaultness . set_some ( def_id. index , item. defaultness ( tcx) ) ;
1544
+ self . tables . assoc_container . set_some ( def_id. index , item. container ) ;
1534
1545
1535
- match trait_item. kind {
1536
- ty:: AssocKind :: Const | ty:: AssocKind :: Fn => { }
1537
- ty:: AssocKind :: Type => {
1538
- self . encode_explicit_item_bounds ( def_id) ;
1546
+ match item. container {
1547
+ AssocItemContainer :: TraitContainer => {
1548
+ if let ty:: AssocKind :: Type = item. kind {
1549
+ self . encode_explicit_item_bounds ( def_id) ;
1550
+ }
1551
+ }
1552
+ AssocItemContainer :: ImplContainer => {
1553
+ if let Some ( trait_item_def_id) = item. trait_item_def_id {
1554
+ self . tables . trait_item_def_id . set_some ( def_id. index , trait_item_def_id. into ( ) ) ;
1555
+ }
1539
1556
}
1540
1557
}
1541
- if let Some ( rpitit_info) = trait_item. opt_rpitit_info {
1542
- let rpitit_info = self . lazy ( rpitit_info) ;
1543
- self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
1544
- }
1545
- }
1546
-
1547
- fn encode_info_for_impl_item ( & mut self , def_id : DefId ) {
1548
- debug ! ( "EncodeContext::encode_info_for_impl_item({:?})" , def_id) ;
1549
-
1550
- let defaultness = self . tcx . defaultness ( def_id. expect_local ( ) ) ;
1551
- self . tables . defaultness . set_some ( def_id. index , defaultness) ;
1552
- let impl_item = self . tcx . associated_item ( def_id) ;
1553
- self . tables . assoc_container . set_some ( def_id. index , impl_item. container ) ;
1554
-
1555
- if let Some ( trait_item_def_id) = impl_item. trait_item_def_id {
1556
- self . tables . trait_item_def_id . set_some ( def_id. index , trait_item_def_id. into ( ) ) ;
1557
- }
1558
- if let Some ( rpitit_info) = impl_item. opt_rpitit_info {
1559
- let rpitit_info = self . lazy ( rpitit_info) ;
1560
- self . tables . opt_rpitit_info . set_some ( def_id. index , rpitit_info) ;
1558
+ if let Some ( rpitit_info) = item. opt_rpitit_info {
1559
+ record ! ( self . tables. opt_rpitit_info[ def_id] <- rpitit_info) ;
1561
1560
}
1562
1561
}
1563
1562
@@ -1685,13 +1684,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1685
1684
let def_id = item. owner_id . to_def_id ( ) ;
1686
1685
debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
1687
1686
1688
- let record_associated_item_def_ids = |this : & mut Self , def_ids : & [ DefId ] | {
1689
- record_array ! ( this. tables. associated_item_or_field_def_ids[ def_id] <- def_ids. iter( ) . map( |& def_id| {
1690
- assert!( def_id. is_local( ) ) ;
1691
- def_id. index
1692
- } ) )
1693
- } ;
1694
-
1695
1687
match item. kind {
1696
1688
hir:: ItemKind :: Macro ( ref macro_def, _) => {
1697
1689
self . tables . is_macro_rules . set ( def_id. index , macro_def. macro_rules ) ;
@@ -1730,25 +1722,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
1730
1722
record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
1731
1723
}
1732
1724
}
1733
-
1734
- let associated_item_def_ids = self . tcx . associated_item_def_ids ( def_id) ;
1735
- record_associated_item_def_ids ( self , associated_item_def_ids) ;
1736
- for & trait_item_def_id in associated_item_def_ids {
1737
- self . encode_info_for_impl_item ( trait_item_def_id) ;
1738
- }
1739
1725
}
1740
1726
hir:: ItemKind :: Trait ( ..) => {
1741
1727
record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
1742
1728
1743
1729
let module_children = self . tcx . module_children_local ( item. owner_id . def_id ) ;
1744
1730
record_array ! ( self . tables. module_children_non_reexports[ def_id] <-
1745
1731
module_children. iter( ) . map( |child| child. res. def_id( ) . index) ) ;
1746
-
1747
- let associated_item_def_ids = self . tcx . associated_item_def_ids ( def_id) ;
1748
- record_associated_item_def_ids ( self , associated_item_def_ids) ;
1749
- for & item_def_id in associated_item_def_ids {
1750
- self . encode_info_for_trait_item ( item_def_id) ;
1751
- }
1752
1732
}
1753
1733
hir:: ItemKind :: TraitAlias ( ..) => {
1754
1734
record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
0 commit comments