Rollup merge of #92414 - dtolnay:constnoexpr, r=oli-obk
Fix spacing of pretty printed const item without body Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{}", repro!(extern "C" { static S: i32; })); } ``` Before: `extern "C" { static S: i32 ; }` After: `extern "C" { static S: i32; }`
This commit is contained in:
commit
e810487b4d
3 changed files with 16 additions and 14 deletions
|
@ -1116,7 +1116,9 @@ impl<'a> State<'a> {
|
||||||
self.print_ident(ident);
|
self.print_ident(ident);
|
||||||
self.word_space(":");
|
self.word_space(":");
|
||||||
self.print_type(ty);
|
self.print_type(ty);
|
||||||
self.space();
|
if body.is_some() {
|
||||||
|
self.space();
|
||||||
|
}
|
||||||
self.end(); // end the head-ibox
|
self.end(); // end the head-ibox
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
self.word_space("=");
|
self.word_space("=");
|
||||||
|
|
|
@ -6,42 +6,42 @@ fn main() {}
|
||||||
|
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static X: u8 ;
|
static X: u8;
|
||||||
type X;
|
type X;
|
||||||
fn foo();
|
fn foo();
|
||||||
pub static X: u8 ;
|
pub static X: u8;
|
||||||
pub type X;
|
pub type X;
|
||||||
pub fn foo();
|
pub fn foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
trait T {
|
trait T {
|
||||||
const X: u8 ;
|
const X: u8;
|
||||||
type X;
|
type X;
|
||||||
fn foo();
|
fn foo();
|
||||||
default const X: u8 ;
|
default const X: u8;
|
||||||
default type X;
|
default type X;
|
||||||
default fn foo();
|
default fn foo();
|
||||||
pub const X: u8 ;
|
pub const X: u8;
|
||||||
pub type X;
|
pub type X;
|
||||||
pub fn foo();
|
pub fn foo();
|
||||||
pub default const X: u8 ;
|
pub default const X: u8;
|
||||||
pub default type X;
|
pub default type X;
|
||||||
pub default fn foo();
|
pub default fn foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(FALSE)]
|
#[cfg(FALSE)]
|
||||||
impl T for S {
|
impl T for S {
|
||||||
const X: u8 ;
|
const X: u8;
|
||||||
type X;
|
type X;
|
||||||
fn foo();
|
fn foo();
|
||||||
default const X: u8 ;
|
default const X: u8;
|
||||||
default type X;
|
default type X;
|
||||||
default fn foo();
|
default fn foo();
|
||||||
pub const X: u8 ;
|
pub const X: u8;
|
||||||
pub type X;
|
pub type X;
|
||||||
pub fn foo();
|
pub fn foo();
|
||||||
pub default const X: u8 ;
|
pub default const X: u8;
|
||||||
pub default type X;
|
pub default type X;
|
||||||
pub default fn foo();
|
pub default fn foo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,13 +382,13 @@ fn test_item() {
|
||||||
stringify_item!(
|
stringify_item!(
|
||||||
static S: ();
|
static S: ();
|
||||||
),
|
),
|
||||||
"static S: () ;", // FIXME
|
"static S: ();",
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
stringify_item!(
|
stringify_item!(
|
||||||
static mut S: ();
|
static mut S: ();
|
||||||
),
|
),
|
||||||
"static mut S: () ;",
|
"static mut S: ();",
|
||||||
);
|
);
|
||||||
|
|
||||||
// ItemKind::Const
|
// ItemKind::Const
|
||||||
|
@ -402,7 +402,7 @@ fn test_item() {
|
||||||
stringify_item!(
|
stringify_item!(
|
||||||
const S: ();
|
const S: ();
|
||||||
),
|
),
|
||||||
"const S: () ;", // FIXME
|
"const S: ();",
|
||||||
);
|
);
|
||||||
|
|
||||||
// ItemKind::Fn
|
// ItemKind::Fn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue