Rollup merge of #91437 - dtolnay:emptybrace, r=nagisa
Pretty print empty blocks as {} **Example:** ```rust macro_rules! p { ($e:expr) => { println!("{}", stringify!($e)); }; ($i:item) => { println!("{}", stringify!($i)); }; } fn main() { p!(if true {}); p!(struct S {}); } ``` **Before:** ```console if true { } struct S { } ``` **After:** ```console if true {} struct S {} ``` This affects [`dbg!`](https://doc.rust-lang.org/std/macro.dbg.html), as well as ecosystem uses of stringify such as in [`anyhow::ensure!`](https://docs.rs/anyhow/1/anyhow/macro.ensure.html). Printing a `{ }` in today's heavily rustfmt'd world comes out looking jarring/sloppy.
This commit is contained in:
commit
a8f8f746fc
63 changed files with 182 additions and 164 deletions
|
@ -2174,7 +2174,7 @@ impl<'a> State<'a> {
|
|||
match decl.output {
|
||||
hir::FnRetTy::Return(ref ty) => {
|
||||
self.print_type(&ty);
|
||||
self.maybe_print_comment(ty.span.lo())
|
||||
self.maybe_print_comment(ty.span.lo());
|
||||
}
|
||||
hir::FnRetTy::DefaultReturn(..) => unreachable!(),
|
||||
}
|
||||
|
@ -2368,7 +2368,7 @@ impl<'a> State<'a> {
|
|||
self.end();
|
||||
|
||||
if let hir::FnRetTy::Return(ref output) = decl.output {
|
||||
self.maybe_print_comment(output.span.lo())
|
||||
self.maybe_print_comment(output.span.lo());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue