@@ -464,7 +464,9 @@ pub struct TyParam {
464
464
pub name : String ,
465
465
pub did : ast:: DefId ,
466
466
pub bounds : Vec < TyParamBound > ,
467
- pub default : Option < Type >
467
+ pub default : Option < Type > ,
468
+ /// An optional default bound on the parameter which is unbound, like `Sized?`
469
+ pub default_unbound : Option < Type >
468
470
}
469
471
470
472
impl Clean < TyParam > for ast:: TyParam {
@@ -473,7 +475,8 @@ impl Clean<TyParam> for ast::TyParam {
473
475
name : self . ident . clean ( cx) ,
474
476
did : ast:: DefId { krate : ast:: LOCAL_CRATE , node : self . id } ,
475
477
bounds : self . bounds . clean ( cx) ,
476
- default : self . default . clean ( cx)
478
+ default : self . default . clean ( cx) ,
479
+ default_unbound : self . unbound . clean ( cx)
477
480
}
478
481
}
479
482
}
@@ -482,11 +485,13 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef<'tcx> {
482
485
fn clean ( & self , cx : & DocContext ) -> TyParam {
483
486
cx. external_typarams . borrow_mut ( ) . as_mut ( ) . unwrap ( )
484
487
. insert ( self . def_id , self . name . clean ( cx) ) ;
488
+ let ( bounds, default_unbound) = self . bounds . clean ( cx) ;
485
489
TyParam {
486
490
name : self . name . clean ( cx) ,
487
491
did : self . def_id ,
488
- bounds : self . bounds . clean ( cx) ,
489
- default : self . default . clean ( cx)
492
+ bounds : bounds,
493
+ default : self . default . clean ( cx) ,
494
+ default_unbound : default_unbound
490
495
}
491
496
}
492
497
}
@@ -588,12 +593,16 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
588
593
}
589
594
}
590
595
591
- impl < ' tcx > Clean < Vec < TyParamBound > > for ty:: ParamBounds < ' tcx > {
592
- fn clean ( & self , cx : & DocContext ) -> Vec < TyParamBound > {
596
+ // Returns (bounds, default_unbound)
597
+ impl < ' tcx > Clean < ( Vec < TyParamBound > , Option < Type > ) > for ty:: ParamBounds < ' tcx > {
598
+ fn clean ( & self , cx : & DocContext ) -> ( Vec < TyParamBound > , Option < Type > ) {
593
599
let mut v = Vec :: new ( ) ;
600
+ let mut has_sized_bound = false ;
594
601
for b in self . builtin_bounds . iter ( ) {
595
602
if b != ty:: BoundSized {
596
603
v. push ( b. clean ( cx) ) ;
604
+ } else {
605
+ has_sized_bound = true ;
597
606
}
598
607
}
599
608
for t in self . trait_bounds . iter ( ) {
@@ -602,7 +611,15 @@ impl<'tcx> Clean<Vec<TyParamBound>> for ty::ParamBounds<'tcx> {
602
611
for r in self . region_bounds . iter ( ) . filter_map ( |r| r. clean ( cx) ) {
603
612
v. push ( RegionBound ( r) ) ;
604
613
}
605
- return v;
614
+ if has_sized_bound {
615
+ ( v, None )
616
+ } else {
617
+ let ty = match ty:: BoundSized . clean ( cx) {
618
+ TraitBound ( ty) => ty,
619
+ _ => unreachable ! ( )
620
+ } ;
621
+ ( v, Some ( ty) )
622
+ }
606
623
}
607
624
}
608
625
@@ -950,6 +967,8 @@ pub struct Trait {
950
967
pub items : Vec < TraitMethod > ,
951
968
pub generics : Generics ,
952
969
pub bounds : Vec < TyParamBound > ,
970
+ /// An optional default bound not required for `Self`, like `Sized?`
971
+ pub default_unbound : Option < Type >
953
972
}
954
973
955
974
impl Clean < Item > for doctree:: Trait {
@@ -965,6 +984,7 @@ impl Clean<Item> for doctree::Trait {
965
984
items : self . items . clean ( cx) ,
966
985
generics : self . generics . clean ( cx) ,
967
986
bounds : self . bounds . clean ( cx) ,
987
+ default_unbound : self . default_unbound . clean ( cx)
968
988
} ) ,
969
989
}
970
990
}
@@ -2258,7 +2278,8 @@ impl Clean<Item> for ty::AssociatedType {
2258
2278
node : ast:: DUMMY_NODE_ID
2259
2279
} ,
2260
2280
bounds : vec ! [ ] ,
2261
- default : None
2281
+ default : None ,
2282
+ default_unbound : None
2262
2283
} ) ,
2263
2284
visibility : None ,
2264
2285
def_id : self . def_id ,
0 commit comments