@@ -126,40 +126,40 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> {
126126    } 
127127} 
128128
129- impl < ' tcx >  Clean < ' tcx ,  Option < GenericBound > >  for  hir:: GenericBound < ' tcx >  { 
130-     fn  clean ( & self ,  cx :  & mut  DocContext < ' tcx > )  -> Option < GenericBound >  { 
131-         Some ( match  * self  { 
132-             hir:: GenericBound :: Outlives ( lt)  => GenericBound :: Outlives ( clean_lifetime ( lt,  cx) ) , 
133-             hir:: GenericBound :: LangItemTrait ( lang_item,  span,  _,  generic_args)  => { 
134-                 let  def_id = cx. tcx . require_lang_item ( lang_item,  Some ( span) ) ; 
135- 
136-                 let  trait_ref = ty:: TraitRef :: identity ( cx. tcx ,  def_id) . skip_binder ( ) ; 
137- 
138-                 let  generic_args = generic_args. clean ( cx) ; 
139-                 let  GenericArgs :: AngleBracketed  {  bindings,  .. }  = generic_args
140-                 else  { 
141-                     bug ! ( "clean: parenthesized `GenericBound::LangItemTrait`" ) ; 
142-                 } ; 
129+ fn  clean_generic_bound < ' tcx > ( 
130+     bound :  & hir:: GenericBound < ' tcx > , 
131+     cx :  & mut  DocContext < ' tcx > , 
132+ )  -> Option < GenericBound >  { 
133+     Some ( match  * bound { 
134+         hir:: GenericBound :: Outlives ( lt)  => GenericBound :: Outlives ( clean_lifetime ( lt,  cx) ) , 
135+         hir:: GenericBound :: LangItemTrait ( lang_item,  span,  _,  generic_args)  => { 
136+             let  def_id = cx. tcx . require_lang_item ( lang_item,  Some ( span) ) ; 
137+ 
138+             let  trait_ref = ty:: TraitRef :: identity ( cx. tcx ,  def_id) . skip_binder ( ) ; 
139+ 
140+             let  generic_args = generic_args. clean ( cx) ; 
141+             let  GenericArgs :: AngleBracketed  {  bindings,  .. }  = generic_args
142+             else  { 
143+                 bug ! ( "clean: parenthesized `GenericBound::LangItemTrait`" ) ; 
144+             } ; 
143145
144-                 let  trait_ = clean_trait_ref_with_bindings ( cx,  trait_ref,  & bindings) ; 
145-                 GenericBound :: TraitBound ( 
146-                     PolyTrait  {  trait_,  generic_params :  vec ! [ ]  } , 
147-                     hir:: TraitBoundModifier :: None , 
148-                 ) 
146+             let  trait_ = clean_trait_ref_with_bindings ( cx,  trait_ref,  & bindings) ; 
147+             GenericBound :: TraitBound ( 
148+                 PolyTrait  {  trait_,  generic_params :  vec ! [ ]  } , 
149+                 hir:: TraitBoundModifier :: None , 
150+             ) 
151+         } 
152+         hir:: GenericBound :: Trait ( ref  t,  modifier)  => { 
153+             // `T: ~const Destruct` is hidden because `T: Destruct` is a no-op. 
154+             if  modifier == hir:: TraitBoundModifier :: MaybeConst 
155+                 && cx. tcx . lang_items ( ) . destruct_trait ( )  == Some ( t. trait_ref . trait_def_id ( ) . unwrap ( ) ) 
156+             { 
157+                 return  None ; 
149158            } 
150-             hir:: GenericBound :: Trait ( ref  t,  modifier)  => { 
151-                 // `T: ~const Destruct` is hidden because `T: Destruct` is a no-op. 
152-                 if  modifier == hir:: TraitBoundModifier :: MaybeConst 
153-                     && cx. tcx . lang_items ( ) . destruct_trait ( ) 
154-                         == Some ( t. trait_ref . trait_def_id ( ) . unwrap ( ) ) 
155-                 { 
156-                     return  None ; 
157-                 } 
158159
159-                 GenericBound :: TraitBound ( clean_poly_trait_ref ( t,  cx) ,  modifier) 
160-             } 
161-         } ) 
162-     } 
160+             GenericBound :: TraitBound ( clean_poly_trait_ref ( t,  cx) ,  modifier) 
161+         } 
162+     } ) 
163163} 
164164
165165pub ( crate )  fn  clean_trait_ref_with_bindings < ' tcx > ( 
@@ -207,12 +207,6 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
207207    ) 
208208} 
209209
210- impl < ' tcx >  Clean < ' tcx ,  GenericBound >  for  ty:: PolyTraitRef < ' tcx >  { 
211-     fn  clean ( & self ,  cx :  & mut  DocContext < ' tcx > )  -> GenericBound  { 
212-         clean_poly_trait_ref_with_bindings ( cx,  * self ,  & [ ] ) 
213-     } 
214- } 
215- 
216210fn  clean_lifetime < ' tcx > ( lifetime :  hir:: Lifetime ,  cx :  & mut  DocContext < ' tcx > )  -> Lifetime  { 
217211    let  def = cx. tcx . named_region ( lifetime. hir_id ) ; 
218212    if  let  Some ( 
@@ -294,14 +288,14 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for hir::WherePredicate<'tcx> {
294288                    . collect ( ) ; 
295289                WherePredicate :: BoundPredicate  { 
296290                    ty :  clean_ty ( wbp. bounded_ty ,  cx) , 
297-                     bounds :  wbp. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) , 
291+                     bounds :  wbp. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) , 
298292                    bound_params, 
299293                } 
300294            } 
301295
302296            hir:: WherePredicate :: RegionPredicate ( ref  wrp)  => WherePredicate :: RegionPredicate  { 
303297                lifetime :  clean_lifetime ( wrp. lifetime ,  cx) , 
304-                 bounds :  wrp. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) , 
298+                 bounds :  wrp. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) , 
305299            } , 
306300
307301            hir:: WherePredicate :: EqPredicate ( ref  wrp)  => WherePredicate :: EqPredicate  { 
@@ -349,7 +343,7 @@ fn clean_poly_trait_predicate<'tcx>(
349343    let  poly_trait_ref = pred. map_bound ( |pred| pred. trait_ref ) ; 
350344    Some ( WherePredicate :: BoundPredicate  { 
351345        ty :  clean_middle_ty ( poly_trait_ref. skip_binder ( ) . self_ty ( ) ,  cx,  None ) , 
352-         bounds :  vec ! [ poly_trait_ref . clean ( cx) ] , 
346+         bounds :  vec ! [ clean_poly_trait_ref_with_bindings ( cx,  poly_trait_ref ,   & [ ] ) ] , 
353347        bound_params :  Vec :: new ( ) , 
354348    } ) 
355349} 
@@ -531,7 +525,7 @@ fn clean_generic_param<'tcx>(
531525                    . bounds_for_param ( did) 
532526                    . filter ( |bp| bp. origin  != PredicateOrigin :: WhereClause ) 
533527                    . flat_map ( |bp| bp. bounds ) 
534-                     . filter_map ( |x| x . clean ( cx) ) 
528+                     . filter_map ( |x| clean_generic_bound ( x ,   cx) ) 
535529                    . collect ( ) 
536530            }  else  { 
537531                Vec :: new ( ) 
@@ -1041,7 +1035,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
10411035            } 
10421036            hir:: TraitItemKind :: Type ( bounds,  Some ( default) )  => { 
10431037                let  generics = enter_impl_trait ( cx,  |cx| trait_item. generics . clean ( cx) ) ; 
1044-                 let  bounds = bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ; 
1038+                 let  bounds = bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) ; 
10451039                let  item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx ,  default) ,  cx,  None ) ; 
10461040                AssocTypeItem ( 
10471041                    Box :: new ( Typedef  { 
@@ -1054,7 +1048,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
10541048            } 
10551049            hir:: TraitItemKind :: Type ( bounds,  None )  => { 
10561050                let  generics = enter_impl_trait ( cx,  |cx| trait_item. generics . clean ( cx) ) ; 
1057-                 let  bounds = bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ; 
1051+                 let  bounds = bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) ; 
10581052                TyAssocTypeItem ( Box :: new ( generics) ,  bounds) 
10591053            } 
10601054        } ; 
@@ -1507,7 +1501,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
15071501        TyKind :: OpaqueDef ( item_id,  _)  => { 
15081502            let  item = cx. tcx . hir ( ) . item ( item_id) ; 
15091503            if  let  hir:: ItemKind :: OpaqueTy ( ref  ty)  = item. kind  { 
1510-                 ImplTrait ( ty. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ) 
1504+                 ImplTrait ( ty. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) ) 
15111505            }  else  { 
15121506                unreachable ! ( ) 
15131507            } 
@@ -1911,7 +1905,7 @@ fn clean_maybe_renamed_item<'tcx>(
19111905                kind :  ConstantKind :: Local  {  body :  body_id,  def_id } , 
19121906            } ) , 
19131907            ItemKind :: OpaqueTy ( ref  ty)  => OpaqueTyItem ( OpaqueTy  { 
1914-                 bounds :  ty. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) , 
1908+                 bounds :  ty. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) , 
19151909                generics :  ty. generics . clean ( cx) , 
19161910            } ) , 
19171911            ItemKind :: TyAlias ( hir_ty,  generics)  => { 
@@ -1929,7 +1923,7 @@ fn clean_maybe_renamed_item<'tcx>(
19291923            } ) , 
19301924            ItemKind :: TraitAlias ( generics,  bounds)  => TraitAliasItem ( TraitAlias  { 
19311925                generics :  generics. clean ( cx) , 
1932-                 bounds :  bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) , 
1926+                 bounds :  bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) , 
19331927            } ) , 
19341928            ItemKind :: Union ( ref  variant_data,  generics)  => UnionItem ( Union  { 
19351929                generics :  generics. clean ( cx) , 
@@ -1961,7 +1955,7 @@ fn clean_maybe_renamed_item<'tcx>(
19611955                    def_id, 
19621956                    items, 
19631957                    generics :  generics. clean ( cx) , 
1964-                     bounds :  bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) , 
1958+                     bounds :  bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x ,   cx) ) . collect ( ) , 
19651959                } ) 
19661960            } 
19671961            ItemKind :: ExternCrate ( orig_name)  => { 
@@ -2241,7 +2235,7 @@ fn clean_type_binding<'tcx>(
22412235                TypeBindingKind :: Equality  {  term :  clean_hir_term ( term,  cx)  } 
22422236            } 
22432237            hir:: TypeBindingKind :: Constraint  {  bounds }  => TypeBindingKind :: Constraint  { 
2244-                 bounds :  bounds. iter ( ) . filter_map ( |b| b . clean ( cx) ) . collect ( ) , 
2238+                 bounds :  bounds. iter ( ) . filter_map ( |b| clean_generic_bound ( b ,   cx) ) . collect ( ) , 
22452239            } , 
22462240        } , 
22472241    } 
0 commit comments