Skip to content

Commit f5f2d44

Browse files
authored
Rollup merge of #93299 - GuillaumeGomez:dot-separator-no-source, r=jsha
Fix dot separator when there is no source link Fixes #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`
2 parents 37e9cb3 + 066fcb6 commit f5f2d44

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/librustdoc/html/render/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1676,11 +1676,12 @@ fn render_rightside(
16761676
containing_item.stable_since(tcx),
16771677
const_stable_since,
16781678
);
1679-
if has_stability {
1679+
let mut tmp_buf = Buffer::empty_from(w);
1680+
write_srclink(cx, item, &mut tmp_buf);
1681+
if has_stability && !tmp_buf.is_empty() {
16801682
w.write_str(" · ");
16811683
}
1682-
1683-
write_srclink(cx, item, w);
1684+
w.push_buffer(tmp_buf);
16841685
w.write_str("</div>");
16851686
}
16861687

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![doc(html_no_source)]
2+
#![feature(staged_api)]
3+
#![stable(feature = "bar", since = "1.0")]
4+
#![crate_name = "foo"]
5+
6+
// @has foo/fn.foo.html
7+
// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · '
8+
// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · '
9+
#[stable(feature = "bar", since = "1.0")]
10+
pub fn foo() {}
11+
12+
// @has foo/struct.Bar.html
13+
// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · '
14+
// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0 · source · '
15+
#[stable(feature = "bar", since = "1.0")]
16+
pub struct Bar;
17+
18+
impl Bar {
19+
// @has - '//div[@id="method.bar"]/*[@class="rightside"]' '2.0'
20+
// @!has - '//div[@id="method.bar"]/*[@class="rightside"]' '2.0 ·'
21+
#[stable(feature = "foobar", since = "2.0")]
22+
pub fn bar() {}
23+
}

0 commit comments

Comments
 (0)