@@ -242,30 +242,28 @@ pub(crate) fn clean_middle_const<'tcx>(
242242 }
243243}
244244
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 {
266255 None
267256 }
268257 }
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+ }
269267 }
270268}
271269
@@ -316,7 +314,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
316314 ty:: PredicateKind :: Trait ( pred) => {
317315 clean_poly_trait_predicate ( bound_predicate. rebind ( pred) , cx)
318316 }
319- ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred, cx ) ,
317+ ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
320318 ty:: PredicateKind :: TypeOutlives ( pred) => clean_type_outlives_predicate ( pred, cx) ,
321319 ty:: PredicateKind :: Projection ( pred) => Some ( clean_projection_predicate ( pred, cx) ) ,
322320 ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
@@ -353,7 +351,6 @@ fn clean_poly_trait_predicate<'tcx>(
353351
354352fn clean_region_outlives_predicate < ' tcx > (
355353 pred : ty:: OutlivesPredicate < ty:: Region < ' tcx > , ty:: Region < ' tcx > > ,
356- cx : & mut DocContext < ' tcx > ,
357354) -> Option < WherePredicate > {
358355 let ty:: OutlivesPredicate ( a, b) = pred;
359356
@@ -362,8 +359,10 @@ fn clean_region_outlives_predicate<'tcx>(
362359 }
363360
364361 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+ ) ] ,
367366 } )
368367}
369368
@@ -379,7 +378,9 @@ fn clean_type_outlives_predicate<'tcx>(
379378
380379 Some ( WherePredicate :: BoundPredicate {
381380 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+ ) ] ,
383384 bound_params : Vec :: new ( ) ,
384385 } )
385386}
@@ -1592,7 +1593,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
15921593 }
15931594 ty:: RawPtr ( mt) => RawPointer ( mt. mutbl , Box :: new ( clean_middle_ty ( mt. ty , cx, None ) ) ) ,
15941595 ty:: Ref ( r, ty, mutbl) => BorrowedRef {
1595- lifetime : r . clean ( cx ) ,
1596+ lifetime : clean_middle_region ( r ) ,
15961597 mutability : mutbl,
15971598 type_ : Box :: new ( clean_middle_ty ( ty, cx, None ) ) ,
15981599 } ,
@@ -1639,7 +1640,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
16391640
16401641 inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
16411642
1642- let lifetime = reg . clean ( cx ) ;
1643+ let lifetime = clean_middle_region ( * reg ) ;
16431644 let mut bounds = vec ! [ ] ;
16441645
16451646 for did in dids {
@@ -1705,7 +1706,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
17051706 let trait_ref = match bound_predicate. skip_binder ( ) {
17061707 ty:: PredicateKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
17071708 ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( _ty, reg) ) => {
1708- if let Some ( r) = reg . clean ( cx ) {
1709+ if let Some ( r) = clean_middle_region ( reg ) {
17091710 regions. push ( GenericBound :: Outlives ( r) ) ;
17101711 }
17111712 return None ;
0 commit comments