diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-05 15:04:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-05 15:04:20 +0100 |
| commit | a8f8f746fc046a025d1b8c464ce28f6b828f32e9 (patch) | |
| tree | 162c91c875293c2c5b332f5fca640ea38c515956 /src/test/ui/const-generics | |
| parent | 214b2a126bc6654bf60108aea2e8dce94b096b4b (diff) | |
| parent | b516a8c5cbcde670e509182592547072a723875a (diff) | |
| download | rust-a8f8f746fc046a025d1b8c464ce28f6b828f32e9.tar.gz rust-a8f8f746fc046a025d1b8c464ce28f6b828f32e9.zip | |
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.
Diffstat (limited to 'src/test/ui/const-generics')
| -rw-r--r-- | src/test/ui/const-generics/defaults/pretty-printing-ast.stdout | 4 |
1 files changed, 2 insertions, 2 deletions
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 1bceb8cbb94..9f65b8f25ba 100644 --- a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -11,9 +11,9 @@ use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; -trait Foo<const KIND : bool = true> { } +trait Foo<const KIND : bool = true> {} -fn foo<const SIZE : usize = 5>() { } +fn foo<const SIZE : usize = 5>() {} struct Range<const FROM : usize = 0, const LEN : usize = 0, const TO : usize = FROM>; |
