diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 51068d5648e4..d654429146d8 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2036,14 +2036,18 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
-> fmt::Result {
let name = m.name.as_ref().unwrap();
- let id = derive_id(format!("{}.{}", item_type(m), name));
- write!(w, "
",
+ let item_type = item_type(m);
+ let id = derive_id(format!("{}.{}", item_type, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
+ write!(w, "\
+ ",
id = id,
- stab = m.stability_class())?;
+ stab = m.stability_class(),
+ ns_id = ns_id)?;
render_assoc_item(w, m, AssocItemLink::Anchor(Some(&id)))?;
write!(w, "
")?;
render_stability_since(w, m, t)?;
- write!(w, "
")?;
+ write!(w, "
")?;
document(w, cx, m)?;
Ok(())
}
@@ -2282,12 +2286,19 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
if fields.peek().is_some() {
write!(w, "Fields
")?;
for (field, ty) in fields {
- write!(w, "
-
+ let id = derive_id(format!("{}.{}",
+ ItemType::StructField,
+ field.name.as_ref().unwrap()));
+ let ns_id = derive_id(format!("{}.{}",
+ field.name.as_ref().unwrap(),
+ ItemType::StructField.name_space()));
+ write!(w, "
+
{name}: {ty}
- ",
+ ",
item_type = ItemType::StructField,
- name_space = ItemType::StructField.name_space(),
+ id = id,
+ ns_id = ns_id,
stab = field.stability_class(),
name = field.name.as_ref().unwrap(),
ty = ty)?;
@@ -2356,10 +2367,16 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
if !e.variants.is_empty() {
write!(w, "Variants
\n")?;
for variant in &e.variants {
- write!(w, "\
- {name}",
- item_type = ItemType::Variant,
- name_space = ItemType::Variant.name_space(),
+ let id = derive_id(format!("{}.{}",
+ ItemType::Variant,
+ variant.name.as_ref().unwrap()));
+ let ns_id = derive_id(format!("{}.{}",
+ variant.name.as_ref().unwrap(),
+ ItemType::Variant.name_space()));
+ write!(w, "\
+ {name}",
+ id = id,
+ ns_id = ns_id,
name = variant.name.as_ref().unwrap())?;
if let clean::VariantItem(ref var) = variant.inner {
if let clean::TupleVariant(ref tys) = var.kind {
@@ -2373,7 +2390,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
write!(w, ")")?;
}
}
- write!(w, "
")?;
+ write!(w, "")?;
document(w, cx, variant)?;
use clean::{Variant, StructVariant};
@@ -2383,14 +2400,21 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
for field in &s.fields {
use clean::StructFieldItem;
if let StructFieldItem(ref ty) = field.inner {
+ let id = derive_id(format!("variant.{}.field.{}",
+ variant.name.as_ref().unwrap(),
+ field.name.as_ref().unwrap()));
+ let ns_id = derive_id(format!("{}.{}.{}.{}",
+ variant.name.as_ref().unwrap(),
+ ItemType::Variant.name_space(),
+ field.name.as_ref().unwrap(),
+ ItemType::StructField.name_space()));
write!(w, "\
- \
- {f}: {t} | ",
- v = variant.name.as_ref().unwrap(),
+ id='{id}'>\
+ \
+ {f}: {t} | ",
+ id = id,
+ ns_id = ns_id,
f = field.name.as_ref().unwrap(),
- vns = ItemType::Variant.name_space(),
- fns = ItemType::StructField.name_space(),
t = *ty)?;
document(w, cx, field)?;
write!(w, " |
")?;
@@ -2606,10 +2630,10 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
}
}
- fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
- link: AssocItemLink, render_static: bool,
- is_default_item: bool, outer_version: Option<&str>,
- trait_: Option<&clean::Trait>) -> fmt::Result {
+ fn doc_impl_item(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
+ link: AssocItemLink, render_static: bool,
+ is_default_item: bool, outer_version: Option<&str>,
+ trait_: Option<&clean::Trait>) -> fmt::Result {
let item_type = item_type(item);
let name = item.name.as_ref().unwrap();
@@ -2624,42 +2648,47 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
// Only render when the method is not static or we allow static methods
if !is_static || render_static {
let id = derive_id(format!("{}.{}", item_type, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\n")?;
+ write!(w, "\n")?;
}
}
clean::TypedefItem(ref tydef, _) => {
let id = derive_id(format!("{}.{}", ItemType::AssociatedType, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\n")?;
+ write!(w, "\n")?;
}
clean::AssociatedConstItem(ref ty, ref default) => {
let id = derive_id(format!("{}.{}", item_type, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\n")?;
+ write!(w, "\n")?;
}
clean::ConstantItem(ref c) => {
let id = derive_id(format!("{}.{}", item_type, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\n")?;
+ write!(w, "\n")?;
}
clean::AssociatedTypeItem(ref bounds, ref default) => {
let id = derive_id(format!("{}.{}", item_type, name));
+ let ns_id = derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "\n")?;
+ write!(w, "\n")?;
}
clean::StrippedItem(..) => return Ok(()),
_ => panic!("can't make docs for trait item with name {:?}", item.name)
@@ -2698,8 +2727,8 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
write!(w, "")?;
for trait_item in &i.inner_impl().items {
- doctraititem(w, cx, trait_item, link, render_header,
- false, outer_version, trait_)?;
+ doc_impl_item(w, cx, trait_item, link, render_header,
+ false, outer_version, trait_)?;
}
fn render_default_items(w: &mut fmt::Formatter,
@@ -2716,8 +2745,8 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
let did = i.trait_.as_ref().unwrap().def_id().unwrap();
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
- doctraititem(w, cx, trait_item, assoc_link, render_static, true,
- outer_version, None)?;
+ doc_impl_item(w, cx, trait_item, assoc_link, render_static, true,
+ outer_version, None)?;
}
Ok(())
}
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index de0457592fc8..c97cacd10c38 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -284,7 +284,7 @@ h3.impl > .out-of-band {
font-size: 21px;
}
-h4 > code, h3 > code {
+h4 > code, h3 > code, invisible > code {
position: inherit;
}
@@ -292,6 +292,12 @@ h4 > code, h3 > code {
z-index: 5;
}
+.invisible {
+ background: rgba(0, 0, 0, 0);
+ width: 100%;
+ display: inline-block;
+}
+
.content .in-band {
margin: 0px;
padding: 0px;
@@ -660,6 +666,7 @@ span.since {
:target > code {
background: #FDFFD3;
+ opacity: 1;
}
/* Media Queries */
diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css
index aee6d15b7ca3..c64fb1b67f3d 100644
--- a/src/librustdoc/html/static/styles/main.css
+++ b/src/librustdoc/html/static/styles/main.css
@@ -26,7 +26,7 @@ h1.fqn {
h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) {
border-bottom-color: #DDDDDD;
}
-.in-band, code {
+.in-band {
background-color: white;
}
diff --git a/src/test/rustdoc/assoc-types.rs b/src/test/rustdoc/assoc-types.rs
index d5047ade062d..e5485c356c29 100644
--- a/src/test/rustdoc/assoc-types.rs
+++ b/src/test/rustdoc/assoc-types.rs
@@ -13,7 +13,9 @@
// @has assoc_types/trait.Index.html
pub trait Index {
// @has - '//*[@id="associatedtype.Output"]//code' 'type Output: ?Sized'
+ // @has - '//*[@id="Output.t"]//code' 'type Output: ?Sized'
type Output: ?Sized;
+ // @has - '//*[@id="index.v"]//code' 'fn index'
// @has - '//*[@id="tymethod.index"]//code' \
// "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
fn index<'a>(&'a self, index: I) -> &'a Self::Output;
diff --git a/src/test/rustdoc/issue-19190.rs b/src/test/rustdoc/issue-19190.rs
index 6289fcc6fe52..15f7528b4ba2 100644
--- a/src/test/rustdoc/issue-19190.rs
+++ b/src/test/rustdoc/issue-19190.rs
@@ -23,6 +23,9 @@ impl Deref for Bar {
fn deref(&self) -> &Foo { loop {} }
}
+// @has issue_19190/Bar.t.html
// @has issue_19190/struct.Bar.html
+// @has - '//*[@id="foo.v"]' 'fn foo(&self)'
// @has - '//*[@id="method.foo"]' 'fn foo(&self)'
+// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
diff --git a/src/test/rustdoc/issue-21092.rs b/src/test/rustdoc/issue-21092.rs
index ff48c70fc58d..8c5bda7584c9 100644
--- a/src/test/rustdoc/issue-21092.rs
+++ b/src/test/rustdoc/issue-21092.rs
@@ -13,6 +13,7 @@
extern crate issue_21092;
+// @has issue_21092/Bar.t.html
// @has issue_21092/struct.Bar.html
// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32'
pub use issue_21092::{Foo, Bar};
diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs
index 25c97ee2c76a..0b6a8104661a 100644
--- a/src/test/rustdoc/issue-25001.rs
+++ b/src/test/rustdoc/issue-25001.rs
@@ -19,14 +19,17 @@ pub trait Bar {
impl Foo {
// @has - '//*[@id="method.pass"]//code' 'fn pass()'
+ // @has - '//*[@id="pass.v"]//code' 'fn pass()'
pub fn pass() {}
}
impl Foo {
// @has - '//*[@id="method.pass-1"]//code' 'fn pass() -> usize'
+ // @has - '//*[@id="pass.v-1"]//code' 'fn pass() -> usize'
pub fn pass() -> usize { 42 }
}
impl Foo {
// @has - '//*[@id="method.pass-2"]//code' 'fn pass() -> isize'
+ // @has - '//*[@id="pass.v-2"]//code' 'fn pass() -> isize'
pub fn pass() -> isize { 42 }
}
diff --git a/src/test/rustdoc/src-links.rs b/src/test/rustdoc/src-links.rs
index 4d7dad64b47a..e946e2423167 100644
--- a/src/test/rustdoc/src-links.rs
+++ b/src/test/rustdoc/src-links.rs
@@ -24,11 +24,13 @@ pub mod bar {
// @has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html'
pub mod baz {
/// Dox
+ // @has foo/bar/baz/baz.v.html
// @has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html'
pub fn baz() { }
}
/// Dox
+ // @has foo/bar/Foobar.t.html
// @has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html'
pub trait Foobar { fn dummy(&self) { } }
diff --git a/src/test/rustdoc/structfields.rs b/src/test/rustdoc/structfields.rs
index c4327f70728c..c0bfe3ffe3cf 100644
--- a/src/test/rustdoc/structfields.rs
+++ b/src/test/rustdoc/structfields.rs
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// @has structfields/Foo.t.html
+// @has - struct.Foo.html
// @has structfields/struct.Foo.html
pub struct Foo {
// @has - //pre "pub a: ()"
@@ -22,6 +24,8 @@ pub struct Foo {
pub d: usize,
}
+// @has structfields/Bar.t.html
+// @has - struct.Bar.html
// @has structfields/struct.Bar.html
pub struct Bar {
// @has - //pre "pub a: ()"
@@ -29,6 +33,8 @@ pub struct Bar {
// @!has - //pre "// some fields omitted"
}
+// @has structfields/Qux.t.html
+// @has - enum.Qux.html
// @has structfields/enum.Qux.html
pub enum Qux {
Quz {