@@ -96,9 +96,9 @@ impl Clean<Attributes> for [ast::Attribute] {
96
96
}
97
97
}
98
98
99
- impl Clean < GenericBound > for hir:: GenericBound < ' _ > {
100
- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericBound {
101
- match * self {
99
+ impl Clean < Option < GenericBound > > for hir:: GenericBound < ' _ > {
100
+ fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Option < GenericBound > {
101
+ Some ( match * self {
102
102
hir:: GenericBound :: Outlives ( lt) => GenericBound :: Outlives ( lt. clean ( cx) ) ,
103
103
hir:: GenericBound :: LangItemTrait ( lang_item, span, _, generic_args) => {
104
104
let def_id = cx. tcx . require_lang_item ( lang_item, Some ( span) ) ;
@@ -118,9 +118,16 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
118
118
)
119
119
}
120
120
hir:: GenericBound :: Trait ( ref t, modifier) => {
121
+ // `T: ~const Drop` is not equivalent to `T: Drop`, and we don't currently document `~const` bounds
122
+ // because of its experimental status, so just don't show these.
123
+ if Some ( t. trait_ref . trait_def_id ( ) . unwrap ( ) ) == cx. tcx . lang_items ( ) . drop_trait ( )
124
+ && hir:: TraitBoundModifier :: MaybeConst == modifier
125
+ {
126
+ return None ;
127
+ }
121
128
GenericBound :: TraitBound ( t. clean ( cx) , modifier)
122
129
}
123
- }
130
+ } )
124
131
}
125
132
}
126
133
@@ -255,14 +262,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
255
262
. collect ( ) ;
256
263
WherePredicate :: BoundPredicate {
257
264
ty : wbp. bounded_ty . clean ( cx) ,
258
- bounds : wbp. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
265
+ bounds : wbp. bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
259
266
bound_params,
260
267
}
261
268
}
262
269
263
270
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
264
271
lifetime : wrp. lifetime . clean ( cx) ,
265
- bounds : wrp. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
272
+ bounds : wrp. bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
266
273
} ,
267
274
268
275
hir:: WherePredicate :: EqPredicate ( ref wrp) => {
@@ -276,7 +283,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
276
283
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Option < WherePredicate > {
277
284
let bound_predicate = self . kind ( ) ;
278
285
match bound_predicate. skip_binder ( ) {
279
- ty:: PredicateKind :: Trait ( pred) => Some ( bound_predicate. rebind ( pred) . clean ( cx) ) ,
286
+ ty:: PredicateKind :: Trait ( pred) => bound_predicate. rebind ( pred) . clean ( cx) ,
280
287
ty:: PredicateKind :: RegionOutlives ( pred) => pred. clean ( cx) ,
281
288
ty:: PredicateKind :: TypeOutlives ( pred) => pred. clean ( cx) ,
282
289
ty:: PredicateKind :: Projection ( pred) => Some ( pred. clean ( cx) ) ,
@@ -293,14 +300,22 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
293
300
}
294
301
}
295
302
296
- impl < ' a > Clean < WherePredicate > for ty:: PolyTraitPredicate < ' a > {
297
- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> WherePredicate {
303
+ impl < ' a > Clean < Option < WherePredicate > > for ty:: PolyTraitPredicate < ' a > {
304
+ fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Option < WherePredicate > {
305
+ // `T: ~const Drop` is not equivalent to `T: Drop`, and we don't currently document `~const` bounds
306
+ // because of its experimental status, so just don't show these.
307
+ if self . skip_binder ( ) . constness == ty:: BoundConstness :: ConstIfConst
308
+ && Some ( self . skip_binder ( ) . trait_ref . def_id ) == cx. tcx . lang_items ( ) . drop_trait ( )
309
+ {
310
+ return None ;
311
+ }
312
+
298
313
let poly_trait_ref = self . map_bound ( |pred| pred. trait_ref ) ;
299
- WherePredicate :: BoundPredicate {
314
+ Some ( WherePredicate :: BoundPredicate {
300
315
ty : poly_trait_ref. skip_binder ( ) . self_ty ( ) . clean ( cx) ,
301
316
bounds : vec ! [ poly_trait_ref. clean( cx) ] ,
302
317
bound_params : Vec :: new ( ) ,
303
- }
318
+ } )
304
319
}
305
320
}
306
321
@@ -427,7 +442,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
427
442
self . name . ident ( ) . name ,
428
443
GenericParamDefKind :: Type {
429
444
did : cx. tcx . hir ( ) . local_def_id ( self . hir_id ) . to_def_id ( ) ,
430
- bounds : self . bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
445
+ bounds : self . bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
431
446
default : default. map ( |t| t. clean ( cx) ) . map ( Box :: new) ,
432
447
synthetic,
433
448
} ,
@@ -942,7 +957,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
942
957
TyMethodItem ( t)
943
958
}
944
959
hir:: TraitItemKind :: Type ( bounds, ref default) => {
945
- let bounds = bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ;
960
+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
946
961
let default = default. map ( |t| t. clean ( cx) ) ;
947
962
AssocTypeItem ( bounds, default)
948
963
}
@@ -1352,7 +1367,7 @@ impl Clean<Type> for hir::Ty<'_> {
1352
1367
TyKind :: OpaqueDef ( item_id, _) => {
1353
1368
let item = cx. tcx . hir ( ) . item ( item_id) ;
1354
1369
if let hir:: ItemKind :: OpaqueTy ( ref ty) = item. kind {
1355
- ImplTrait ( ty. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) )
1370
+ ImplTrait ( ty. bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) )
1356
1371
} else {
1357
1372
unreachable ! ( )
1358
1373
}
@@ -1756,7 +1771,7 @@ fn clean_maybe_renamed_item(
1756
1771
kind : ConstantKind :: Local { body : body_id, def_id } ,
1757
1772
} ) ,
1758
1773
ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1759
- bounds : ty. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1774
+ bounds : ty. bounds . iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
1760
1775
generics : ty. generics . clean ( cx) ,
1761
1776
} ) ,
1762
1777
ItemKind :: TyAlias ( hir_ty, ref generics) => {
@@ -1778,7 +1793,7 @@ fn clean_maybe_renamed_item(
1778
1793
} ) ,
1779
1794
ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
1780
1795
generics : generics. clean ( cx) ,
1781
- bounds : bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1796
+ bounds : bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
1782
1797
} ) ,
1783
1798
ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
1784
1799
generics : generics. clean ( cx) ,
@@ -1809,7 +1824,7 @@ fn clean_maybe_renamed_item(
1809
1824
unsafety,
1810
1825
items,
1811
1826
generics : generics. clean ( cx) ,
1812
- bounds : bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1827
+ bounds : bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ,
1813
1828
is_auto : is_auto. clean ( cx) ,
1814
1829
} )
1815
1830
}
@@ -2096,9 +2111,9 @@ impl Clean<TypeBindingKind> for hir::TypeBindingKind<'_> {
2096
2111
hir:: TypeBindingKind :: Equality { ref ty } => {
2097
2112
TypeBindingKind :: Equality { ty : ty. clean ( cx) }
2098
2113
}
2099
- hir:: TypeBindingKind :: Constraint { bounds } => {
2100
- TypeBindingKind :: Constraint { bounds : bounds. iter ( ) . map ( |b| b. clean ( cx) ) . collect ( ) }
2101
- }
2114
+ hir:: TypeBindingKind :: Constraint { bounds } => TypeBindingKind :: Constraint {
2115
+ bounds : bounds. iter ( ) . filter_map ( |b| b. clean ( cx) ) . collect ( ) ,
2116
+ } ,
2102
2117
}
2103
2118
}
2104
2119
}
0 commit comments