diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 32e4a829184..0b6faa4b13e 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1676,11 +1676,12 @@ fn render_rightside( containing_item.stable_since(tcx), const_stable_since, ); - if has_stability { + let mut tmp_buf = Buffer::empty_from(w); + write_srclink(cx, item, &mut tmp_buf); + if has_stability && !tmp_buf.is_empty() { w.write_str(" · "); } - - write_srclink(cx, item, w); + w.push_buffer(tmp_buf); w.write_str(""); } diff --git a/src/test/rustdoc/version-separator-without-source.rs b/src/test/rustdoc/version-separator-without-source.rs new file mode 100644 index 00000000000..bffe5030a84 --- /dev/null +++ b/src/test/rustdoc/version-separator-without-source.rs @@ -0,0 +1,23 @@ +#![doc(html_no_source)] +#![feature(staged_api)] +#![stable(feature = "bar", since = "1.0")] +#![crate_name = "foo"] + +// @has foo/fn.foo.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub fn foo() {} + +// @has foo/struct.Bar.html +// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · ' +// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · ' +#[stable(feature = "bar", since = "1.0")] +pub struct Bar; + +impl Bar { + // @has - '//div[@id="method.bar"]/*[@class="rightside"]' '2.0' + // @!has - '//div[@id="method.bar"]/*[@class="rightside"]' '2.0 ·' + #[stable(feature = "foobar", since = "2.0")] + pub fn bar() {} +}