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
11 changed files with 100 additions and 50 deletions
|
@ -1328,7 +1328,7 @@ mod tests {
|
||||||
matches_codepattern,
|
matches_codepattern,
|
||||||
"matches_codepattern",
|
"matches_codepattern",
|
||||||
pprust::to_string(|s| fake_print_crate(s, &krate)),
|
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,
|
convert_dollar_crate: bool,
|
||||||
span: Span,
|
span: Span,
|
||||||
) {
|
) {
|
||||||
|
if delim == DelimToken::Brace {
|
||||||
|
self.cbox(INDENT_UNIT);
|
||||||
|
}
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
self.print_path(path, false, 0);
|
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("!");
|
self.word("!");
|
||||||
}
|
}
|
||||||
if let Some(ident) = ident {
|
if let Some(ident) = ident {
|
||||||
self.space();
|
self.nbsp();
|
||||||
self.print_ident(ident);
|
self.print_ident(ident);
|
||||||
self.space();
|
|
||||||
}
|
}
|
||||||
match delim {
|
match delim {
|
||||||
DelimToken::Paren => self.popen(),
|
|
||||||
DelimToken::Bracket => self.word("["),
|
|
||||||
DelimToken::NoDelim => self.word(" "),
|
|
||||||
DelimToken::Brace => {
|
DelimToken::Brace => {
|
||||||
self.head("");
|
if path.is_some() || has_bang || ident.is_some() {
|
||||||
self.bopen();
|
self.nbsp();
|
||||||
}
|
}
|
||||||
|
self.word("{");
|
||||||
|
if !tts.is_empty() {
|
||||||
|
self.space();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => self.word(token_kind_to_string(&token::OpenDelim(delim))),
|
||||||
}
|
}
|
||||||
self.ibox(0);
|
self.ibox(0);
|
||||||
self.print_tts(tts, convert_dollar_crate);
|
self.print_tts(tts, convert_dollar_crate);
|
||||||
self.end();
|
self.end();
|
||||||
match delim {
|
match delim {
|
||||||
DelimToken::Paren => self.pclose(),
|
|
||||||
DelimToken::Bracket => self.word("]"),
|
|
||||||
DelimToken::NoDelim => self.word(" "),
|
|
||||||
DelimToken::Brace => self.bclose(span),
|
DelimToken::Brace => self.bclose(span),
|
||||||
|
_ => self.word(token_kind_to_string(&token::CloseDelim(delim))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
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() { }
|
|
@ -111,9 +111,7 @@ fn _8() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _9() {
|
fn _9() {
|
||||||
macro_rules!
|
macro_rules! stmt_mac { () => { let _ = () ; } }
|
||||||
stmt_mac
|
|
||||||
{() => {let _ = () ; } }
|
|
||||||
|
|
||||||
#[rustc_dummy]
|
#[rustc_dummy]
|
||||||
stmt_mac!();
|
stmt_mac!();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// minimal junk
|
// minimal junk
|
||||||
#![feature(no_core)]
|
#![feature /* 0#0 */(no_core)]
|
||||||
#![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 */() { }
|
||||||
|
|
|
@ -25,7 +25,7 @@ LL | ping!();
|
||||||
::: <::ping::ping macros>:1:1
|
::: <::ping::ping macros>:1:1
|
||||||
|
|
|
|
||||||
LL | () => { pong ! () ; }
|
LL | () => { pong ! () ; }
|
||||||
| --------------------
|
| ---------------------
|
||||||
| | |
|
| | |
|
||||||
| | in this macro invocation
|
| | in this macro invocation
|
||||||
| in this expansion of `ping!`
|
| in this expansion of `ping!`
|
||||||
|
@ -45,7 +45,7 @@ LL | deep!();
|
||||||
::: <::ping::deep macros>:1:1
|
::: <::ping::deep macros>:1:1
|
||||||
|
|
|
|
||||||
LL | () => { foo ! () ; }
|
LL | () => { foo ! () ; }
|
||||||
| -------------------
|
| --------------------
|
||||||
| | |
|
| | |
|
||||||
| | in this macro invocation (#2)
|
| | in this macro invocation (#2)
|
||||||
| in this expansion of `deep!` (#1)
|
| in this expansion of `deep!` (#1)
|
||||||
|
@ -53,7 +53,7 @@ LL | () => {foo ! () ; }
|
||||||
::: <::ping::foo macros>:1:1
|
::: <::ping::foo macros>:1:1
|
||||||
|
|
|
|
||||||
LL | () => { bar ! () ; }
|
LL | () => { bar ! () ; }
|
||||||
| -------------------
|
| --------------------
|
||||||
| | |
|
| | |
|
||||||
| | in this macro invocation (#3)
|
| | in this macro invocation (#3)
|
||||||
| in this expansion of `foo!` (#2)
|
| in this expansion of `foo!` (#2)
|
||||||
|
@ -61,7 +61,7 @@ LL | () => {bar ! () ; }
|
||||||
::: <::ping::bar macros>:1:1
|
::: <::ping::bar macros>:1:1
|
||||||
|
|
|
|
||||||
LL | () => { ping ! () ; }
|
LL | () => { ping ! () ; }
|
||||||
| --------------------
|
| ---------------------
|
||||||
| | |
|
| | |
|
||||||
| | in this macro invocation (#4)
|
| | in this macro invocation (#4)
|
||||||
| in this expansion of `bar!` (#3)
|
| in this expansion of `bar!` (#3)
|
||||||
|
@ -69,7 +69,7 @@ LL | () => {ping ! () ; }
|
||||||
::: <::ping::ping macros>:1:1
|
::: <::ping::ping macros>:1:1
|
||||||
|
|
|
|
||||||
LL | () => { pong ! () ; }
|
LL | () => { pong ! () ; }
|
||||||
| --------------------
|
| ---------------------
|
||||||
| | |
|
| | |
|
||||||
| | in this macro invocation (#5)
|
| | in this macro invocation (#5)
|
||||||
| in this expansion of `ping!` (#4)
|
| in this expansion of `ping!` (#4)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue