@@ -96,9 +96,9 @@ impl Clean<Attributes> for [ast::Attribute] {
9696 }
9797}
9898
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 {
102102 hir:: GenericBound :: Outlives ( lt) => GenericBound :: Outlives ( lt. clean ( cx) ) ,
103103 hir:: GenericBound :: LangItemTrait ( lang_item, span, _, generic_args) => {
104104 let def_id = cx. tcx . require_lang_item ( lang_item, Some ( span) ) ;
@@ -118,9 +118,16 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
118118 )
119119 }
120120 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+ }
121128 GenericBound :: TraitBound ( t. clean ( cx) , modifier)
122129 }
123- }
130+ } )
124131 }
125132}
126133
@@ -255,14 +262,14 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
255262 . collect ( ) ;
256263 WherePredicate :: BoundPredicate {
257264 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 ( ) ,
259266 bound_params,
260267 }
261268 }
262269
263270 hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
264271 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 ( ) ,
266273 } ,
267274
268275 hir:: WherePredicate :: EqPredicate ( ref wrp) => {
@@ -276,7 +283,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
276283 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Option < WherePredicate > {
277284 let bound_predicate = self . kind ( ) ;
278285 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) ,
280287 ty:: PredicateKind :: RegionOutlives ( pred) => pred. clean ( cx) ,
281288 ty:: PredicateKind :: TypeOutlives ( pred) => pred. clean ( cx) ,
282289 ty:: PredicateKind :: Projection ( pred) => Some ( pred. clean ( cx) ) ,
@@ -293,14 +300,22 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
293300 }
294301}
295302
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+
298313 let poly_trait_ref = self . map_bound ( |pred| pred. trait_ref ) ;
299- WherePredicate :: BoundPredicate {
314+ Some ( WherePredicate :: BoundPredicate {
300315 ty : poly_trait_ref. skip_binder ( ) . self_ty ( ) . clean ( cx) ,
301316 bounds : vec ! [ poly_trait_ref. clean( cx) ] ,
302317 bound_params : Vec :: new ( ) ,
303- }
318+ } )
304319 }
305320}
306321
@@ -427,7 +442,7 @@ impl Clean<GenericParamDef> for hir::GenericParam<'_> {
427442 self . name . ident ( ) . name ,
428443 GenericParamDefKind :: Type {
429444 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 ( ) ,
431446 default : default. map ( |t| t. clean ( cx) ) . map ( Box :: new) ,
432447 synthetic,
433448 } ,
@@ -942,7 +957,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
942957 TyMethodItem ( t)
943958 }
944959 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 ( ) ;
946961 let default = default. map ( |t| t. clean ( cx) ) ;
947962 AssocTypeItem ( bounds, default)
948963 }
@@ -1352,7 +1367,7 @@ impl Clean<Type> for hir::Ty<'_> {
13521367 TyKind :: OpaqueDef ( item_id, _) => {
13531368 let item = cx. tcx . hir ( ) . item ( item_id) ;
13541369 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 ( ) )
13561371 } else {
13571372 unreachable ! ( )
13581373 }
@@ -1756,7 +1771,7 @@ fn clean_maybe_renamed_item(
17561771 kind : ConstantKind :: Local { body : body_id, def_id } ,
17571772 } ) ,
17581773 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 ( ) ,
17601775 generics : ty. generics . clean ( cx) ,
17611776 } ) ,
17621777 ItemKind :: TyAlias ( hir_ty, ref generics) => {
@@ -1778,7 +1793,7 @@ fn clean_maybe_renamed_item(
17781793 } ) ,
17791794 ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
17801795 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 ( ) ,
17821797 } ) ,
17831798 ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
17841799 generics : generics. clean ( cx) ,
@@ -1809,7 +1824,7 @@ fn clean_maybe_renamed_item(
18091824 unsafety,
18101825 items,
18111826 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 ( ) ,
18131828 is_auto : is_auto. clean ( cx) ,
18141829 } )
18151830 }
@@ -2096,9 +2111,9 @@ impl Clean<TypeBindingKind> for hir::TypeBindingKind<'_> {
20962111 hir:: TypeBindingKind :: Equality { ref ty } => {
20972112 TypeBindingKind :: Equality { ty : ty. clean ( cx) }
20982113 }
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+ } ,
21022117 }
21032118 }
21042119}
0 commit comments