File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
compiler/rustc_metadata/src/rmeta Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -919,7 +919,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
919919 item_id : DefIndex ,
920920 tcx : TyCtxt < ' tcx > ,
921921 ) -> ty:: GenericPredicates < ' tcx > {
922- self . root . tables . explicit_predicates . get ( self , item_id) . unwrap ( ) . decode ( ( self , tcx) )
922+ self . root
923+ . tables
924+ . explicit_predicates
925+ . get ( self , item_id)
926+ . map ( |e| e. decode ( ( self , tcx) ) )
927+ . unwrap_or_default ( )
923928 }
924929
925930 fn get_inferred_outlives (
Original file line number Diff line number Diff line change @@ -992,7 +992,12 @@ impl EncodeContext<'a, 'tcx> {
992992 if should_encode_generics ( def_kind) {
993993 let g = tcx. generics_of ( def_id) ;
994994 record ! ( self . tables. generics[ def_id] <- g) ;
995- record ! ( self . tables. explicit_predicates[ def_id] <- self . tcx. explicit_predicates_of( def_id) ) ;
995+ let predicates = self . tcx . explicit_predicates_of ( def_id) ;
996+ if let ty:: GenericPredicates { parent : None , predicates : & [ ] } = predicates {
997+ // do nothing -- missing entry indicates empty predicates
998+ } else {
999+ record ! ( self . tables. explicit_predicates[ def_id] <- predicates) ;
1000+ }
9961001 let inferred_outlives = self . tcx . inferred_outlives_of ( def_id) ;
9971002 if !inferred_outlives. is_empty ( ) {
9981003 record ! ( self . tables. inferred_outlives[ def_id] <- inferred_outlives) ;
Original file line number Diff line number Diff line change @@ -301,6 +301,7 @@ define_tables! {
301301 inherent_impls: Table <DefIndex , Lazy <[ DefIndex ] >>,
302302 variances: Table <DefIndex , Lazy <[ ty:: Variance ] >>,
303303 generics: Table <DefIndex , Lazy <ty:: Generics >>,
304+ // Empty entry indicates default predicates -- quite common in practice.
304305 explicit_predicates: Table <DefIndex , Lazy !( ty:: GenericPredicates <' tcx>) >,
305306 expn_that_defined: Table <DefIndex , Lazy <ExpnId >>,
306307 // As an optimization, a missing entry indicates an empty `&[]`.
You can’t perform that action at this time.
0 commit comments