@@ -2103,6 +2103,7 @@ impl<'a> fmt::Display for Item<'a> {
2103
2103
clean:: ConstantItem ( ..) => write ! ( fmt, "Constant " ) ?,
2104
2104
clean:: ForeignTypeItem => write ! ( fmt, "Foreign Type " ) ?,
2105
2105
clean:: KeywordItem ( ..) => write ! ( fmt, "Keyword " ) ?,
2106
+ clean:: ExistentialItem ( ..) => write ! ( fmt, "Existential Type " ) ?,
2106
2107
_ => {
2107
2108
// We don't generate pages for any other type.
2108
2109
unreachable ! ( ) ;
@@ -2167,6 +2168,7 @@ impl<'a> fmt::Display for Item<'a> {
2167
2168
clean:: ConstantItem ( ref c) => item_constant ( fmt, self . cx , self . item , c) ,
2168
2169
clean:: ForeignTypeItem => item_foreign_type ( fmt, self . cx , self . item ) ,
2169
2170
clean:: KeywordItem ( ref k) => item_keyword ( fmt, self . cx , self . item , k) ,
2171
+ clean:: ExistentialItem ( ref e, _) => item_existential ( fmt, self . cx , self . item , e) ,
2170
2172
_ => {
2171
2173
// We don't generate pages for any other type.
2172
2174
unreachable ! ( ) ;
@@ -2685,18 +2687,17 @@ fn render_impls(cx: &Context, w: &mut fmt::Formatter,
2685
2687
Ok ( ( ) )
2686
2688
}
2687
2689
2688
- fn item_trait ( w : & mut fmt:: Formatter , cx : & Context , it : & clean:: Item ,
2689
- t : & clean:: Trait ) -> fmt:: Result {
2690
+ fn bounds ( t_bounds : & [ clean:: GenericBound ] ) -> String {
2690
2691
let mut bounds = String :: new ( ) ;
2691
2692
let mut bounds_plain = String :: new ( ) ;
2692
- if !t . bounds . is_empty ( ) {
2693
+ if !t_bounds . is_empty ( ) {
2693
2694
if !bounds. is_empty ( ) {
2694
2695
bounds. push ( ' ' ) ;
2695
2696
bounds_plain. push ( ' ' ) ;
2696
2697
}
2697
2698
bounds. push_str ( ": " ) ;
2698
2699
bounds_plain. push_str ( ": " ) ;
2699
- for ( i, p) in t . bounds . iter ( ) . enumerate ( ) {
2700
+ for ( i, p) in t_bounds . iter ( ) . enumerate ( ) {
2700
2701
if i > 0 {
2701
2702
bounds. push_str ( " + " ) ;
2702
2703
bounds_plain. push_str ( " + " ) ;
@@ -2705,7 +2706,16 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2705
2706
bounds_plain. push_str ( & format ! ( "{:#}" , * p) ) ;
2706
2707
}
2707
2708
}
2709
+ bounds
2710
+ }
2708
2711
2712
+ fn item_trait (
2713
+ w : & mut fmt:: Formatter ,
2714
+ cx : & Context ,
2715
+ it : & clean:: Item ,
2716
+ t : & clean:: Trait ,
2717
+ ) -> fmt:: Result {
2718
+ let bounds = bounds ( & t. bounds ) ;
2709
2719
let types = t. items . iter ( ) . filter ( |m| m. is_associated_type ( ) ) . collect :: < Vec < _ > > ( ) ;
2710
2720
let consts = t. items . iter ( ) . filter ( |m| m. is_associated_const ( ) ) . collect :: < Vec < _ > > ( ) ;
2711
2721
let required = t. items . iter ( ) . filter ( |m| m. is_ty_method ( ) ) . collect :: < Vec < _ > > ( ) ;
@@ -3905,6 +3915,29 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
3905
3915
Ok ( ( ) )
3906
3916
}
3907
3917
3918
+ fn item_existential (
3919
+ w : & mut fmt:: Formatter ,
3920
+ cx : & Context ,
3921
+ it : & clean:: Item ,
3922
+ t : & clean:: Existential ,
3923
+ ) -> fmt:: Result {
3924
+ write ! ( w, "<pre class='rust existential'>" ) ?;
3925
+ render_attributes ( w, it) ?;
3926
+ write ! ( w, "existential type {}{}{where_clause}: {bounds};</pre>" ,
3927
+ it. name. as_ref( ) . unwrap( ) ,
3928
+ t. generics,
3929
+ where_clause = WhereClause { gens: & t. generics, indent: 0 , end_newline: true } ,
3930
+ bounds = bounds( & t. bounds) ) ?;
3931
+
3932
+ document ( w, cx, it) ?;
3933
+
3934
+ // Render any items associated directly to this alias, as otherwise they
3935
+ // won't be visible anywhere in the docs. It would be nice to also show
3936
+ // associated items from the aliased type (see discussion in #32077), but
3937
+ // we need #14072 to make sense of the generics.
3938
+ render_assoc_items ( w, cx, it, it. def_id , AssocItemRender :: All )
3939
+ }
3940
+
3908
3941
fn item_typedef ( w : & mut fmt:: Formatter , cx : & Context , it : & clean:: Item ,
3909
3942
t : & clean:: Typedef ) -> fmt:: Result {
3910
3943
write ! ( w, "<pre class='rust typedef'>" ) ?;
0 commit comments