about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/auto_trait.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-12 22:06:34 +0000
committerbors <bors@rust-lang.org>2024-05-12 22:06:34 +0000
commitecbe3fd550fccd2cba17ea7e86539bf3e0bfc618 (patch)
treec3fe72599d5318f82b14fe186bdf7a6b67935dcb /compiler/rustc_trait_selection/src/traits/auto_trait.rs
parentef0027897d2e9014766fb47dce9ddbb925d2f540 (diff)
parent94cc82c088b9301dc4dcf84ce127a64bbd77dddf (diff)
downloadrust-ecbe3fd550fccd2cba17ea7e86539bf3e0bfc618.tar.gz
rust-ecbe3fd550fccd2cba17ea7e86539bf3e0bfc618.zip
Auto merge of #125051 - dtolnay:printletelse, r=compiler-errors
Pretty-print let-else with added parenthesization when needed

Rustc used to produce invalid syntax for the following code, which is problematic because it means we cannot apply rustfmt to the output of `-Zunpretty=expanded`.

```rust
macro_rules! expr {
    ($e:expr) => { $e };
}

fn main() {
    let _ = expr!(loop {}) else { return; };
}
```

```console
$ rustc repro.rs -Zunpretty=expanded | rustfmt
error: `loop...else` loops are not supported
 --> <stdin>:9:29
  |
9 | fn main() { let _ = loop {} else { return; }; }
  |                     ----    ^^^^^^^^^^^^^^^^
  |                     |
  |                     `else` is attached to this loop
  |
  = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
```
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/auto_trait.rs')
0 files changed, 0 insertions, 0 deletions