mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 19:43:24 +00:00
pprust: Fix formatting regressions from the previous commits
Fix some remaining cases of bad formatting Update some failing tests
This commit is contained in:
parent
75896011dc
commit
a2a1cd1864
@ -1328,7 +1328,7 @@ mod tests {
|
||||
matches_codepattern,
|
||||
"matches_codepattern",
|
||||
pprust::to_string(|s| fake_print_crate(s, &krate)),
|
||||
"macro_rules! zz((zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+)));".to_string());
|
||||
"macro_rules! zz{(zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+))}".to_string());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -714,6 +714,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
|
||||
convert_dollar_crate: bool,
|
||||
span: Span,
|
||||
) {
|
||||
if delim == DelimToken::Brace {
|
||||
self.cbox(INDENT_UNIT);
|
||||
}
|
||||
if let Some(path) = path {
|
||||
self.print_path(path, false, 0);
|
||||
}
|
||||
@ -721,27 +724,27 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
|
||||
self.word("!");
|
||||
}
|
||||
if let Some(ident) = ident {
|
||||
self.space();
|
||||
self.nbsp();
|
||||
self.print_ident(ident);
|
||||
self.space();
|
||||
}
|
||||
match delim {
|
||||
DelimToken::Paren => self.popen(),
|
||||
DelimToken::Bracket => self.word("["),
|
||||
DelimToken::NoDelim => self.word(" "),
|
||||
DelimToken::Brace => {
|
||||
self.head("");
|
||||
self.bopen();
|
||||
if path.is_some() || has_bang || ident.is_some() {
|
||||
self.nbsp();
|
||||
}
|
||||
self.word("{");
|
||||
if !tts.is_empty() {
|
||||
self.space();
|
||||
}
|
||||
}
|
||||
_ => self.word(token_kind_to_string(&token::OpenDelim(delim))),
|
||||
}
|
||||
self.ibox(0);
|
||||
self.print_tts(tts, convert_dollar_crate);
|
||||
self.end();
|
||||
match delim {
|
||||
DelimToken::Paren => self.pclose(),
|
||||
DelimToken::Bracket => self.word("]"),
|
||||
DelimToken::NoDelim => self.word(" "),
|
||||
DelimToken::Brace => self.bclose(span),
|
||||
_ => self.word(token_kind_to_string(&token::CloseDelim(delim))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,6 @@ extern crate std;
|
||||
// pretty-mode:expanded
|
||||
// pp-exact:cast-lt.pp
|
||||
|
||||
macro_rules! negative {($ e : expr) => {$ e < 0 } }
|
||||
macro_rules! negative { ($ e : expr) => { $ e < 0 } }
|
||||
|
||||
fn main() { (1 as i32) < 0; }
|
||||
|
49
src/test/pretty/delimited-token-groups.rs
Normal file
49
src/test/pretty/delimited-token-groups.rs
Normal file
@ -0,0 +1,49 @@
|
||||
// pp-exact
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
macro_rules! mac { ($ ($ tt : tt) *) => () }
|
||||
|
||||
mac! {
|
||||
struct S { field1 : u8 , field2 : u16 , } impl Clone for S
|
||||
{
|
||||
fn clone () -> S
|
||||
{
|
||||
panic ! () ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mac! {
|
||||
a
|
||||
(aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa) a
|
||||
[aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa] a
|
||||
{
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
} a
|
||||
}
|
||||
|
||||
mac!(aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa);
|
||||
mac![aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa];
|
||||
mac! {
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa
|
||||
}
|
||||
|
||||
#[rustc_dummy(aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa)]
|
||||
#[rustc_dummy[aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa]]
|
||||
#[rustc_dummy {
|
||||
aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa
|
||||
aaaaaaaa aaaaaaaa
|
||||
}]
|
||||
#[rustc_dummy =
|
||||
"aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa"]
|
||||
fn main() { }
|
@ -5,4 +5,4 @@
|
||||
// pretty-compare-only
|
||||
// pp-exact
|
||||
|
||||
fn main() { b!{ } c }
|
||||
fn main() { b! { } c }
|
||||
|
@ -111,31 +111,29 @@ fn _8() {
|
||||
}
|
||||
|
||||
fn _9() {
|
||||
macro_rules!
|
||||
stmt_mac
|
||||
{() => {let _ = () ; } }
|
||||
macro_rules! stmt_mac { () => { let _ = () ; } }
|
||||
|
||||
#[rustc_dummy]
|
||||
stmt_mac!();
|
||||
|
||||
#[rustc_dummy]
|
||||
stmt_mac!{ };
|
||||
stmt_mac! { };
|
||||
|
||||
#[rustc_dummy]
|
||||
stmt_mac![];
|
||||
|
||||
#[rustc_dummy]
|
||||
stmt_mac!{ }
|
||||
stmt_mac! { }
|
||||
|
||||
let _ = ();
|
||||
}
|
||||
|
||||
macro_rules! expr_mac {() => {() } }
|
||||
macro_rules! expr_mac { () => { () } }
|
||||
|
||||
fn _10() {
|
||||
let _ = #[rustc_dummy] expr_mac!();
|
||||
let _ = #[rustc_dummy] expr_mac![];
|
||||
let _ = #[rustc_dummy] expr_mac!{ };
|
||||
let _ = #[rustc_dummy] expr_mac! { };
|
||||
}
|
||||
|
||||
fn _11() {
|
||||
@ -238,7 +236,7 @@ fn _11() {
|
||||
|| #[rustc_dummy] return;
|
||||
let _ = #[rustc_dummy] expr_mac!();
|
||||
let _ = #[rustc_dummy] expr_mac![];
|
||||
let _ = #[rustc_dummy] expr_mac!{ };
|
||||
let _ = #[rustc_dummy] expr_mac! { };
|
||||
let _ = #[rustc_dummy] Foo{#![rustc_dummy] data: (),};
|
||||
let _ = #[rustc_dummy] Foo{#![rustc_dummy] ..s};
|
||||
let _ = #[rustc_dummy] Foo{#![rustc_dummy] data: (), ..s};
|
||||
|
@ -1,9 +1,9 @@
|
||||
// minimal junk
|
||||
#![feature(no_core)]
|
||||
#![no_core]
|
||||
#![feature /* 0#0 */(no_core)]
|
||||
#![no_core /* 0#0 */]
|
||||
|
||||
macro_rules! foo /* 60#0 */(( $ x : ident ) => { y + $ x });
|
||||
macro_rules /* 0#0 */! foo /* 0#0 */ { ($ x : ident) => { y + $ x } }
|
||||
|
||||
fn bar /* 62#0 */() { let x /* 59#2 */ = 1; y /* 61#4 */ + x /* 59#5 */ }
|
||||
fn bar /* 0#0 */() { let x /* 0#0 */ = 1; y /* 0#1 */ + x /* 0#0 */ }
|
||||
|
||||
fn y /* 61#0 */() { }
|
||||
fn y /* 0#0 */() { }
|
||||
|
@ -18,7 +18,7 @@ pub fn main() {
|
||||
assert_eq!(column!(), 16);
|
||||
assert_eq!(indirect_line!(), 19);
|
||||
assert!((file!().ends_with("syntax-extension-source-utils.rs")));
|
||||
assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string());
|
||||
assert_eq!(stringify!((2*3) + 5).to_string(), "(2 * 3) + 5".to_string());
|
||||
assert!(include!("syntax-extension-source-utils-files/includeme.\
|
||||
fragment").to_string()
|
||||
== "victory robot 6".to_string());
|
||||
@ -33,5 +33,5 @@ pub fn main() {
|
||||
// The Windows tests are wrapped in an extra module for some reason
|
||||
assert!((m1::m2::where_am_i().ends_with("m1::m2")));
|
||||
|
||||
assert_eq!((36, "( 2 * 3 ) + 5"), (line!(), stringify!((2*3) + 5)));
|
||||
assert_eq!((36, "(2 * 3) + 5"), (line!(), stringify!((2*3) + 5)));
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ LL | ping!();
|
||||
|
|
||||
::: <::ping::ping macros>:1:1
|
||||
|
|
||||
LL | () => {pong ! () ; }
|
||||
| --------------------
|
||||
| | |
|
||||
| | in this macro invocation
|
||||
LL | () => { pong ! () ; }
|
||||
| ---------------------
|
||||
| | |
|
||||
| | in this macro invocation
|
||||
| in this expansion of `ping!`
|
||||
|
||||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
|
||||
@ -44,34 +44,34 @@ LL | deep!();
|
||||
|
|
||||
::: <::ping::deep macros>:1:1
|
||||
|
|
||||
LL | () => {foo ! () ; }
|
||||
| -------------------
|
||||
| | |
|
||||
| | in this macro invocation (#2)
|
||||
LL | () => { foo ! () ; }
|
||||
| --------------------
|
||||
| | |
|
||||
| | in this macro invocation (#2)
|
||||
| in this expansion of `deep!` (#1)
|
||||
|
|
||||
::: <::ping::foo macros>:1:1
|
||||
|
|
||||
LL | () => {bar ! () ; }
|
||||
| -------------------
|
||||
| | |
|
||||
| | in this macro invocation (#3)
|
||||
LL | () => { bar ! () ; }
|
||||
| --------------------
|
||||
| | |
|
||||
| | in this macro invocation (#3)
|
||||
| in this expansion of `foo!` (#2)
|
||||
|
|
||||
::: <::ping::bar macros>:1:1
|
||||
|
|
||||
LL | () => {ping ! () ; }
|
||||
| --------------------
|
||||
| | |
|
||||
| | in this macro invocation (#4)
|
||||
LL | () => { ping ! () ; }
|
||||
| ---------------------
|
||||
| | |
|
||||
| | in this macro invocation (#4)
|
||||
| in this expansion of `bar!` (#3)
|
||||
|
|
||||
::: <::ping::ping macros>:1:1
|
||||
|
|
||||
LL | () => {pong ! () ; }
|
||||
| --------------------
|
||||
| | |
|
||||
| | in this macro invocation (#5)
|
||||
LL | () => { pong ! () ; }
|
||||
| ---------------------
|
||||
| | |
|
||||
| | in this macro invocation (#5)
|
||||
| in this expansion of `ping!` (#4)
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -5,5 +5,5 @@ LL | println!("Hello, World!");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expanding `println! { "Hello, World!" }`
|
||||
= note: to `{$crate :: io :: _print (format_args_nl ! ("Hello, World!")) ; }`
|
||||
= note: to `{ $crate :: io :: _print (format_args_nl ! ("Hello, World!")) ; }`
|
||||
|
||||
|
@ -1 +1 @@
|
||||
fn main () {let y : u32 = "z" ; {let x : u32 = "y" ; } }
|
||||
fn main () { let y : u32 = "z" ; { let x : u32 = "y" ; } }
|
||||
|
Loading…
Reference in New Issue
Block a user