@@ -3002,7 +3002,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
3002
3002
fn item_constant ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ,
3003
3003
c : & clean:: Constant ) -> fmt:: Result {
3004
3004
write ! ( w, "<pre class='rust const'>" ) ?;
3005
- render_attributes ( w, it) ?;
3005
+ render_attributes ( w, it, false ) ?;
3006
3006
write ! ( w, "{vis}const \
3007
3007
{name}: {typ}</pre>",
3008
3008
vis = VisSpace ( & it. visibility) ,
@@ -3014,7 +3014,7 @@ fn item_constant(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3014
3014
fn item_static ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ,
3015
3015
s : & clean:: Static ) -> fmt:: Result {
3016
3016
write ! ( w, "<pre class='rust static'>" ) ?;
3017
- render_attributes ( w, it) ?;
3017
+ render_attributes ( w, it, false ) ?;
3018
3018
write ! ( w, "{vis}static {mutability}\
3019
3019
{name}: {typ}</pre>",
3020
3020
vis = VisSpace ( & it. visibility) ,
@@ -3037,7 +3037,7 @@ fn item_function(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3037
3037
f. generics
3038
3038
) . len ( ) ;
3039
3039
write ! ( w, "{}<pre class='rust fn'>" , render_spotlight_traits( it) ?) ?;
3040
- render_attributes ( w, it) ?;
3040
+ render_attributes ( w, it, false ) ?;
3041
3041
write ! ( w,
3042
3042
"{vis}{constness}{unsafety}{asyncness}{abi}fn \
3043
3043
{name}{generics}{decl}{where_clause}</pre>",
@@ -3126,7 +3126,7 @@ fn item_trait(
3126
3126
// Output the trait definition
3127
3127
wrap_into_docblock ( w, |w| {
3128
3128
write ! ( w, "<pre class='rust trait'>" ) ?;
3129
- render_attributes ( w, it) ?;
3129
+ render_attributes ( w, it, true ) ?;
3130
3130
write ! ( w, "{}{}{}trait {}{}{}" ,
3131
3131
VisSpace ( & it. visibility) ,
3132
3132
UnsafetySpace ( t. unsafety) ,
@@ -3479,7 +3479,7 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
3479
3479
} else {
3480
3480
( 0 , true )
3481
3481
} ;
3482
- render_attributes ( w, meth) ?;
3482
+ render_attributes ( w, meth, false ) ?;
3483
3483
write ! ( w, "{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
3484
3484
{generics}{decl}{where_clause}",
3485
3485
if parent == ItemType :: Trait { " " } else { "" } ,
@@ -3526,7 +3526,7 @@ fn item_struct(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3526
3526
s : & clean:: Struct ) -> fmt:: Result {
3527
3527
wrap_into_docblock ( w, |w| {
3528
3528
write ! ( w, "<pre class='rust struct'>" ) ?;
3529
- render_attributes ( w, it) ?;
3529
+ render_attributes ( w, it, true ) ?;
3530
3530
render_struct ( w,
3531
3531
it,
3532
3532
Some ( & s. generics ) ,
@@ -3577,7 +3577,7 @@ fn item_union(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3577
3577
s : & clean:: Union ) -> fmt:: Result {
3578
3578
wrap_into_docblock ( w, |w| {
3579
3579
write ! ( w, "<pre class='rust union'>" ) ?;
3580
- render_attributes ( w, it) ?;
3580
+ render_attributes ( w, it, true ) ?;
3581
3581
render_union ( w,
3582
3582
it,
3583
3583
Some ( & s. generics ) ,
@@ -3622,7 +3622,7 @@ fn item_enum(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
3622
3622
e : & clean:: Enum ) -> fmt:: Result {
3623
3623
wrap_into_docblock ( w, |w| {
3624
3624
write ! ( w, "<pre class='rust enum'>" ) ?;
3625
- render_attributes ( w, it) ?;
3625
+ render_attributes ( w, it, true ) ?;
3626
3626
write ! ( w, "{}enum {}{}{}" ,
3627
3627
VisSpace ( & it. visibility) ,
3628
3628
it. name. as_ref( ) . unwrap( ) ,
@@ -3783,7 +3783,7 @@ const ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
3783
3783
"non_exhaustive"
3784
3784
] ;
3785
3785
3786
- fn render_attributes ( w : & mut dyn fmt:: Write , it : & clean:: Item ) -> fmt:: Result {
3786
+ fn render_attributes ( w : & mut dyn fmt:: Write , it : & clean:: Item , top : bool ) -> fmt:: Result {
3787
3787
let mut attrs = String :: new ( ) ;
3788
3788
3789
3789
for attr in & it. attrs . other_attrs {
@@ -3795,7 +3795,8 @@ fn render_attributes(w: &mut dyn fmt::Write, it: &clean::Item) -> fmt::Result {
3795
3795
}
3796
3796
}
3797
3797
if attrs. len ( ) > 0 {
3798
- write ! ( w, "<div class=\" docblock attributes\" >{}</div>" , & attrs) ?;
3798
+ write ! ( w, "<div class=\" docblock attributes{}\" >{}</div>" ,
3799
+ if top { " top-attr" } else { "" } , & attrs) ?;
3799
3800
}
3800
3801
Ok ( ( ) )
3801
3802
}
@@ -4344,7 +4345,7 @@ fn item_existential(
4344
4345
t : & clean:: Existential ,
4345
4346
) -> fmt:: Result {
4346
4347
write ! ( w, "<pre class='rust existential'>" ) ?;
4347
- render_attributes ( w, it) ?;
4348
+ render_attributes ( w, it, false ) ?;
4348
4349
write ! ( w, "existential type {}{}{where_clause}: {bounds};</pre>" ,
4349
4350
it. name. as_ref( ) . unwrap( ) ,
4350
4351
t. generics,
@@ -4363,7 +4364,7 @@ fn item_existential(
4363
4364
fn item_trait_alias ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ,
4364
4365
t : & clean:: TraitAlias ) -> fmt:: Result {
4365
4366
write ! ( w, "<pre class='rust trait-alias'>" ) ?;
4366
- render_attributes ( w, it) ?;
4367
+ render_attributes ( w, it, false ) ?;
4367
4368
write ! ( w, "trait {}{}{} = {};</pre>" ,
4368
4369
it. name. as_ref( ) . unwrap( ) ,
4369
4370
t. generics,
@@ -4382,7 +4383,7 @@ fn item_trait_alias(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
4382
4383
fn item_typedef ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ,
4383
4384
t : & clean:: Typedef ) -> fmt:: Result {
4384
4385
write ! ( w, "<pre class='rust typedef'>" ) ?;
4385
- render_attributes ( w, it) ?;
4386
+ render_attributes ( w, it, false ) ?;
4386
4387
write ! ( w, "type {}{}{where_clause} = {type_};</pre>" ,
4387
4388
it. name. as_ref( ) . unwrap( ) ,
4388
4389
t. generics,
@@ -4400,7 +4401,7 @@ fn item_typedef(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
4400
4401
4401
4402
fn item_foreign_type ( w : & mut fmt:: Formatter < ' _ > , cx : & Context , it : & clean:: Item ) -> fmt:: Result {
4402
4403
writeln ! ( w, "<pre class='rust foreigntype'>extern {{" ) ?;
4403
- render_attributes ( w, it) ?;
4404
+ render_attributes ( w, it, false ) ?;
4404
4405
write ! (
4405
4406
w,
4406
4407
" {}type {};\n }}</pre>" ,
0 commit comments