Skip to content

Commit 2f6a53f

Browse files
authored
Rollup merge of rust-lang#77920 - ayazhafiz:i/mut-ident-spacing, r=jyn514
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.
2 parents 23aff01 + e60072f commit 2f6a53f

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
@@ -2384,7 +2384,7 @@ fn item_static(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Static
23842384
render_attributes(w, it, false);
23852385
write!(
23862386
w,
2387-
"{vis}static {mutability} {name}: {typ}</pre>",
2387+
"{vis}static {mutability}{name}: {typ}</pre>",
23882388
vis = it.visibility.print_with_space(),
23892389
mutability = s.mutability.print_with_space(),
23902390
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' 'static FOO: usize'
6+
static FOO: usize = 1;
7+
8+
// @has static/static.BAR.html '//pre' 'pub static BAR: usize'
9+
pub static BAR: usize = 1;
10+
11+
// @has static/static.BAZ.html '//pre' 'pub static mut BAZ: usize'
12+
pub static mut BAZ: usize = 1;

0 commit comments

Comments
 (0)