Stuart Cook 1eeb8e8b15
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.
2025-08-15 16:16:29 +10:00
..
2025-02-21 15:49:44 +11:00
2025-08-09 16:27:20 +05:00
2025-08-14 18:18:42 +02:00
2025-08-14 18:18:42 +02:00
2025-04-03 21:41:58 +00:00
2025-08-09 16:27:20 +05:00
2025-08-09 16:27:20 +05:00
2025-02-21 15:49:46 +11:00
2025-02-21 15:49:46 +11:00
2025-03-07 14:51:07 +11:00
2025-07-23 13:33:23 +02:00
2025-07-23 13:33:23 +02:00
2025-03-11 09:46:34 -07:00
2025-06-30 07:49:20 -05:00
2025-02-28 08:36:12 +11:00