@@ -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 ;
@@ -242,30 +243,6 @@ impl Clean<Lifetime> for hir::Lifetime {
242
243
}
243
244
}
244
245
245
- impl Clean < Lifetime > for hir:: GenericParam < ' _ > {
246
- fn clean ( & self , _: & mut DocContext < ' _ > ) -> Lifetime {
247
- match self . kind {
248
- hir:: GenericParamKind :: Lifetime { .. } => {
249
- if !self . bounds . is_empty ( ) {
250
- let mut bounds = self . bounds . iter ( ) . map ( |bound| match bound {
251
- hir:: GenericBound :: Outlives ( lt) => lt,
252
- _ => panic ! ( ) ,
253
- } ) ;
254
- let name = bounds. next ( ) . expect ( "no more bounds" ) . name . ident ( ) ;
255
- let mut s = format ! ( "{}: {}" , self . name. ident( ) , name) ;
256
- for bound in bounds {
257
- s. push_str ( & format ! ( " + {}" , bound. name. ident( ) ) ) ;
258
- }
259
- Lifetime ( Symbol :: intern ( & s) )
260
- } else {
261
- Lifetime ( self . name . ident ( ) . name )
262
- }
263
- }
264
- _ => panic ! ( ) ,
265
- }
266
- }
267
- }
268
-
269
246
impl Clean < Constant > for hir:: ConstArg {
270
247
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Constant {
271
248
Constant {
@@ -303,11 +280,30 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
303
280
impl Clean < WherePredicate > for hir:: WherePredicate < ' _ > {
304
281
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> WherePredicate {
305
282
match * self {
306
- hir:: WherePredicate :: BoundPredicate ( ref wbp) => WherePredicate :: BoundPredicate {
307
- ty : wbp. bounded_ty . clean ( cx) ,
308
- bounds : wbp. bounds . clean ( cx) ,
309
- bound_params : wbp. bound_generic_params . into_iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
310
- } ,
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
+ }
311
307
312
308
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
313
309
lifetime : wrp. lifetime . clean ( cx) ,
0 commit comments