diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index f0c1d017326cd..0d5ce07c6ca11 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1116,7 +1116,9 @@ impl<'a> State<'a> { self.print_ident(ident); self.word_space(":"); self.print_type(ty); - self.space(); + if body.is_some() { + self.space(); + } self.end(); // end the head-ibox if let Some(body) = body { self.word_space("="); diff --git a/src/test/pretty/nested-item-vis-defaultness.rs b/src/test/pretty/nested-item-vis-defaultness.rs index f46c0e3f1bc62..b094ba577db2d 100644 --- a/src/test/pretty/nested-item-vis-defaultness.rs +++ b/src/test/pretty/nested-item-vis-defaultness.rs @@ -6,42 +6,42 @@ fn main() {} #[cfg(FALSE)] extern "C" { - static X: u8 ; + static X: u8; type X; fn foo(); - pub static X: u8 ; + pub static X: u8; pub type X; pub fn foo(); } #[cfg(FALSE)] trait T { - const X: u8 ; + const X: u8; type X; fn foo(); - default const X: u8 ; + default const X: u8; default type X; default fn foo(); - pub const X: u8 ; + pub const X: u8; pub type X; pub fn foo(); - pub default const X: u8 ; + pub default const X: u8; pub default type X; pub default fn foo(); } #[cfg(FALSE)] impl T for S { - const X: u8 ; + const X: u8; type X; fn foo(); - default const X: u8 ; + default const X: u8; default type X; default fn foo(); - pub const X: u8 ; + pub const X: u8; pub type X; pub fn foo(); - pub default const X: u8 ; + pub default const X: u8; pub default type X; pub default fn foo(); } diff --git a/src/test/ui/macros/stringify.rs b/src/test/ui/macros/stringify.rs index 90bc7dc1da239..7d1c05a85bcf5 100644 --- a/src/test/ui/macros/stringify.rs +++ b/src/test/ui/macros/stringify.rs @@ -382,13 +382,13 @@ fn test_item() { stringify_item!( static S: (); ), - "static S: () ;", // FIXME + "static S: ();", ); assert_eq!( stringify_item!( static mut S: (); ), - "static mut S: () ;", + "static mut S: ();", ); // ItemKind::Const @@ -402,7 +402,7 @@ fn test_item() { stringify_item!( const S: (); ), - "const S: () ;", // FIXME + "const S: ();", ); // ItemKind::Fn