Skip to content

Commit b7df498

Browse files
committed
Fix spacing of pretty printed const item without body
1 parent 2b67c30 commit b7df498

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1116,9 +1116,9 @@ impl<'a> State<'a> {
11161116
self.print_ident(ident);
11171117
self.word_space(":");
11181118
self.print_type(ty);
1119-
self.space();
11201119
self.end(); // end the head-ibox
11211120
if let Some(body) = body {
1121+
self.space();
11221122
self.word_space("=");
11231123
self.print_expr(body);
11241124
}

Diff for: src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ struct C {
77
}
88

99
#[allow()]
10-
const C: C =
10+
const C: C
11+
=
1112
C{
1213
#[cfg(debug_assertions)]
1314
field: 0,

Diff for: src/test/pretty/nested-item-vis-defaultness.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,42 @@ fn main() {}
66

77
#[cfg(FALSE)]
88
extern "C" {
9-
static X: u8 ;
9+
static X: u8;
1010
type X;
1111
fn foo();
12-
pub static X: u8 ;
12+
pub static X: u8;
1313
pub type X;
1414
pub fn foo();
1515
}
1616

1717
#[cfg(FALSE)]
1818
trait T {
19-
const X: u8 ;
19+
const X: u8;
2020
type X;
2121
fn foo();
22-
default const X: u8 ;
22+
default const X: u8;
2323
default type X;
2424
default fn foo();
25-
pub const X: u8 ;
25+
pub const X: u8;
2626
pub type X;
2727
pub fn foo();
28-
pub default const X: u8 ;
28+
pub default const X: u8;
2929
pub default type X;
3030
pub default fn foo();
3131
}
3232

3333
#[cfg(FALSE)]
3434
impl T for S {
35-
const X: u8 ;
35+
const X: u8;
3636
type X;
3737
fn foo();
38-
default const X: u8 ;
38+
default const X: u8;
3939
default type X;
4040
default fn foo();
41-
pub const X: u8 ;
41+
pub const X: u8;
4242
pub type X;
4343
pub fn foo();
44-
pub default const X: u8 ;
44+
pub default const X: u8;
4545
pub default type X;
4646
pub default fn foo();
4747
}

Diff for: src/test/ui/macros/stringify.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ fn test_item() {
382382
stringify_item!(
383383
static S: ();
384384
),
385-
"static S: () ;", // FIXME
385+
"static S: ();",
386386
);
387387
assert_eq!(
388388
stringify_item!(
389389
static mut S: ();
390390
),
391-
"static mut S: () ;",
391+
"static mut S: ();",
392392
);
393393

394394
// ItemKind::Const
@@ -402,7 +402,7 @@ fn test_item() {
402402
stringify_item!(
403403
const S: ();
404404
),
405-
"const S: () ;", // FIXME
405+
"const S: ();",
406406
);
407407

408408
// ItemKind::Fn

Diff for: src/test/ui/proc-macro/quote-debug.stdout

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ fn main() {
4343
crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}',
4444
crate::Spacing::Alone)))].iter().cloned().collect::<crate::TokenStream>()
4545
}
46-
const _: () =
46+
const _: ()
47+
=
4748
{
4849
extern crate proc_macro;
4950
#[rustc_proc_macro_decls]

0 commit comments

Comments
 (0)