@@ -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 > (
@@ -294,14 +294,14 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for hir::WherePredicate<'tcx> {
294
294
. collect ( ) ;
295
295
WherePredicate :: BoundPredicate {
296
296
ty : clean_ty ( wbp. bounded_ty , cx) ,
297
- bounds : wbp. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ,
297
+ bounds : wbp. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ,
298
298
bound_params,
299
299
}
300
300
}
301
301
302
302
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
303
303
lifetime : clean_lifetime ( wrp. lifetime , cx) ,
304
- bounds : wrp. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ,
304
+ bounds : wrp. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ,
305
305
} ,
306
306
307
307
hir:: WherePredicate :: EqPredicate ( ref wrp) => WherePredicate :: EqPredicate {
@@ -531,7 +531,7 @@ fn clean_generic_param<'tcx>(
531
531
. bounds_for_param ( did)
532
532
. filter ( |bp| bp. origin != PredicateOrigin :: WhereClause )
533
533
. flat_map ( |bp| bp. bounds )
534
- . filter_map ( |x| x . clean ( cx) )
534
+ . filter_map ( |x| clean_generic_bound ( x , cx) )
535
535
. collect ( )
536
536
} else {
537
537
Vec :: new ( )
@@ -1041,7 +1041,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1041
1041
}
1042
1042
hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1043
1043
let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1044
- let bounds = bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ;
1044
+ let bounds = bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ;
1045
1045
let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1046
1046
AssocTypeItem (
1047
1047
Box :: new ( Typedef {
@@ -1054,7 +1054,7 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1054
1054
}
1055
1055
hir:: TraitItemKind :: Type ( bounds, None ) => {
1056
1056
let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1057
- let bounds = bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ;
1057
+ let bounds = bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ;
1058
1058
TyAssocTypeItem ( Box :: new ( generics) , bounds)
1059
1059
}
1060
1060
} ;
@@ -1507,7 +1507,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
1507
1507
TyKind :: OpaqueDef ( item_id, _) => {
1508
1508
let item = cx. tcx . hir ( ) . item ( item_id) ;
1509
1509
if let hir:: ItemKind :: OpaqueTy ( ref ty) = item. kind {
1510
- ImplTrait ( ty. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) )
1510
+ ImplTrait ( ty. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) )
1511
1511
} else {
1512
1512
unreachable ! ( )
1513
1513
}
@@ -1911,7 +1911,7 @@ fn clean_maybe_renamed_item<'tcx>(
1911
1911
kind : ConstantKind :: Local { body : body_id, def_id } ,
1912
1912
} ) ,
1913
1913
ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1914
- bounds : ty. bounds . iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ,
1914
+ bounds : ty. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ,
1915
1915
generics : ty. generics . clean ( cx) ,
1916
1916
} ) ,
1917
1917
ItemKind :: TyAlias ( hir_ty, generics) => {
@@ -1929,7 +1929,7 @@ fn clean_maybe_renamed_item<'tcx>(
1929
1929
} ) ,
1930
1930
ItemKind :: TraitAlias ( generics, bounds) => TraitAliasItem ( TraitAlias {
1931
1931
generics : generics. clean ( cx) ,
1932
- bounds : bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ,
1932
+ bounds : bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ,
1933
1933
} ) ,
1934
1934
ItemKind :: Union ( ref variant_data, generics) => UnionItem ( Union {
1935
1935
generics : generics. clean ( cx) ,
@@ -1961,7 +1961,7 @@ fn clean_maybe_renamed_item<'tcx>(
1961
1961
def_id,
1962
1962
items,
1963
1963
generics : generics. clean ( cx) ,
1964
- bounds : bounds. iter ( ) . filter_map ( |x| x . clean ( cx) ) . collect ( ) ,
1964
+ bounds : bounds. iter ( ) . filter_map ( |x| clean_generic_bound ( x , cx) ) . collect ( ) ,
1965
1965
} )
1966
1966
}
1967
1967
ItemKind :: ExternCrate ( orig_name) => {
@@ -2241,7 +2241,7 @@ fn clean_type_binding<'tcx>(
2241
2241
TypeBindingKind :: Equality { term : clean_hir_term ( term, cx) }
2242
2242
}
2243
2243
hir:: TypeBindingKind :: Constraint { bounds } => TypeBindingKind :: Constraint {
2244
- bounds : bounds. iter ( ) . filter_map ( |b| b . clean ( cx) ) . collect ( ) ,
2244
+ bounds : bounds. iter ( ) . filter_map ( |b| clean_generic_bound ( b , cx) ) . collect ( ) ,
2245
2245
} ,
2246
2246
} ,
2247
2247
}
0 commit comments