about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-15 16:16:29 +1000
committerGitHub <noreply@github.com>2025-08-15 16:16:29 +1000
commit1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28 (patch)
treea8051298da3ef458d2490ebc56e462b5f91870c5 /compiler/rustc_codegen_llvm/src
parent324bf2b9fd8bf9661e7045c8a93f5ff0ec1a8ca5 (diff)
parent9dfee2ef35d8176bbcfb601bdf58059513049a16 (diff)
downloadrust-1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28.tar.gz
rust-1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28.zip
Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov
Change the desugaring of `assert!` for better error output

In the desugaring of `assert!`, we now expand to a `match` expression instead of `if !cond {..}`.

The span of incorrect conditions will point only at the expression, and not the whole `assert!` invocation.

```
error[E0308]: mismatched types
  --> $DIR/issue-14091.rs:2:13
   |
LL |     assert!(1,1);
   |             ^ expected `bool`, found integer
```

We no longer mention the expression needing to implement the `Not` trait.

```
error[E0308]: mismatched types
  --> $DIR/issue-14091-2.rs:15:13
   |
LL |     assert!(x, x);
   |             ^ expected `bool`, found `BytePos`
```

Now `assert!(val)` desugars to:

```rust
match val {
    true => {},
    _ => $crate::panic::panic_2021!(),
}
```

Fix #122159.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions