Skip to content

Commit

Permalink
Rollup merge of rust-lang#93299 - GuillaumeGomez:dot-separator-no-sou…
Browse files Browse the repository at this point in the history
…rce, r=jsha

Fix dot separator when there is no source link

Fixes rust-lang#92973.

We did well adding this test since there was a bug:

![Screenshot from 2022-01-25 17-05-48](https://user-images.githubusercontent.com/3050060/151016535-39b45f52-e1e0-4963-ad19-532e24ec4c9b.png)

r? `@jsha`
  • Loading branch information
matthiaskrgr committed Jan 29, 2022
2 parents 37e9cb3 + 066fcb6 commit f5f2d44
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("</div>");
}

Expand Down
23 changes: 23 additions & 0 deletions src/test/rustdoc/version-separator-without-source.rs
Original file line number Diff line number Diff line change
@@ -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() {}
}

0 comments on commit f5f2d44

Please sign in to comment.