@@ -30,6 +30,7 @@ use rustc_target::spec::abi::Abi;
30
30
use rustc_typeck:: check:: intrinsic:: intrinsic_operation_unsafety;
31
31
use rustc_typeck:: hir_ty_to_ty;
32
32
33
+ use std:: assert_matches:: assert_matches;
33
34
use std:: collections:: hash_map:: Entry ;
34
35
use std:: default:: Default ;
35
36
use std:: hash:: Hash ;
@@ -199,9 +200,10 @@ impl Clean<GenericBound> for (ty::PolyTraitRef<'_>, &[TypeBinding]) {
199
200
. collect_referenced_late_bound_regions ( & poly_trait_ref)
200
201
. into_iter ( )
201
202
. 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
+ } ) ,
205
207
_ => None ,
206
208
} )
207
209
. collect ( ) ;
@@ -241,30 +243,6 @@ impl Clean<Lifetime> for hir::Lifetime {
241
243
}
242
244
}
243
245
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
-
268
246
impl Clean < Constant > for hir:: ConstArg {
269
247
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Constant {
270
248
Constant {
@@ -302,11 +280,30 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
302
280
impl Clean < WherePredicate > for hir:: WherePredicate < ' _ > {
303
281
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> WherePredicate {
304
282
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
+ }
310
307
311
308
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
312
309
lifetime : wrp. lifetime . clean ( cx) ,
@@ -412,7 +409,9 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
412
409
impl Clean < GenericParamDef > for ty:: GenericParamDef {
413
410
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericParamDef {
414
411
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
+ }
416
415
ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
417
416
let default = if has_default {
418
417
let mut default = cx. tcx . type_of ( self . def_id ) . clean ( cx) ;
@@ -462,21 +461,15 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
462
461
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericParamDef {
463
462
let ( name, kind) = match self . kind {
464
463
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) ,
468
469
_ => 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 } )
480
473
}
481
474
hir:: GenericParamKind :: Type { ref default, synthetic } => (
482
475
self . name . ident ( ) . name ,
@@ -536,7 +529,7 @@ impl Clean<Generics> for hir::Generics<'_> {
536
529
. map ( |param| {
537
530
let param: GenericParamDef = param. clean ( cx) ;
538
531
match param. kind {
539
- GenericParamDefKind :: Lifetime => unreachable ! ( ) ,
532
+ GenericParamDefKind :: Lifetime { .. } => unreachable ! ( ) ,
540
533
GenericParamDefKind :: Type { did, ref bounds, .. } => {
541
534
cx. impl_trait_bounds . insert ( did. into ( ) , bounds. clone ( ) ) ;
542
535
}
@@ -569,7 +562,7 @@ impl Clean<Generics> for hir::Generics<'_> {
569
562
{
570
563
for param in & mut generics. params {
571
564
match param. kind {
572
- GenericParamDefKind :: Lifetime => { }
565
+ GenericParamDefKind :: Lifetime { .. } => { }
573
566
GenericParamDefKind :: Type { bounds : ref mut ty_bounds, .. } => {
574
567
if & param. name == name {
575
568
mem:: swap ( bounds, ty_bounds) ;
0 commit comments