diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 940d7e87a183b..1a96656b6f23c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2410,12 +2410,12 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func f.generics.print() ) .len(); - write!(w, "{}
", render_spotlight_traits(it)); + write!(w, "", vis = it.visibility.print_with_space(), constness = f.header.constness.print_with_space(), asyncness = f.header.asyncness.print_with_space(), @@ -2425,7 +2425,8 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func generics = f.generics.print(), where_clause = WhereClause { gens: &f.generics, indent: 0, end_newline: true }, decl = Function { decl: &f.decl, header_len, indent: 0, asyncness: f.header.asyncness } - .print() + .print(), + spotlight = spotlight_decl(&f.decl), ); document(w, cx, it) } @@ -2614,9 +2615,8 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait) let id = cx.derive_id(format!("{}.{}", item_type, name)); write!( w, - ""); render_attributes(w, it, false); write!( w, "{vis}{constness}{asyncness}{unsafety}{abi}fn \ - {name}{generics}{decl}{where_clause}", + {name}{generics}{decl}{spotlight}{where_clause}
",
- extra = render_spotlight_traits(m),
- id = id
+ "",
+ id = id,
);
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)), ItemType::Impl);
write!(w, "
");
@@ -2931,7 +2931,7 @@ fn render_assoc_item(
write!(
w,
"{}{}{}{}{}{}{}fn {name}\
- {generics}{decl}{where_clause}",
+ {generics}{decl}{spotlight}{where_clause}",
if parent == ItemType::Trait { " " } else { "" },
meth.visibility.print_with_space(),
header.constness.print_with_space(),
@@ -2943,6 +2943,7 @@ fn render_assoc_item(
name = name,
generics = g.print(),
decl = Function { decl: d, header_len, indent, asyncness: header.asyncness }.print(),
+ spotlight = spotlight_decl(&d),
where_clause = WhereClause { gens: g, indent, end_newline }
)
}
@@ -3564,16 +3565,6 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
}
}
-fn render_spotlight_traits(item: &clean::Item) -> String {
- match item.inner {
- clean::FunctionItem(clean::Function { ref decl, .. })
- | clean::TyMethodItem(clean::TyMethod { ref decl, .. })
- | clean::MethodItem(clean::Method { ref decl, .. })
- | clean::ForeignFunctionItem(clean::Function { ref decl, .. }) => spotlight_decl(decl),
- _ => String::new(),
- }
-}
-
fn spotlight_decl(decl: &clean::FnDecl) -> String {
let mut out = Buffer::html();
let mut trait_ = String::new();
@@ -3622,13 +3613,13 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
out.insert_str(
0,
&format!(
- "ⓘ\
+ "ⓘ\
Important traits for {}\
",
trait_
),
);
- out.push_str("");
+ out.push_str("");
}
out.into_inner()
@@ -3740,13 +3731,12 @@ fn render_impl(
(true, " hidden")
};
match item.inner {
- clean::MethodItem(clean::Method { ref decl, .. })
- | clean::TyMethodItem(clean::TyMethod { ref decl, .. }) => {
+ clean::MethodItem(clean::Method { .. })
+ | clean::TyMethodItem(clean::TyMethod { .. }) => {
// Only render when the method is not static or we allow static methods
if render_method_item {
let id = cx.derive_id(format!("{}.{}", item_type, name));
write!(w, "", id, item_type, extra_class);
- write!(w, "{}", spotlight_decl(decl));
write!(w, "");
render_assoc_item(w, item, link.anchor(&id), ItemType::Impl);
write!(w, "
");
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 3b2a28a0f5e45..b780cf5dafb49 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -1082,7 +1082,7 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
font-size: 16px;
}
-.tooltip:hover .tooltiptext {
+.important-traits:hover .tooltiptext {
display: inline;
}
@@ -1150,6 +1150,7 @@ pre.rust {
.important-traits {
cursor: pointer;
z-index: 2;
+ margin-left: 5px;
}
h4 > .important-traits {
@@ -1555,19 +1556,6 @@ h3.important {
top: 0px;
}
-#main > div.important-traits {
- position: absolute;
- left: -24px;
- margin-top: 16px;
-}
-
-.content > .methods > .method > div.important-traits {
- position: absolute;
- font-weight: 400;
- left: -42px;
- margin-top: 2px;
-}
-
kbd {
display: inline-block;
padding: 3px 5px;