File tree 3 files changed +8
-3
lines changed
3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -671,7 +671,9 @@ impl<'a, 'tcx> CrateMetadata {
671
671
item_id : DefIndex ,
672
672
tcx : TyCtxt < ' tcx > ,
673
673
) -> & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
674
- self . root . per_def . inferred_outlives . get ( self , item_id) . unwrap ( ) . decode ( ( self , tcx) )
674
+ self . root . per_def . inferred_outlives . get ( self , item_id) . map ( |predicates| {
675
+ predicates. decode ( ( self , tcx) )
676
+ } ) . unwrap_or_default ( )
675
677
}
676
678
677
679
crate fn get_super_predicates (
Original file line number Diff line number Diff line change @@ -842,8 +842,10 @@ impl EncodeContext<'tcx> {
842
842
843
843
fn encode_inferred_outlives ( & mut self , def_id : DefId ) {
844
844
debug ! ( "EncodeContext::encode_inferred_outlives({:?})" , def_id) ;
845
- record ! ( self . per_def. inferred_outlives[ def_id] <-
846
- self . tcx. inferred_outlives_of( def_id) ) ;
845
+ let inferred_outlives = self . tcx . inferred_outlives_of ( def_id) ;
846
+ if !inferred_outlives. is_empty ( ) {
847
+ record ! ( self . per_def. inferred_outlives[ def_id] <- inferred_outlives) ;
848
+ }
847
849
}
848
850
849
851
fn encode_super_predicates ( & mut self , def_id : DefId ) {
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ crate struct LazyPerDefTables<'tcx> {
249
249
// doesn't handle shorthands in its own (de)serialization impls,
250
250
// as it's an `enum` for which we want to derive (de)serialization,
251
251
// so the `ty::codec` APIs handle the whole `&'tcx [...]` at once.
252
+ // Also, as an optimization, a missing entry indicates an empty `&[]`.
252
253
pub inferred_outlives : Lazy ! ( PerDefTable <Lazy !( & ' tcx [ ( ty:: Predicate <' tcx>, Span ) ] ) >) ,
253
254
pub super_predicates : Lazy ! ( PerDefTable <Lazy !( ty:: GenericPredicates <' tcx>) >) ,
254
255
You can’t perform that action at this time.
0 commit comments