@@ -242,30 +242,28 @@ pub(crate) fn clean_middle_const<'tcx>(
242
242
}
243
243
}
244
244
245
- impl < ' tcx > Clean < ' tcx , Option < Lifetime > > for ty:: Region < ' tcx > {
246
- fn clean ( & self , _cx : & mut DocContext < ' _ > ) -> Option < Lifetime > {
247
- match * * self {
248
- ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
249
- ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrNamed ( _, name) , .. } ) => {
250
- if name != kw:: UnderscoreLifetime { Some ( Lifetime ( name) ) } else { None }
251
- }
252
- ty:: ReEarlyBound ( ref data) => {
253
- if data. name != kw:: UnderscoreLifetime {
254
- Some ( Lifetime ( data. name ) )
255
- } else {
256
- None
257
- }
258
- }
259
- ty:: ReLateBound ( ..)
260
- | ty:: ReFree ( ..)
261
- | ty:: ReVar ( ..)
262
- | ty:: RePlaceholder ( ..)
263
- | ty:: ReEmpty ( _)
264
- | ty:: ReErased => {
265
- debug ! ( "cannot clean region {:?}" , self ) ;
245
+ pub ( crate ) fn clean_middle_region < ' tcx > ( region : ty:: Region < ' tcx > ) -> Option < Lifetime > {
246
+ match * region {
247
+ ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
248
+ ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrNamed ( _, name) , .. } ) => {
249
+ if name != kw:: UnderscoreLifetime { Some ( Lifetime ( name) ) } else { None }
250
+ }
251
+ ty:: ReEarlyBound ( ref data) => {
252
+ if data. name != kw:: UnderscoreLifetime {
253
+ Some ( Lifetime ( data. name ) )
254
+ } else {
266
255
None
267
256
}
268
257
}
258
+ ty:: ReLateBound ( ..)
259
+ | ty:: ReFree ( ..)
260
+ | ty:: ReVar ( ..)
261
+ | ty:: RePlaceholder ( ..)
262
+ | ty:: ReEmpty ( _)
263
+ | ty:: ReErased => {
264
+ debug ! ( "cannot clean region {:?}" , region) ;
265
+ None
266
+ }
269
267
}
270
268
}
271
269
@@ -316,7 +314,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
316
314
ty:: PredicateKind :: Trait ( pred) => {
317
315
clean_poly_trait_predicate ( bound_predicate. rebind ( pred) , cx)
318
316
}
319
- ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred, cx ) ,
317
+ ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
320
318
ty:: PredicateKind :: TypeOutlives ( pred) => clean_type_outlives_predicate ( pred, cx) ,
321
319
ty:: PredicateKind :: Projection ( pred) => Some ( clean_projection_predicate ( pred, cx) ) ,
322
320
ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
@@ -353,7 +351,6 @@ fn clean_poly_trait_predicate<'tcx>(
353
351
354
352
fn clean_region_outlives_predicate < ' tcx > (
355
353
pred : ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > ,
356
- cx : & mut DocContext < ' tcx > ,
357
354
) -> Option < WherePredicate > {
358
355
let ty:: OutlivesPredicate ( a, b) = pred;
359
356
@@ -362,8 +359,10 @@ fn clean_region_outlives_predicate<'tcx>(
362
359
}
363
360
364
361
Some ( WherePredicate :: RegionPredicate {
365
- lifetime : a. clean ( cx) . expect ( "failed to clean lifetime" ) ,
366
- bounds : vec ! [ GenericBound :: Outlives ( b. clean( cx) . expect( "failed to clean bounds" ) ) ] ,
362
+ lifetime : clean_middle_region ( a) . expect ( "failed to clean lifetime" ) ,
363
+ bounds : vec ! [ GenericBound :: Outlives (
364
+ clean_middle_region( b) . expect( "failed to clean bounds" ) ,
365
+ ) ] ,
367
366
} )
368
367
}
369
368
@@ -379,7 +378,9 @@ fn clean_type_outlives_predicate<'tcx>(
379
378
380
379
Some ( WherePredicate :: BoundPredicate {
381
380
ty : clean_middle_ty ( ty, cx, None ) ,
382
- bounds : vec ! [ GenericBound :: Outlives ( lt. clean( cx) . expect( "failed to clean lifetimes" ) ) ] ,
381
+ bounds : vec ! [ GenericBound :: Outlives (
382
+ clean_middle_region( lt) . expect( "failed to clean lifetimes" ) ,
383
+ ) ] ,
383
384
bound_params : Vec :: new ( ) ,
384
385
} )
385
386
}
@@ -1592,7 +1593,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1592
1593
}
1593
1594
ty:: RawPtr ( mt) => RawPointer ( mt. mutbl , Box :: new ( clean_middle_ty ( mt. ty , cx, None ) ) ) ,
1594
1595
ty:: Ref ( r, ty, mutbl) => BorrowedRef {
1595
- lifetime : r . clean ( cx ) ,
1596
+ lifetime : clean_middle_region ( r ) ,
1596
1597
mutability : mutbl,
1597
1598
type_ : Box :: new ( clean_middle_ty ( ty, cx, None ) ) ,
1598
1599
} ,
@@ -1639,7 +1640,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1639
1640
1640
1641
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1641
1642
1642
- let lifetime = reg . clean ( cx ) ;
1643
+ let lifetime = clean_middle_region ( * reg ) ;
1643
1644
let mut bounds = vec ! [ ] ;
1644
1645
1645
1646
for did in dids {
@@ -1705,7 +1706,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1705
1706
let trait_ref = match bound_predicate. skip_binder ( ) {
1706
1707
ty:: PredicateKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
1707
1708
ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( _ty, reg) ) => {
1708
- if let Some ( r) = reg . clean ( cx ) {
1709
+ if let Some ( r) = clean_middle_region ( reg ) {
1709
1710
regions. push ( GenericBound :: Outlives ( r) ) ;
1710
1711
}
1711
1712
return None ;
0 commit comments