Skip to content

Commit

Permalink
Rollup merge of #77920 - ayazhafiz:i/mut-ident-spacing, r=jyn514
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnTitor committed Oct 23, 2020
2 parents b968738 + e60072f commit 4704259
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ fn item_static(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Static
render_attributes(w, it, false);
write!(
w,
"{vis}static {mutability} {name}: {typ}</pre>",
"{vis}static {mutability}{name}: {typ}</pre>",
vis = it.visibility.print_with_space(),
mutability = s.mutability.print_with_space(),
name = it.name.as_ref().unwrap(),
Expand Down
12 changes: 12 additions & 0 deletions src/test/rustdoc/static.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags: --document-private-items

#![crate_type = "lib"]

// @has static/static.FOO.html '//pre' 'static FOO: usize'
static FOO: usize = 1;

// @has static/static.BAR.html '//pre' 'pub static BAR: usize'
pub static BAR: usize = 1;

// @has static/static.BAZ.html '//pre' 'pub static mut BAZ: usize'
pub static mut BAZ: usize = 1;

0 comments on commit 4704259

Please sign in to comment.