-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
This issue tracks the release notes text for #122661.
cc @estebank, @BurntSushi -- original issue/PR authors and assignees for drafting text
See the forge.rust-lang.org chapter about release notes for an overview of how the release team makes use of these tracking issues.
Release notes text
This section should be edited to specify the correct category(s) for the change, with succinct description(s) of what changed. Some things worth considering:
- Does this need an additional compat notes section?
- Was this a libs stabilization that should have additional headers to list new APIs under
Stabilized APIs
andConst Stabilized APIs
?
# Compatibility Notes
- [Changed the expansion of the `assert!` macro](https://github.com/rust-lang/rust/pull/122661): The macro now expands to a `match` expression instead of an `if !cond { .. }`, which provides better error output when misused, but breaks `assert!` invocations which rely on a custom `Not` trait implementation.
Tip
Use the previous releases for inspiration on how to write the release notes text and which categories to pick.
Release blog section
If this change is notable enough for inclusion in the blog post then this section should be edited to contain a draft for the blog post. Otherwise leave it empty.
[The `assert!` macro now expands to a `match` expression](https://github.com/rust-lang/rust/pull/122661) instead of an `if !cond { .. }`, which provides better error output when misused, but breaks `assert!` invocations which rely on a custom `Not` trait implementation. For example, the following contrived code will stop working:
```rust
struct True;
impl core::ops::Not for True {
type Output = bool;
fn not(self) -> bool {
false
}
}
fn example() {
assert!(True);
}
```
but that it will *not* break uses of `&bool`, such as:
```rust
struct Struct {
valid: bool,
}
fn example(s: &Struct) {
let Struct { valid } = s;
assert!(valid);
}
```
In return, we get diagnostics that make more sense when misusing the macro:
```text
error[E0308]: mismatched types
--> $DIR/issue-28308.rs:2:13
|
LL | assert!("foo");
| ^^^^^ expected `bool`, found `str`
```
Instead of the previous diagnostic which would mention the expression needing to implement the `Not` trait:
```text
error[E0600]: cannot apply unary operator `!` to type `&'static str`
--> $DIR/issue-28308.rs:2:5
|
LL | assert!("foo");
| ^^^^^^^^^^^^^^ cannot apply unary operator `!`
```
Note
If a blog post section is required the release-blog-post
label should be added (@rustbot label +release-blog-post
) to this issue as otherwise it may be missed by the release team.