@@ -247,30 +247,28 @@ pub(crate) fn clean_middle_const<'tcx>(
247
247
}
248
248
}
249
249
250
- impl < ' tcx > Clean < ' tcx , Option < Lifetime > > for ty:: Region < ' tcx > {
251
- fn clean ( & self , _cx : & mut DocContext < ' _ > ) -> Option < Lifetime > {
252
- match * * self {
253
- ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
254
- ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrNamed ( _, name) , .. } ) => {
255
- if name != kw:: UnderscoreLifetime { Some ( Lifetime ( name) ) } else { None }
256
- }
257
- ty:: ReEarlyBound ( ref data) => {
258
- if data. name != kw:: UnderscoreLifetime {
259
- Some ( Lifetime ( data. name ) )
260
- } else {
261
- None
262
- }
263
- }
264
- ty:: ReLateBound ( ..)
265
- | ty:: ReFree ( ..)
266
- | ty:: ReVar ( ..)
267
- | ty:: RePlaceholder ( ..)
268
- | ty:: ReEmpty ( _)
269
- | ty:: ReErased => {
270
- debug ! ( "cannot clean region {:?}" , self ) ;
250
+ pub ( crate ) fn clean_middle_region < ' tcx > ( region : ty:: Region < ' tcx > ) -> Option < Lifetime > {
251
+ match * region {
252
+ ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
253
+ ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrNamed ( _, name) , .. } ) => {
254
+ if name != kw:: UnderscoreLifetime { Some ( Lifetime ( name) ) } else { None }
255
+ }
256
+ ty:: ReEarlyBound ( ref data) => {
257
+ if data. name != kw:: UnderscoreLifetime {
258
+ Some ( Lifetime ( data. name ) )
259
+ } else {
271
260
None
272
261
}
273
262
}
263
+ ty:: ReLateBound ( ..)
264
+ | ty:: ReFree ( ..)
265
+ | ty:: ReVar ( ..)
266
+ | ty:: RePlaceholder ( ..)
267
+ | ty:: ReEmpty ( _)
268
+ | ty:: ReErased => {
269
+ debug ! ( "cannot clean region {:?}" , region) ;
270
+ None
271
+ }
274
272
}
275
273
}
276
274
@@ -321,7 +319,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
321
319
ty:: PredicateKind :: Trait ( pred) => {
322
320
clean_poly_trait_predicate ( bound_predicate. rebind ( pred) , cx)
323
321
}
324
- ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred, cx ) ,
322
+ ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
325
323
ty:: PredicateKind :: TypeOutlives ( pred) => clean_type_outlives_predicate ( pred, cx) ,
326
324
ty:: PredicateKind :: Projection ( pred) => Some ( clean_projection_predicate ( pred, cx) ) ,
327
325
ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
@@ -358,7 +356,6 @@ fn clean_poly_trait_predicate<'tcx>(
358
356
359
357
fn clean_region_outlives_predicate < ' tcx > (
360
358
pred : ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > ,
361
- cx : & mut DocContext < ' tcx > ,
362
359
) -> Option < WherePredicate > {
363
360
let ty:: OutlivesPredicate ( a, b) = pred;
364
361
@@ -367,8 +364,10 @@ fn clean_region_outlives_predicate<'tcx>(
367
364
}
368
365
369
366
Some ( WherePredicate :: RegionPredicate {
370
- lifetime : a. clean ( cx) . expect ( "failed to clean lifetime" ) ,
371
- bounds : vec ! [ GenericBound :: Outlives ( b. clean( cx) . expect( "failed to clean bounds" ) ) ] ,
367
+ lifetime : clean_middle_region ( a) . expect ( "failed to clean lifetime" ) ,
368
+ bounds : vec ! [ GenericBound :: Outlives (
369
+ clean_middle_region( b) . expect( "failed to clean bounds" ) ,
370
+ ) ] ,
372
371
} )
373
372
}
374
373
@@ -384,7 +383,9 @@ fn clean_type_outlives_predicate<'tcx>(
384
383
385
384
Some ( WherePredicate :: BoundPredicate {
386
385
ty : clean_middle_ty ( ty, cx, None ) ,
387
- bounds : vec ! [ GenericBound :: Outlives ( lt. clean( cx) . expect( "failed to clean lifetimes" ) ) ] ,
386
+ bounds : vec ! [ GenericBound :: Outlives (
387
+ clean_middle_region( lt) . expect( "failed to clean lifetimes" ) ,
388
+ ) ] ,
388
389
bound_params : Vec :: new ( ) ,
389
390
} )
390
391
}
@@ -999,15 +1000,6 @@ impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> {
999
1000
}
1000
1001
}
1001
1002
1002
- impl < ' tcx > Clean < ' tcx , bool > for hir:: IsAuto {
1003
- fn clean ( & self , _: & mut DocContext < ' tcx > ) -> bool {
1004
- match * self {
1005
- hir:: IsAuto :: Yes => true ,
1006
- hir:: IsAuto :: No => false ,
1007
- }
1008
- }
1009
- }
1010
-
1011
1003
impl < ' tcx > Clean < ' tcx , Path > for hir:: TraitRef < ' tcx > {
1012
1004
fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Path {
1013
1005
let path = clean_path ( self . path , cx) ;
@@ -1597,7 +1589,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1597
1589
}
1598
1590
ty:: RawPtr ( mt) => RawPointer ( mt. mutbl , Box :: new ( clean_middle_ty ( mt. ty , cx, None ) ) ) ,
1599
1591
ty:: Ref ( r, ty, mutbl) => BorrowedRef {
1600
- lifetime : r . clean ( cx ) ,
1592
+ lifetime : clean_middle_region ( r ) ,
1601
1593
mutability : mutbl,
1602
1594
type_ : Box :: new ( clean_middle_ty ( ty, cx, None ) ) ,
1603
1595
} ,
@@ -1644,7 +1636,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1644
1636
1645
1637
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1646
1638
1647
- let lifetime = reg . clean ( cx ) ;
1639
+ let lifetime = clean_middle_region ( * reg ) ;
1648
1640
let mut bounds = vec ! [ ] ;
1649
1641
1650
1642
for did in dids {
@@ -1710,7 +1702,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1710
1702
let trait_ref = match bound_predicate. skip_binder ( ) {
1711
1703
ty:: PredicateKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
1712
1704
ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( _ty, reg) ) => {
1713
- if let Some ( r) = reg . clean ( cx ) {
1705
+ if let Some ( r) = clean_middle_region ( reg ) {
1714
1706
regions. push ( GenericBound :: Outlives ( r) ) ;
1715
1707
}
1716
1708
return None ;
0 commit comments