Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spacing of pretty printed const item without body #92414

Merged
merged 2 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("=");
Expand Down
20 changes: 10 additions & 10 deletions src/test/pretty/nested-item-vis-defaultness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
6 changes: 3 additions & 3 deletions src/test/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -402,7 +402,7 @@ fn test_item() {
stringify_item!(
const S: ();
),
"const S: () ;", // FIXME
"const S: ();",
);

// ItemKind::Fn
Expand Down