about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
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
commit210097ad7e272458b48e2b4cee028e7a2876a692 (patch)
treebfe849707433edd091da85267e7fc2d4d5f18920 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parente7d8d34eae23bd91164510b03e6b239ccbcfdf07 (diff)
parent0a522ccfd97de0f28e5c090431c12241be875a04 (diff)
downloadrust-210097ad7e272458b48e2b4cee028e7a2876a692.tar.gz
rust-210097ad7e272458b48e2b4cee028e7a2876a692.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_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions