Rollup of 5 pull requests
Successful merges:
- #68004 (permit negative impls for non-auto traits)
- #70385 (Miri nits: comment and var name improvement)
- #70411 (Fix for #62691: use the largest niche across all fields)
- #70417 (parser: recover on `...` as a pattern, suggesting `..`)
- #70424 (simplify match stmt)
Failed merges:
r? @ghost
simplify match stmt
We actually have a surprising amount of
```rust
match expr {
$($p:pat)|+ => true,
_ => false,
}
```
While I would prefer this to be replaced with `matches!`, most cases are
fairly readable anyway so we can just let them be for now.
Fix for #62691: use the largest niche across all fields
fixes#62691
(The second commit is a small optimization but it makes the code less pretty and i don't know if it is worth it.)
permit negative impls for non-auto traits
This is a prototype impl that extends `impl !Trait` beyond auto traits. It is not integrated with coherence or anything else, and hence only serves to prevent downstream impls (but not to allow downstream crates to rely on the absence of such impls for coherence purposes).
Fixes https://github.com/rust-lang/rust/issues/66544
TODO:
- [x] need a test that you can't rely on negative impls for coherence purposes
- [x] test that negative impls cannot specialize positive ones
- [x] test that positive impls cannot specialize negative ones
- [x] extend negative impl to `Clone` in order to fully fix#66544
- [x] and maybe make `CoerceUnsized` unsafe? -- that problem is now split out into https://github.com/rust-lang/rust/issues/68015
- [x] introduce feature flag and prepare a write-up
- [x] improve diagnostics?
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.
This also adds docs in the unstable book for the current state of auto traits.