@@ -30,6 +30,7 @@ use rustc_target::spec::abi::Abi;
3030use rustc_typeck:: check:: intrinsic:: intrinsic_operation_unsafety;
3131use rustc_typeck:: hir_ty_to_ty;
3232
33+ use std:: assert_matches:: assert_matches;
3334use std:: collections:: hash_map:: Entry ;
3435use std:: default:: Default ;
3536use std:: hash:: Hash ;
@@ -199,9 +200,10 @@ impl Clean<GenericBound> for (ty::PolyTraitRef<'_>, &[TypeBinding]) {
199200 . collect_referenced_late_bound_regions ( & poly_trait_ref)
200201 . into_iter ( )
201202 . filter_map ( |br| match br {
202- ty:: BrNamed ( _, name) => {
203- Some ( GenericParamDef { name, kind : GenericParamDefKind :: Lifetime } )
204- }
203+ ty:: BrNamed ( _, name) => Some ( GenericParamDef {
204+ name,
205+ kind : GenericParamDefKind :: Lifetime { outlives : vec ! [ ] } ,
206+ } ) ,
205207 _ => None ,
206208 } )
207209 . collect ( ) ;
@@ -241,30 +243,6 @@ impl Clean<Lifetime> for hir::Lifetime {
241243 }
242244}
243245
244- impl Clean < Lifetime > for hir:: GenericParam < ' _ > {
245- fn clean ( & self , _: & mut DocContext < ' _ > ) -> Lifetime {
246- match self . kind {
247- hir:: GenericParamKind :: Lifetime { .. } => {
248- if !self . bounds . is_empty ( ) {
249- let mut bounds = self . bounds . iter ( ) . map ( |bound| match bound {
250- hir:: GenericBound :: Outlives ( lt) => lt,
251- _ => panic ! ( ) ,
252- } ) ;
253- let name = bounds. next ( ) . expect ( "no more bounds" ) . name . ident ( ) ;
254- let mut s = format ! ( "{}: {}" , self . name. ident( ) , name) ;
255- for bound in bounds {
256- s. push_str ( & format ! ( " + {}" , bound. name. ident( ) ) ) ;
257- }
258- Lifetime ( Symbol :: intern ( & s) )
259- } else {
260- Lifetime ( self . name . ident ( ) . name )
261- }
262- }
263- _ => panic ! ( ) ,
264- }
265- }
266- }
267-
268246impl Clean < Constant > for hir:: ConstArg {
269247 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Constant {
270248 Constant {
@@ -302,11 +280,30 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
302280impl Clean < WherePredicate > for hir:: WherePredicate < ' _ > {
303281 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> WherePredicate {
304282 match * self {
305- hir:: WherePredicate :: BoundPredicate ( ref wbp) => WherePredicate :: BoundPredicate {
306- ty : wbp. bounded_ty . clean ( cx) ,
307- bounds : wbp. bounds . clean ( cx) ,
308- bound_params : wbp. bound_generic_params . into_iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
309- } ,
283+ hir:: WherePredicate :: BoundPredicate ( ref wbp) => {
284+ let bound_params = wbp
285+ . bound_generic_params
286+ . into_iter ( )
287+ . map ( |param| {
288+ // Higher-ranked params must be lifetimes.
289+ // Higher-ranked lifetimes can't have bounds.
290+ assert_matches ! (
291+ param,
292+ hir:: GenericParam {
293+ kind: hir:: GenericParamKind :: Lifetime { .. } ,
294+ bounds: [ ] ,
295+ ..
296+ }
297+ ) ;
298+ Lifetime ( param. name . ident ( ) . name )
299+ } )
300+ . collect ( ) ;
301+ WherePredicate :: BoundPredicate {
302+ ty : wbp. bounded_ty . clean ( cx) ,
303+ bounds : wbp. bounds . clean ( cx) ,
304+ bound_params,
305+ }
306+ }
310307
311308 hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
312309 lifetime : wrp. lifetime . clean ( cx) ,
@@ -412,7 +409,9 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
412409impl Clean < GenericParamDef > for ty:: GenericParamDef {
413410 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericParamDef {
414411 let ( name, kind) = match self . kind {
415- ty:: GenericParamDefKind :: Lifetime => ( self . name , GenericParamDefKind :: Lifetime ) ,
412+ ty:: GenericParamDefKind :: Lifetime => {
413+ ( self . name , GenericParamDefKind :: Lifetime { outlives : vec ! [ ] } )
414+ }
416415 ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
417416 let default = if has_default {
418417 let mut default = cx. tcx . type_of ( self . def_id ) . clean ( cx) ;
@@ -462,21 +461,15 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
462461 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericParamDef {
463462 let ( name, kind) = match self . kind {
464463 hir:: GenericParamKind :: Lifetime { .. } => {
465- let name = if !self . bounds . is_empty ( ) {
466- let mut bounds = self . bounds . iter ( ) . map ( |bound| match bound {
467- hir:: GenericBound :: Outlives ( lt) => lt,
464+ let outlives = self
465+ . bounds
466+ . iter ( )
467+ . map ( |bound| match bound {
468+ hir:: GenericBound :: Outlives ( lt) => lt. clean ( cx) ,
468469 _ => panic ! ( ) ,
469- } ) ;
470- let name = bounds. next ( ) . expect ( "no more bounds" ) . name . ident ( ) ;
471- let mut s = format ! ( "{}: {}" , self . name. ident( ) , name) ;
472- for bound in bounds {
473- s. push_str ( & format ! ( " + {}" , bound. name. ident( ) ) ) ;
474- }
475- Symbol :: intern ( & s)
476- } else {
477- self . name . ident ( ) . name
478- } ;
479- ( name, GenericParamDefKind :: Lifetime )
470+ } )
471+ . collect ( ) ;
472+ ( self . name . ident ( ) . name , GenericParamDefKind :: Lifetime { outlives } )
480473 }
481474 hir:: GenericParamKind :: Type { ref default, synthetic } => (
482475 self . name . ident ( ) . name ,
@@ -536,7 +529,7 @@ impl Clean<Generics> for hir::Generics<'_> {
536529 . map ( |param| {
537530 let param: GenericParamDef = param. clean ( cx) ;
538531 match param. kind {
539- GenericParamDefKind :: Lifetime => unreachable ! ( ) ,
532+ GenericParamDefKind :: Lifetime { .. } => unreachable ! ( ) ,
540533 GenericParamDefKind :: Type { did, ref bounds, .. } => {
541534 cx. impl_trait_bounds . insert ( did. into ( ) , bounds. clone ( ) ) ;
542535 }
@@ -569,7 +562,7 @@ impl Clean<Generics> for hir::Generics<'_> {
569562 {
570563 for param in & mut generics. params {
571564 match param. kind {
572- GenericParamDefKind :: Lifetime => { }
565+ GenericParamDefKind :: Lifetime { .. } => { }
573566 GenericParamDefKind :: Type { bounds : ref mut ty_bounds, .. } => {
574567 if & param. name == name {
575568 mem:: swap ( bounds, ty_bounds) ;
0 commit comments