@@ -1270,7 +1270,10 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
12701270 ty:: RePlaceholder ( ..) |
12711271 ty:: ReEmpty |
12721272 ty:: ReClosureBound ( _) |
1273- ty:: ReErased => None
1273+ ty:: ReErased => {
1274+ debug ! ( "Cannot clean region {:?}" , self ) ;
1275+ None
1276+ }
12741277 }
12751278 }
12761279}
@@ -1309,16 +1312,16 @@ impl Clean<WherePredicate> for hir::WherePredicate {
13091312 }
13101313}
13111314
1312- impl < ' a > Clean < WherePredicate > for ty:: Predicate < ' a > {
1313- fn clean ( & self , cx : & DocContext ) -> WherePredicate {
1315+ impl < ' a > Clean < Option < WherePredicate > > for ty:: Predicate < ' a > {
1316+ fn clean ( & self , cx : & DocContext ) -> Option < WherePredicate > {
13141317 use rustc:: ty:: Predicate ;
13151318
13161319 match * self {
1317- Predicate :: Trait ( ref pred) => pred. clean ( cx) ,
1318- Predicate :: Subtype ( ref pred) => pred. clean ( cx) ,
1320+ Predicate :: Trait ( ref pred) => Some ( pred. clean ( cx) ) ,
1321+ Predicate :: Subtype ( ref pred) => Some ( pred. clean ( cx) ) ,
13191322 Predicate :: RegionOutlives ( ref pred) => pred. clean ( cx) ,
13201323 Predicate :: TypeOutlives ( ref pred) => pred. clean ( cx) ,
1321- Predicate :: Projection ( ref pred) => pred. clean ( cx) ,
1324+ Predicate :: Projection ( ref pred) => Some ( pred. clean ( cx) ) ,
13221325
13231326 Predicate :: WellFormed ( ..) |
13241327 Predicate :: ObjectSafe ( ..) |
@@ -1344,24 +1347,39 @@ impl<'tcx> Clean<WherePredicate> for ty::SubtypePredicate<'tcx> {
13441347 }
13451348}
13461349
1347- impl < ' tcx > Clean < WherePredicate > for ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > {
1348- fn clean ( & self , cx : & DocContext ) -> WherePredicate {
1350+ impl < ' tcx > Clean < Option < WherePredicate > > for
1351+ ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > {
1352+
1353+ fn clean ( & self , cx : & DocContext ) -> Option < WherePredicate > {
13491354 let ty:: OutlivesPredicate ( ref a, ref b) = * self ;
1350- WherePredicate :: RegionPredicate {
1355+
1356+ match ( a, b) {
1357+ ( ty:: ReEmpty , ty:: ReEmpty ) => {
1358+ return None ;
1359+ } ,
1360+ _ => { }
1361+ }
1362+
1363+ Some ( WherePredicate :: RegionPredicate {
13511364 lifetime : a. clean ( cx) . expect ( "failed to clean lifetime" ) ,
13521365 bounds : vec ! [ GenericBound :: Outlives ( b. clean( cx) . expect( "failed to clean bounds" ) ) ]
1353- }
1366+ } )
13541367 }
13551368}
13561369
1357- impl < ' tcx > Clean < WherePredicate > for ty:: OutlivesPredicate < Ty < ' tcx > , ty:: Region < ' tcx > > {
1358- fn clean ( & self , cx : & DocContext ) -> WherePredicate {
1370+ impl < ' tcx > Clean < Option < WherePredicate > > for ty:: OutlivesPredicate < Ty < ' tcx > , ty:: Region < ' tcx > > {
1371+ fn clean ( & self , cx : & DocContext ) -> Option < WherePredicate > {
13591372 let ty:: OutlivesPredicate ( ref ty, ref lt) = * self ;
13601373
1361- WherePredicate :: BoundPredicate {
1374+ match lt {
1375+ ty:: ReEmpty => return None ,
1376+ _ => { }
1377+ }
1378+
1379+ Some ( WherePredicate :: BoundPredicate {
13621380 ty : ty. clean ( cx) ,
13631381 bounds : vec ! [ GenericBound :: Outlives ( lt. clean( cx) . expect( "failed to clean lifetimes" ) ) ]
1364- }
1382+ } )
13651383 }
13661384}
13671385
@@ -1578,7 +1596,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
15781596 } ) . collect :: < Vec < GenericParamDef > > ( ) ;
15791597
15801598 let mut where_predicates = preds. predicates . iter ( )
1581- . map ( |( p, _) | p. clean ( cx) )
1599+ . flat_map ( |( p, _) | p. clean ( cx) )
15821600 . collect :: < Vec < _ > > ( ) ;
15831601
15841602 // Type parameters and have a Sized bound by default unless removed with
0 commit comments