@@ -130,7 +130,7 @@ impl<'tcx> Clean<'tcx, Attributes> for [ast::Attribute] {
130130impl < ' tcx > Clean < ' tcx , Option < GenericBound > > for hir:: GenericBound < ' tcx > {
131131 fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Option < GenericBound > {
132132 Some ( match * self {
133- hir:: GenericBound :: Outlives ( lt) => GenericBound :: Outlives ( lt . clean ( cx) ) ,
133+ hir:: GenericBound :: Outlives ( lt) => GenericBound :: Outlives ( clean_lifetime ( lt , cx) ) ,
134134 hir:: GenericBound :: LangItemTrait ( lang_item, span, _, generic_args) => {
135135 let def_id = cx. tcx . require_lang_item ( lang_item, Some ( span) ) ;
136136
@@ -214,21 +214,19 @@ impl<'tcx> Clean<'tcx, GenericBound> for ty::PolyTraitRef<'tcx> {
214214 }
215215}
216216
217- impl < ' tcx > Clean < ' tcx , Lifetime > for hir:: Lifetime {
218- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Lifetime {
219- let def = cx. tcx . named_region ( self . hir_id ) ;
220- if let Some (
221- rl:: Region :: EarlyBound ( _, node_id)
222- | rl:: Region :: LateBound ( _, _, node_id)
223- | rl:: Region :: Free ( _, node_id) ,
224- ) = def
225- {
226- if let Some ( lt) = cx. substs . get ( & node_id) . and_then ( |p| p. as_lt ( ) ) . cloned ( ) {
227- return lt;
228- }
217+ fn clean_lifetime < ' tcx > ( lifetime : hir:: Lifetime , cx : & mut DocContext < ' tcx > ) -> Lifetime {
218+ let def = cx. tcx . named_region ( lifetime. hir_id ) ;
219+ if let Some (
220+ rl:: Region :: EarlyBound ( _, node_id)
221+ | rl:: Region :: LateBound ( _, _, node_id)
222+ | rl:: Region :: Free ( _, node_id) ,
223+ ) = def
224+ {
225+ if let Some ( lt) = cx. substs . get ( & node_id) . and_then ( |p| p. as_lt ( ) ) . cloned ( ) {
226+ return lt;
229227 }
230- Lifetime ( self . name . ident ( ) . name )
231228 }
229+ Lifetime ( lifetime. name . ident ( ) . name )
232230}
233231
234232pub ( crate ) fn clean_const < ' tcx > ( constant : & hir:: ConstArg , cx : & mut DocContext < ' tcx > ) -> Constant {
@@ -305,7 +303,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for hir::WherePredicate<'tcx> {
305303 }
306304
307305 hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
308- lifetime : wrp. lifetime . clean ( cx) ,
306+ lifetime : clean_lifetime ( wrp. lifetime , cx) ,
309307 bounds : wrp. bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
310308 } ,
311309
@@ -518,7 +516,7 @@ fn clean_generic_param<'tcx>(
518516 . filter ( |bp| !bp. in_where_clause )
519517 . flat_map ( |bp| bp. bounds )
520518 . map ( |bound| match bound {
521- hir:: GenericBound :: Outlives ( lt) => lt . clean ( cx) ,
519+ hir:: GenericBound :: Outlives ( lt) => clean_lifetime ( * lt , cx) ,
522520 _ => panic ! ( ) ,
523521 } )
524522 . collect ( )
@@ -1425,7 +1423,8 @@ fn maybe_expand_private_type_alias<'tcx>(
14251423 } ) ;
14261424 if let Some ( lt) = lifetime. cloned ( ) {
14271425 let lt_def_id = cx. tcx . hir ( ) . local_def_id ( param. hir_id ) ;
1428- let cleaned = if !lt. is_elided ( ) { lt. clean ( cx) } else { Lifetime :: elided ( ) } ;
1426+ let cleaned =
1427+ if !lt. is_elided ( ) { clean_lifetime ( lt, cx) } else { Lifetime :: elided ( ) } ;
14291428 substs. insert ( lt_def_id. to_def_id ( ) , SubstParam :: Lifetime ( cleaned) ) ;
14301429 }
14311430 indices. lifetimes += 1 ;
@@ -1497,7 +1496,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
14971496 // there's no case where it could cause the function to fail to compile.
14981497 let elided =
14991498 l. is_elided ( ) || matches ! ( l. name, LifetimeName :: Param ( _, ParamName :: Fresh ) ) ;
1500- let lifetime = if elided { None } else { Some ( l . clean ( cx) ) } ;
1499+ let lifetime = if elided { None } else { Some ( clean_lifetime ( * l , cx) ) } ;
15011500 BorrowedRef { lifetime, mutability : m. mutbl , type_ : Box :: new ( clean_ty ( m. ty , cx) ) }
15021501 }
15031502 TyKind :: Slice ( ty) => Slice ( Box :: new ( clean_ty ( ty, cx) ) ) ,
@@ -1533,7 +1532,8 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
15331532 TyKind :: Path ( _) => clean_qpath ( ty, cx) ,
15341533 TyKind :: TraitObject ( bounds, ref lifetime, _) => {
15351534 let bounds = bounds. iter ( ) . map ( |bound| bound. clean ( cx) ) . collect ( ) ;
1536- let lifetime = if !lifetime. is_elided ( ) { Some ( lifetime. clean ( cx) ) } else { None } ;
1535+ let lifetime =
1536+ if !lifetime. is_elided ( ) { Some ( clean_lifetime ( * lifetime, cx) ) } else { None } ;
15371537 DynTrait ( bounds, lifetime)
15381538 }
15391539 TyKind :: BareFn ( barefn) => BareFunction ( Box :: new ( barefn. clean ( cx) ) ) ,
@@ -1871,7 +1871,7 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> {
18711871 . iter ( )
18721872 . map ( |arg| match arg {
18731873 hir:: GenericArg :: Lifetime ( lt) if !lt. is_elided ( ) => {
1874- GenericArg :: Lifetime ( lt . clean ( cx) )
1874+ GenericArg :: Lifetime ( clean_lifetime ( * lt , cx) )
18751875 }
18761876 hir:: GenericArg :: Lifetime ( _) => GenericArg :: Lifetime ( Lifetime :: elided ( ) ) ,
18771877 hir:: GenericArg :: Type ( ty) => GenericArg :: Type ( clean_ty ( ty, cx) ) ,
0 commit comments