@@ -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 ;
@@ -242,30 +243,6 @@ impl Clean<Lifetime> for hir::Lifetime {
242243 }
243244}
244245
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-
269246impl Clean < Constant > for hir:: ConstArg {
270247 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Constant {
271248 Constant {
@@ -303,11 +280,30 @@ impl Clean<Option<Lifetime>> for ty::RegionKind {
303280impl Clean < WherePredicate > for hir:: WherePredicate < ' _ > {
304281 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> WherePredicate {
305282 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+ }
311307
312308 hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
313309 lifetime : wrp. lifetime . clean ( cx) ,
0 commit comments