@@ -247,30 +247,28 @@ pub(crate) fn clean_middle_const<'tcx>(
247247 }
248248}
249249
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 {
271260 None
272261 }
273262 }
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+ }
274272 }
275273}
276274
@@ -321,7 +319,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
321319 ty:: PredicateKind :: Trait ( pred) => {
322320 clean_poly_trait_predicate ( bound_predicate. rebind ( pred) , cx)
323321 }
324- ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred, cx ) ,
322+ ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
325323 ty:: PredicateKind :: TypeOutlives ( pred) => clean_type_outlives_predicate ( pred, cx) ,
326324 ty:: PredicateKind :: Projection ( pred) => Some ( clean_projection_predicate ( pred, cx) ) ,
327325 ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
@@ -358,7 +356,6 @@ fn clean_poly_trait_predicate<'tcx>(
358356
359357fn clean_region_outlives_predicate < ' tcx > (
360358 pred : ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > ,
361- cx : & mut DocContext < ' tcx > ,
362359) -> Option < WherePredicate > {
363360 let ty:: OutlivesPredicate ( a, b) = pred;
364361
@@ -367,8 +364,10 @@ fn clean_region_outlives_predicate<'tcx>(
367364 }
368365
369366 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+ ) ] ,
372371 } )
373372}
374373
@@ -384,7 +383,9 @@ fn clean_type_outlives_predicate<'tcx>(
384383
385384 Some ( WherePredicate :: BoundPredicate {
386385 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+ ) ] ,
388389 bound_params : Vec :: new ( ) ,
389390 } )
390391}
@@ -999,15 +1000,6 @@ impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> {
9991000 }
10001001}
10011002
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-
10111003impl < ' tcx > Clean < ' tcx , Path > for hir:: TraitRef < ' tcx > {
10121004 fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Path {
10131005 let path = clean_path ( self . path , cx) ;
@@ -1597,7 +1589,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
15971589 }
15981590 ty:: RawPtr ( mt) => RawPointer ( mt. mutbl , Box :: new ( clean_middle_ty ( mt. ty , cx, None ) ) ) ,
15991591 ty:: Ref ( r, ty, mutbl) => BorrowedRef {
1600- lifetime : r . clean ( cx ) ,
1592+ lifetime : clean_middle_region ( r ) ,
16011593 mutability : mutbl,
16021594 type_ : Box :: new ( clean_middle_ty ( ty, cx, None ) ) ,
16031595 } ,
@@ -1644,7 +1636,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
16441636
16451637 inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
16461638
1647- let lifetime = reg . clean ( cx ) ;
1639+ let lifetime = clean_middle_region ( * reg ) ;
16481640 let mut bounds = vec ! [ ] ;
16491641
16501642 for did in dids {
@@ -1710,7 +1702,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
17101702 let trait_ref = match bound_predicate. skip_binder ( ) {
17111703 ty:: PredicateKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
17121704 ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( _ty, reg) ) => {
1713- if let Some ( r) = reg . clean ( cx ) {
1705+ if let Some ( r) = clean_middle_region ( reg ) {
17141706 regions. push ( GenericBound :: Outlives ( r) ) ;
17151707 }
17161708 return None ;
0 commit comments