Skip to content

Commit abfbd1b

Browse files
committed
Avoid extraneous space between visibility kw and ident for statics
Today, given a static like `static mut FOO: usize = 1`, rustdoc would emit `static mut FOO: usize = 1`, as it emits both the mutability kw with a space and reserves a space after the mutability kw. This patch fixes that misformatting. This patch also adds some tests for emit of other statics, as I could not find an existing test devoted to statics.
1 parent d65c08e commit abfbd1b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ fn item_static(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Static
22892289
render_attributes(w, it, false);
22902290
write!(
22912291
w,
2292-
"{vis}static {mutability} {name}: {typ}</pre>",
2292+
"{vis}static {mutability}{name}: {typ}</pre>",
22932293
vis = it.visibility.print_with_space(),
22942294
mutability = s.mutability.print_with_space(),
22952295
name = it.name.as_ref().unwrap(),

src/test/rustdoc/static.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags: --document-private-items
2+
3+
#![crate_type = "lib"]
4+
5+
// @has static/static.FOO.html '//pre[@class="static"]' 'static FOO: usize'
6+
static FOO: usize = 1;
7+
8+
// @has static/static.BAR.html '//pre[@class="static"]' 'pub static BAR: usize'
9+
pub static BAR: usize = 1;
10+
11+
// @has static/static.BAZ.html '//pre[@class="static"]' 'pub static mut BAZ: usize'
12+
pub static mut BAZ: usize = 1;

0 commit comments

Comments
 (0)