@@ -126,40 +126,40 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> {
126
126
}
127
127
}
128
128
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
+ } ;
143
145
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 ;
149
158
}
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
- }
158
159
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
+ } )
163
163
}
164
164
165
165
pub ( crate ) fn clean_trait_ref_with_bindings < ' tcx > (
@@ -207,12 +207,6 @@ fn clean_poly_trait_ref_with_bindings<'tcx>(
207
207
)
208
208
}
209
209
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
-
216
210
fn clean_lifetime < ' tcx > ( lifetime : hir:: Lifetime , cx : & mut DocContext < ' tcx > ) -> Lifetime {
217
211
let def = cx. tcx . named_region ( lifetime. hir_id ) ;
218
212
if let Some (
@@ -294,14 +288,14 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for hir::WherePredicate<'tcx> {
294
288
. collect ( ) ;
295
289
WherePredicate :: BoundPredicate {
296
290
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 ( ) ,
298
292
bound_params,
299
293
}
300
294
}
301
295
302
296
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
303
297
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 ( ) ,
305
299
} ,
306
300
307
301
hir:: WherePredicate :: EqPredicate ( ref wrp) => WherePredicate :: EqPredicate {
@@ -349,7 +343,7 @@ fn clean_poly_trait_predicate<'tcx>(
349
343
let poly_trait_ref = pred. map_bound ( |pred| pred. trait_ref ) ;
350
344
Some ( WherePredicate :: BoundPredicate {
351
345
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 , & [ ] ) ] ,
353
347
bound_params : Vec :: new ( ) ,
354
348
} )
355
349
}
@@ -531,7 +525,7 @@ fn clean_generic_param<'tcx>(
531
525
. bounds_for_param ( did)
532
526
. filter ( |bp| bp. origin != PredicateOrigin :: WhereClause )
533
527
. flat_map ( |bp| bp. bounds )
534
- . filter_map ( |x| x . clean ( cx) )
528
+ . filter_map ( |x| clean_generic_bound ( x , cx) )
535
529
. collect ( )
536
530
} else {
537
531
Vec :: new ( )
@@ -1041,7 +1035,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1041
1035
}
1042
1036
hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1043
1037
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 ( ) ;
1045
1039
let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1046
1040
AssocTypeItem (
1047
1041
Box :: new ( Typedef {
@@ -1054,7 +1048,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1054
1048
}
1055
1049
hir:: TraitItemKind :: Type ( bounds, None ) => {
1056
1050
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 ( ) ;
1058
1052
TyAssocTypeItem ( Box :: new ( generics) , bounds)
1059
1053
}
1060
1054
} ;
@@ -1507,7 +1501,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
1507
1501
TyKind :: OpaqueDef ( item_id, _) => {
1508
1502
let item = cx. tcx . hir ( ) . item ( item_id) ;
1509
1503
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 ( ) )
1511
1505
} else {
1512
1506
unreachable ! ( )
1513
1507
}
@@ -1911,7 +1905,7 @@ fn clean_maybe_renamed_item<'tcx>(
1911
1905
kind : ConstantKind :: Local { body : body_id, def_id } ,
1912
1906
} ) ,
1913
1907
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 ( ) ,
1915
1909
generics : ty. generics . clean ( cx) ,
1916
1910
} ) ,
1917
1911
ItemKind :: TyAlias ( hir_ty, generics) => {
@@ -1929,7 +1923,7 @@ fn clean_maybe_renamed_item<'tcx>(
1929
1923
} ) ,
1930
1924
ItemKind :: TraitAlias ( generics, bounds) => TraitAliasItem ( TraitAlias {
1931
1925
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 ( ) ,
1933
1927
} ) ,
1934
1928
ItemKind :: Union ( ref variant_data, generics) => UnionItem ( Union {
1935
1929
generics : generics. clean ( cx) ,
@@ -1961,7 +1955,7 @@ fn clean_maybe_renamed_item<'tcx>(
1961
1955
def_id,
1962
1956
items,
1963
1957
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 ( ) ,
1965
1959
} )
1966
1960
}
1967
1961
ItemKind :: ExternCrate ( orig_name) => {
@@ -2241,7 +2235,7 @@ fn clean_type_binding<'tcx>(
2241
2235
TypeBindingKind :: Equality { term : clean_hir_term ( term, cx) }
2242
2236
}
2243
2237
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 ( ) ,
2245
2239
} ,
2246
2240
} ,
2247
2241
}
0 commit comments