diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index d41cebc98df3c..e1f43cb20dc38 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -146,6 +146,22 @@ pub enum Breaks { Inconsistent, } +#[derive(Clone, Copy)] +enum IndentStyle { + /// Vertically aligned under whatever column this block begins at. + /// + /// fn demo(arg1: usize, + /// arg2: usize); + Visual, + /// Indented relative to the indentation level of the previous line. + /// + /// fn demo( + /// arg1: usize, + /// arg2: usize, + /// ); + Block { offset: isize }, +} + #[derive(Clone, Copy)] pub struct BreakToken { offset: isize, @@ -154,7 +170,7 @@ pub struct BreakToken { #[derive(Clone, Copy)] pub struct BeginToken { - offset: isize, + indent: IndentStyle, breaks: Breaks, } @@ -178,7 +194,7 @@ impl Token { #[derive(Copy, Clone)] enum PrintFrame { Fits, - Broken { offset: isize, breaks: Breaks }, + Broken { indent: usize, breaks: Breaks }, } const SIZE_INFINITY: isize = 0xffff; @@ -204,6 +220,8 @@ pub struct Printer { scan_stack: VecDeque, /// Stack of blocks-in-progress being flushed by print print_stack: Vec, + /// Level of indentation of current line + indent: usize, /// Buffered indentation to avoid writing trailing whitespace pending_indentation: isize, /// The token most recently popped from the left boundary of the @@ -229,6 +247,7 @@ impl Printer { right_total: 0, scan_stack: VecDeque::new(), print_stack: Vec::new(), + indent: 0, pending_indentation: 0, last_printed: None, } @@ -368,38 +387,41 @@ impl Printer { *self .print_stack .last() - .unwrap_or(&PrintFrame::Broken { offset: 0, breaks: Breaks::Inconsistent }) + .unwrap_or(&PrintFrame::Broken { indent: 0, breaks: Breaks::Inconsistent }) } fn print_begin(&mut self, token: BeginToken, size: isize) { if size > self.space { - let col = self.margin - self.space + token.offset; - self.print_stack.push(PrintFrame::Broken { offset: col, breaks: token.breaks }); + self.print_stack.push(PrintFrame::Broken { indent: self.indent, breaks: token.breaks }); + self.indent = match token.indent { + IndentStyle::Block { offset } => (self.indent as isize + offset) as usize, + IndentStyle::Visual => (self.margin - self.space) as usize, + }; } else { self.print_stack.push(PrintFrame::Fits); } } fn print_end(&mut self) { - self.print_stack.pop().unwrap(); + if let PrintFrame::Broken { indent, .. } = self.print_stack.pop().unwrap() { + self.indent = indent; + } } fn print_break(&mut self, token: BreakToken, size: isize) { - let break_offset = - match self.get_top() { - PrintFrame::Fits => None, - PrintFrame::Broken { offset, breaks: Breaks::Consistent } => Some(offset), - PrintFrame::Broken { offset, breaks: Breaks::Inconsistent } => { - if size > self.space { Some(offset) } else { None } - } - }; - if let Some(offset) = break_offset { - self.out.push('\n'); - self.pending_indentation = offset + token.offset; - self.space = self.margin - (offset + token.offset); - } else { + let fits = match self.get_top() { + PrintFrame::Fits => true, + PrintFrame::Broken { breaks: Breaks::Consistent, .. } => false, + PrintFrame::Broken { breaks: Breaks::Inconsistent, .. } => size <= self.space, + }; + if fits { self.pending_indentation += token.blank_space; self.space -= token.blank_space; + } else { + self.out.push('\n'); + let indent = self.indent as isize + token.offset; + self.pending_indentation = indent; + self.space = self.margin - indent; } } @@ -422,7 +444,10 @@ impl Printer { /// "raw box" pub fn rbox(&mut self, indent: usize, breaks: Breaks) { - self.scan_begin(BeginToken { offset: indent as isize, breaks }) + self.scan_begin(BeginToken { + indent: IndentStyle::Block { offset: indent as isize }, + breaks, + }) } /// Inconsistent breaking box @@ -435,6 +460,10 @@ impl Printer { self.rbox(indent, Breaks::Consistent) } + pub fn visual_align(&mut self) { + self.scan_begin(BeginToken { indent: IndentStyle::Visual, breaks: Breaks::Consistent }); + } + pub fn break_offset(&mut self, n: usize, off: isize) { self.scan_break(BreakToken { offset: off, blank_space: n as isize }) } diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 96dbd3dca156e..b575dc2196133 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -315,7 +315,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere self.word(cmnt.lines[0].clone()); self.hardbreak() } else { - self.ibox(0); + self.visual_align(); for line in &cmnt.lines { if !line.is_empty() { self.word(line.clone()); @@ -655,7 +655,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere // Outer-box is consistent. self.cbox(INDENT_UNIT); // Head-box is inconsistent. - self.ibox(w.len() + 1); + self.ibox(0); // Keyword that starts the head. if !w.is_empty() { self.word_nbsp(w); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 956200d60f507..6a5bba30b8bca 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -320,7 +320,9 @@ impl<'a> State<'a> { self.print_ident(label.ident); self.word_space(":"); } - self.head("while"); + self.cbox(0); + self.ibox(0); + self.word_nbsp("while"); self.print_expr_as_cond(test); self.space(); self.print_block_with_attrs(blk, attrs); @@ -330,7 +332,9 @@ impl<'a> State<'a> { self.print_ident(label.ident); self.word_space(":"); } - self.head("for"); + self.cbox(0); + self.ibox(0); + self.word_nbsp("for"); self.print_pat(pat); self.space(); self.word_space("in"); @@ -343,12 +347,14 @@ impl<'a> State<'a> { self.print_ident(label.ident); self.word_space(":"); } - self.head("loop"); + self.cbox(0); + self.ibox(0); + self.word_nbsp("loop"); self.print_block_with_attrs(blk, attrs); } ast::ExprKind::Match(ref expr, ref arms) => { - self.cbox(INDENT_UNIT); - self.ibox(INDENT_UNIT); + self.cbox(0); + self.ibox(0); self.word_nbsp("match"); self.print_expr_as_cond(expr); self.space(); @@ -388,7 +394,7 @@ impl<'a> State<'a> { self.word_space(":"); } // containing cbox, will be closed by print-block at } - self.cbox(INDENT_UNIT); + self.cbox(0); // head-box, will be closed by print-block after { self.ibox(0); self.print_block_with_attrs(blk, attrs); @@ -397,7 +403,7 @@ impl<'a> State<'a> { self.word_nbsp("async"); self.print_capture_clause(capture_clause); // cbox/ibox in analogy to the `ExprKind::Block` arm above - self.cbox(INDENT_UNIT); + self.cbox(0); self.ibox(0); self.print_block_with_attrs(blk, attrs); } @@ -500,7 +506,9 @@ impl<'a> State<'a> { self.word("?") } ast::ExprKind::TryBlock(ref blk) => { - self.head("try"); + self.cbox(0); + self.ibox(0); + self.word_nbsp("try"); self.print_block_with_attrs(blk, attrs) } ast::ExprKind::Err => { diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index e575d6aa7e2fc..dac84ae9d5fc8 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -1,5 +1,5 @@ use crate::pp::Breaks::Inconsistent; -use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; +use crate::pprust::state::{AnnNode, PrintState, State}; use rustc_ast as ast; use rustc_ast::GenericBound; @@ -377,7 +377,7 @@ impl<'a> State<'a> { self.space_if_not_bol(); self.maybe_print_comment(v.span.lo()); self.print_outer_attributes(&v.attrs); - self.ibox(INDENT_UNIT); + self.ibox(0); self.print_variant(v); self.word(","); self.end(); diff --git a/src/test/pretty/ast-stmt-expr-attr.rs b/src/test/pretty/ast-stmt-expr-attr.rs index e32f5ca24ea0f..2404b32194289 100644 --- a/src/test/pretty/ast-stmt-expr-attr.rs +++ b/src/test/pretty/ast-stmt-expr-attr.rs @@ -28,67 +28,67 @@ fn syntax() { let _ = #[attr] (x as Y); let _ = #[attr] while true { - #![attr] - }; + #![attr] + }; let _ = #[attr] while let Some(false) = true { - #![attr] - }; + #![attr] + }; let _ = #[attr] for x in y { - #![attr] - }; + #![attr] + }; let _ = #[attr] loop { - #![attr] - }; + #![attr] + }; let _ = #[attr] match true { - #![attr] - #[attr] - _ => false, - }; + #![attr] + #[attr] + _ => false, + }; let _ = #[attr] || #[attr] foo; let _ = #[attr] move || #[attr] foo; let _ = #[attr] || - #[attr] { - #![attr] - foo - }; + #[attr] { + #![attr] + foo + }; let _ = #[attr] move || - #[attr] { - #![attr] - foo - }; + #[attr] { + #![attr] + foo + }; let _ = #[attr] || - { - #![attr] - foo - }; + { + #![attr] + foo + }; let _ = #[attr] move || - { - #![attr] - foo - }; + { + #![attr] + foo + }; let _ = #[attr] { - #![attr] - }; + #![attr] + }; let _ = #[attr] { - #![attr] - let _ = (); - }; + #![attr] + let _ = (); + }; let _ = #[attr] { - #![attr] - let _ = (); - foo - }; + #![attr] + let _ = (); + foo + }; let _ = #[attr] x = y; let _ = #[attr] (x = y); let _ = #[attr] x += y; diff --git a/src/test/pretty/block-comment-wchar.pp b/src/test/pretty/block-comment-wchar.pp index 385afa4f33ec1..8c8580b07c218 100644 --- a/src/test/pretty/block-comment-wchar.pp +++ b/src/test/pretty/block-comment-wchar.pp @@ -93,9 +93,9 @@ // Taken from https://www.unicode.org/Public/UNIDATA/PropList.txt let chars = ['\x0A', '\x0B', '\x0C', '\x0D', '\x20', '\u{85}', '\u{A0}', - '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', - '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', - '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}', - '\u{205F}', '\u{3000}']; + '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', + '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', + '\u{2009}', '\u{200A}', '\u{2028}', '\u{2029}', '\u{202F}', + '\u{205F}', '\u{3000}']; for c in &chars { let ws = c.is_whitespace(); println!("{} {}", c, ws); } } diff --git a/src/test/pretty/delimited-token-groups.rs b/src/test/pretty/delimited-token-groups.rs index 1137d80456489..c7c9277faf69e 100644 --- a/src/test/pretty/delimited-token-groups.rs +++ b/src/test/pretty/delimited-token-groups.rs @@ -17,9 +17,9 @@ mac! { mac! { a(aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa - aaaaaaaa aaaaaaaa) a + aaaaaaaa aaaaaaaa) a [aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa - aaaaaaaa aaaaaaaa] a + aaaaaaaa aaaaaaaa] a { aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa @@ -27,22 +27,22 @@ mac! { } mac!(aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa - aaaaaaaa aaaaaaaa); +aaaaaaaa aaaaaaaa); mac![aaaaaaaa aaaaaaaa 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)] +aaaaaaaa aaaaaaaa aaaaaaaa)] #[rustc_dummy[aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa - aaaaaaaa aaaaaaaa aaaaaaaa]] +aaaaaaaa aaaaaaaa aaaaaaaa]] #[rustc_dummy { - aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa - aaaaaaaa aaaaaaaa - }] + aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa + aaaaaaaa aaaaaaaa +}] #[rustc_dummy = - "aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa"] +"aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa"] fn main() {} diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 93967e720c1b0..3830c3aa6c9f1 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -11,15 +11,15 @@ pub fn foo(_: [i32; (3 as usize)]) ({ } as ()) pub fn bar() ({ - const FOO: usize = ((5 as usize) - (4 as usize) as usize); - let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]); + const FOO: usize = ((5 as usize) - (4 as usize) as usize); + let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]); - let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]); + let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]); - let _ = - (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) - as &[i32; 3]) as *const _ as *const [i32; 3]) as - *const [i32; (3 as usize)] as *const [i32; 3]); + let _ = + (((&([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3]) as + &[i32; 3]) as *const _ as *const [i32; 3]) as + *const [i32; (3 as usize)] as *const [i32; 3]); @@ -29,29 +29,19 @@ - ({ - let res = - ((::alloc::fmt::format as - for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1 - as - fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test" - as - &str)] - as - [&str; 1]) - as - &[&str; 1]), - (&([] - as - [ArgumentV1; 0]) - as - &[ArgumentV1; 0])) - as - Arguments)) - as String); - (res as String) - } as String); - } as ()) + ({ + let res = + ((::alloc::fmt::format as + for<'r> fn(Arguments<'r>) -> String {format})(((::core::fmt::Arguments::new_v1 + as + fn(&[&'static str], &[ArgumentV1]) -> Arguments {Arguments::new_v1})((&([("test" + as &str)] as [&str; 1]) as + &[&str; 1]), + (&([] as [ArgumentV1; 0]) as &[ArgumentV1; 0])) as + Arguments)) as String); + (res as String) + } as String); + } as ()) pub type Foo = [i32; (3 as usize)]; pub struct Bar { pub x: [i32; (3 as usize)], @@ -60,19 +50,9 @@ pub enum Baz { BazVariant([i32; (5 as usize)]), } pub fn id(x: T) -> T ({ (x as T) } as T) pub fn use_id() ({ - let _ = - ((id::<[i32; (3 as usize)]> as - fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 - as - i32), - (2 - as - i32), - (3 - as - i32)] - as - [i32; 3])) - as [i32; 3]); - } as ()) + let _ = + ((id::<[i32; (3 as usize)]> as + fn([i32; 3]) -> [i32; 3] {id::<[i32; 3]>})(([(1 as i32), + (2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3]); + } as ()) fn main() ({ } as ()) diff --git a/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs index ed7879001d559..87f525a6178e6 100644 --- a/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs +++ b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs @@ -9,8 +9,8 @@ struct C { #[allow()] const C: C = C{ - #[cfg(debug_assertions)] - field: 0, + #[cfg(debug_assertions)] + field: 0, - #[cfg(not(debug_assertions))] - field: 1,}; + #[cfg(not(debug_assertions))] + field: 1,}; diff --git a/src/test/pretty/macro_rules.rs b/src/test/pretty/macro_rules.rs index fb66e4a775842..01adb14133b35 100644 --- a/src/test/pretty/macro_rules.rs +++ b/src/test/pretty/macro_rules.rs @@ -12,8 +12,8 @@ macro_rules! matcher_brackets { macro_rules! all_fragments { ($b : block, $e : expr, $i : ident, $it : item, $l : lifetime, $lit : - literal, $m : meta, $p : pat, $pth : path, $s : stmt, $tt : tt, $ty : ty, - $vis : vis) => {} ; + literal, $m : meta, $p : pat, $pth : path, $s : stmt, $tt : tt, $ty : ty, + $vis : vis) => {} ; } fn main() {} diff --git a/src/test/pretty/match-naked-expr-medium.rs b/src/test/pretty/match-naked-expr-medium.rs index a124fdff3900d..836af99002d65 100644 --- a/src/test/pretty/match-naked-expr-medium.rs +++ b/src/test/pretty/match-naked-expr-medium.rs @@ -5,10 +5,10 @@ fn main() { let _y = match x { Some(_) => - ["some(_)".to_string(), "not".to_string(), "SO".to_string(), - "long".to_string(), "string".to_string()], + ["some(_)".to_string(), "not".to_string(), "SO".to_string(), + "long".to_string(), "string".to_string()], None => - ["none".to_string(), "a".to_string(), "a".to_string(), - "a".to_string(), "a".to_string()], + ["none".to_string(), "a".to_string(), "a".to_string(), + "a".to_string(), "a".to_string()], }; } diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index 01533cd8107b0..96bde96200af9 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -48,9 +48,9 @@ fn _4() { let _ = #[rustc_dummy] match () { - #![rustc_dummy] - () => (), - }; + #![rustc_dummy] + () => (), + }; } fn _5() { @@ -156,56 +156,56 @@ fn _11() { let _ = #[rustc_dummy] 0 as usize; let _ = #[rustc_dummy] while false { - #![rustc_dummy] - }; + #![rustc_dummy] + }; let _ = #[rustc_dummy] while let None = Some(()) { - #![rustc_dummy] - }; + #![rustc_dummy] + }; let _ = #[rustc_dummy] for _ in 0..0 { - #![rustc_dummy] - }; + #![rustc_dummy] + }; let _ = #[rustc_dummy] loop { - #![rustc_dummy] - }; + #![rustc_dummy] + }; let _ = #[rustc_dummy] match false { - #![rustc_dummy] - _ => (), - }; + #![rustc_dummy] + _ => (), + }; let _ = #[rustc_dummy] || #[rustc_dummy] (); let _ = #[rustc_dummy] move || #[rustc_dummy] (); let _ = #[rustc_dummy] || - { - #![rustc_dummy] - #[rustc_dummy] - () - }; + { + #![rustc_dummy] + #[rustc_dummy] + () + }; let _ = #[rustc_dummy] move || - { - #![rustc_dummy] - #[rustc_dummy] - () - }; + { + #![rustc_dummy] + #[rustc_dummy] + () + }; let _ = #[rustc_dummy] { - #![rustc_dummy] - }; + #![rustc_dummy] + }; let _ = #[rustc_dummy] { - #![rustc_dummy] - let _ = (); - }; + #![rustc_dummy] + let _ = (); + }; let _ = #[rustc_dummy] { - #![rustc_dummy] - let _ = (); - () - }; + #![rustc_dummy] + let _ = (); + () + }; let mut x = 0; let _ = #[rustc_dummy] x = 15; let _ = #[rustc_dummy] x += 15; diff --git a/src/test/pretty/vec-comments.pp b/src/test/pretty/vec-comments.pp index a150cf0b8ea8a..f2f807c59de99 100644 --- a/src/test/pretty/vec-comments.pp +++ b/src/test/pretty/vec-comments.pp @@ -4,26 +4,26 @@ fn main() { let _v1 = [ - // Comment - 0, - // Comment - 1, - // Comment - 2]; + // Comment + 0, + // Comment + 1, + // Comment + 2]; let _v2 = [0, // Comment - 1, // Comment - 2]; // Comment + 1, // Comment + 2]; // Comment let _v3 = [ - /* Comment */ - 0, - /* Comment */ - 1, - /* Comment */ - 2]; + /* Comment */ + 0, + /* Comment */ + 1, + /* Comment */ + 2]; let _v4 = [0, /* Comment */ - 1, /* Comment */ - 2]; /* Comment */ + 1, /* Comment */ + 2]; /* Comment */ } diff --git a/src/test/ui/attributes/key-value-expansion.stderr b/src/test/ui/attributes/key-value-expansion.stderr index 464e1e1cda779..1b7cb76b55366 100644 --- a/src/test/ui/attributes/key-value-expansion.stderr +++ b/src/test/ui/attributes/key-value-expansion.stderr @@ -16,11 +16,11 @@ LL | bug!(); = note: this error originates in the macro `bug` (in Nightly builds, run with -Z macro-backtrace for more info) error: unexpected token: `{ - let res = - ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""], - &[::core::fmt::ArgumentV1::new_display(&"u8")])); - res - }.as_str()` + let res = + ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""], + &[::core::fmt::ArgumentV1::new_display(&"u8")])); + res + }.as_str()` --> $DIR/key-value-expansion.rs:48:23 | LL | doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()} diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout index 99fe9d2e4b3c3..121138605f1a2 100644 --- a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -15,4 +15,4 @@ trait Foo {} fn foo() {} struct Range; + FROM>; diff --git a/src/test/ui/match/issue-82392.stdout b/src/test/ui/match/issue-82392.stdout index 4f46e32dc3070..2054d43c40957 100644 --- a/src/test/ui/match/issue-82392.stdout +++ b/src/test/ui/match/issue-82392.stdout @@ -7,13 +7,11 @@ extern crate std; // check-pass pub fn main() ({ - (if (true as bool) - ({ } as - ()) else if (let Some(a) = - ((Some as - fn(i32) -> Option {Option::::Some})((3 - as - i32)) - as Option) as bool) - ({ } as ()) as ()) - } as ()) + (if (true as bool) + ({ } as + ()) else if (let Some(a) = + ((Some as + fn(i32) -> Option {Option::::Some})((3 + as i32)) as Option) as bool) ({ } as ()) + as ()) + } as ()) diff --git a/src/test/ui/proc-macro/cfg-eval-inner.stdout b/src/test/ui/proc-macro/cfg-eval-inner.stdout index debbad57a8699..9d25def587cd6 100644 --- a/src/test/ui/proc-macro/cfg-eval-inner.stdout +++ b/src/test/ui/proc-macro/cfg-eval-inner.stdout @@ -1,9 +1,9 @@ PRINT-ATTR INPUT (DISPLAY): impl Foo < [u8 ; - { - #! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner - { field : [u8 ; { #! [rustc_dummy(another_cursed_inner)] 1 }] } 0 - }] > { #! [rustc_dummy(evaluated_attr)] fn bar() {} } +{ + #! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner + { field : [u8 ; { #! [rustc_dummy(another_cursed_inner)] 1 }] } 0 +}] > { #! [rustc_dummy(evaluated_attr)] fn bar() {} } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "impl", diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout index fdd178a52292f..c81fa201cbcf5 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -4,23 +4,23 @@ struct Foo < #[cfg(FALSE)] A, B > #[cfg(FALSE)] first : String, #[cfg_attr(FALSE, deny(warnings))] second : bool, third : [u8 ; - { - #[cfg(FALSE)] struct Bar ; #[cfg(not(FALSE))] struct Inner ; - #[cfg(FALSE)] let a = 25 ; match true - { - #[cfg(FALSE)] true => {}, - #[cfg_attr(not(FALSE), allow(warnings))] false => {}, _ => {} - } ; #[print_helper(should_be_removed)] fn removed_fn() - { #! [cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn - kept_fn() { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum - { - Foo(#[cfg(FALSE)] u8, #[cfg(FALSE)] bool, #[cfg(not(FALSE))] i32, - #[cfg(FALSE)] String, u8) - } struct - TupleStruct(#[cfg(FALSE)] String, #[cfg(not(FALSE))] i32, - #[cfg(FALSE)] bool, u8) ; fn plain_removed_fn() - { #! [cfg_attr(not(FALSE), cfg(FALSE))] } 0 - }], #[print_helper(d)] fourth : B + { + #[cfg(FALSE)] struct Bar ; #[cfg(not(FALSE))] struct Inner ; + #[cfg(FALSE)] let a = 25 ; match true + { + #[cfg(FALSE)] true => {}, #[cfg_attr(not(FALSE), allow(warnings))] + false => {}, _ => {} + } ; #[print_helper(should_be_removed)] fn removed_fn() + { #! [cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() + { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum + { + Foo(#[cfg(FALSE)] u8, #[cfg(FALSE)] bool, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] String, u8) + } struct + TupleStruct(#[cfg(FALSE)] String, #[cfg(not(FALSE))] i32, + #[cfg(FALSE)] bool, u8) ; fn plain_removed_fn() + { #! [cfg_attr(not(FALSE), cfg(FALSE))] } 0 + }], #[print_helper(d)] fourth : B } PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { @@ -1276,14 +1276,14 @@ PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_hel { second : bool, third : [u8 ; - { - #[cfg(not(FALSE))] struct Inner ; match true - { #[allow(warnings)] false => {}, _ => {} } ; #[print_helper(c)] - #[cfg(not(FALSE))] fn kept_fn() - { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum - { Foo(#[cfg(not(FALSE))] i32, u8) } struct - TupleStruct(#[cfg(not(FALSE))] i32, u8) ; 0 - }], #[print_helper(d)] fourth : B + { + #[cfg(not(FALSE))] struct Inner ; match true + { #[allow(warnings)] false => {}, _ => {} } ; #[print_helper(c)] + #[cfg(not(FALSE))] fn kept_fn() + { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum + { Foo(#[cfg(not(FALSE))] i32, u8) } struct + TupleStruct(#[cfg(not(FALSE))] i32, u8) ; 0 + }], #[print_helper(d)] fourth : B } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { diff --git a/src/test/ui/proc-macro/macro-rules-derive-cfg.stdout b/src/test/ui/proc-macro/macro-rules-derive-cfg.stdout index 6e2b6a2e5bdf6..74641058ef3d2 100644 --- a/src/test/ui/proc-macro/macro-rules-derive-cfg.stdout +++ b/src/test/ui/proc-macro/macro-rules-derive-cfg.stdout @@ -2,10 +2,10 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo { val : [bool ; - { - let a = #[rustc_dummy(first)] #[rustc_dummy(second)] - { #! [allow(unused)] 30 } ; 0 - }] + { + let a = #[rustc_dummy(first)] #[rustc_dummy(second)] + { #! [allow(unused)] 30 } ; 0 + }] } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { diff --git a/src/test/ui/proc-macro/quote-debug.stdout b/src/test/ui/proc-macro/quote-debug.stdout index 4bdc04b9ac430..79651f01b9534 100644 --- a/src/test/ui/proc-macro/quote-debug.stdout +++ b/src/test/ui/proc-macro/quote-debug.stdout @@ -19,29 +19,27 @@ extern crate proc_macro; fn main() { [crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("let", - crate::Span::recover_proc_macro_span(0)))), - crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("hello", - crate::Span::recover_proc_macro_span(1)))), - crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3d}', - crate::Spacing::Alone))), - crate::TokenStream::from(crate::TokenTree::Literal({ - let mut iter = - "\"world\"".parse::().unwrap().into_iter(); - if let (Some(crate::TokenTree::Literal(mut lit)), - None) = - (iter.next(), - iter.next()) - { - lit.set_span(crate::Span::recover_proc_macro_span(2)); - lit - } else { - { - ::core::panicking::panic("internal error: entered unreachable code") - } - } - })), - crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}', - crate::Spacing::Alone)))].iter().cloned().collect::() + crate::Span::recover_proc_macro_span(0)))), + crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("hello", + crate::Span::recover_proc_macro_span(1)))), + crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3d}', + crate::Spacing::Alone))), + crate::TokenStream::from(crate::TokenTree::Literal({ + let mut iter = + "\"world\"".parse::().unwrap().into_iter(); + if let (Some(crate::TokenTree::Literal(mut lit)), + None) = + (iter.next(), iter.next()) { + lit.set_span(crate::Span::recover_proc_macro_span(2)); + lit + } else { + { + ::core::panicking::panic("internal error: entered unreachable code") + } + } + })), + crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}', + crate::Spacing::Alone)))].iter().cloned().collect::() } const _: () = { diff --git a/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs b/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs index 8800d3e66f9e4..82c4120b4c789 100644 --- a/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs +++ b/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs @@ -37,7 +37,7 @@ checker!(rename_params, r#"impl Foo fn hello(#[angery(true)] a : i32, #[a2] b : i32, #[what = "how"] c : u32) {} fn hello2(#[a1] #[a2] a : i32, #[what = "how"] b : i32, #[angery(true)] c : - u32) {} fn + u32) {} fn hello_self(#[a1] #[a2] & self, #[a1] #[a2] a : i32, #[what = "how"] b : - i32, #[angery(true)] c : u32) {} + i32, #[angery(true)] c : u32) {} }"#); diff --git a/src/test/ui/type-alias-impl-trait/issue-60662.stdout b/src/test/ui/type-alias-impl-trait/issue-60662.stdout index 14a49f20e6b22..a46047d91743d 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60662.stdout +++ b/src/test/ui/type-alias-impl-trait/issue-60662.stdout @@ -10,5 +10,5 @@ extern crate std; trait Animal { } fn main() { - pub type ServeFut = /*impl Trait*/; - } + pub type ServeFut = /*impl Trait*/; + }