@@ -31,7 +31,7 @@ use rustc_middle::query::Providers;
3131use rustc_middle:: traits:: specialization_graph;
3232use rustc_middle:: ty:: codec:: TyEncoder ;
3333use 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 } ;
3535use rustc_middle:: util:: common:: to_readable_str;
3636use rustc_serialize:: { opaque, Decodable , Decoder , Encodable , Encoder } ;
3737use rustc_session:: config:: { CrateType , OptLevel } ;
@@ -1416,6 +1416,18 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14161416 if let DefKind :: Generator = def_kind {
14171417 self . encode_info_for_generator ( local_id) ;
14181418 }
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+ }
14191431 if let DefKind :: Enum | DefKind :: Struct | DefKind :: Union = def_kind {
14201432 self . encode_info_for_adt ( local_id) ;
14211433 }
@@ -1523,41 +1535,28 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15231535 record_defaulted_array ! ( self . tables. explicit_item_bounds[ def_id] <- bounds) ;
15241536 }
15251537
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 ) {
15281540 let tcx = self . tcx ;
1541+ let item = tcx. associated_item ( def_id) ;
15291542
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 ) ;
15341545
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+ }
15391556 }
15401557 }
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) ;
15611560 }
15621561 }
15631562
@@ -1685,13 +1684,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16851684 let def_id = item. owner_id . to_def_id ( ) ;
16861685 debug ! ( "EncodeContext::encode_info_for_item({:?})" , def_id) ;
16871686
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-
16951687 match item. kind {
16961688 hir:: ItemKind :: Macro ( ref macro_def, _) => {
16971689 self . tables . is_macro_rules . set ( def_id. index , macro_def. macro_rules ) ;
@@ -1730,25 +1722,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17301722 record ! ( self . tables. coerce_unsized_info[ def_id] <- coerce_unsized_info) ;
17311723 }
17321724 }
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- }
17391725 }
17401726 hir:: ItemKind :: Trait ( ..) => {
17411727 record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
17421728
17431729 let module_children = self . tcx . module_children_local ( item. owner_id . def_id ) ;
17441730 record_array ! ( self . tables. module_children_non_reexports[ def_id] <-
17451731 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- }
17521732 }
17531733 hir:: ItemKind :: TraitAlias ( ..) => {
17541734 record ! ( self . tables. trait_def[ def_id] <- self . tcx. trait_def( def_id) ) ;
0 commit comments