Fix invalid suggestion for parenthesized break
Resolvesrust-lang/rust#156383
The old code incorrectly assumed `e.span` started exactly at the beginning of `break`. Fixed by locating the exact start position of `break`.
Avoid const generic recovery after doc comment in type
Fixesrust-lang/rust#122463.
When parsing a generic argument, rustc may snapshot the parser state and retry a failed type parse as an unbraced const generic argument. For `Vec<(/// doc
f32, f32)>`, that recovery produces a misleading follow-up E0747 after the useful “expected type, found doc comment” diagnostic.
This skips that const-generic recovery path when type parsing stopped at a doc comment, and adds a regression test for the compiler diagnostic.
Tweak irrefutable let else warning output
Fixes https://github.com/rust-lang/rust/issues/153454
Greeting!
This PR tweak diagnostic output for `irrefutable-let-else` patterns and adds a check for `let a = Some(b) else {...}`
Thanks for the review!
```
help: consider using `let Some(name) = case` to match on a specific variant
|
LL - let name = Some(case) else {
LL + let Some(name) = case else {
|
```
Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression
Split out of PR rust-lang/rust#154492. This fixes a correctness regression introduced in PR rust-lang/rust#81235 from 2021. Crater was run in my other PR and didn't report any real regressions (https://github.com/rust-lang/rust/pull/154492#issuecomment-4187544786); a rerun has been issued for a few spurious builds (https://github.com/rust-lang/rust/pull/154492#issuecomment-4237077272) but I'm certain it won't find anything either.
This is a theoretical breaking change that doesn't need any T-lang input IMHO since it's such a minute, niche and crystal clear bug that's not worth bothering them with (such a decision is not unprecedented). I'm adding it to the compatibility section of the release notes as is customary.
The Reference doesn't need updating since it didn't adopt this bug and thus accurately describes this part of the grammar as it used to be before 2021-02-23 and as it's meant to be.
The majority of the diff is doc comment additions & necessary UI test restructurings.
Reject dangling attributes in where clauses
Report `attribute without where predicates` for trailing outer attributes in where clauses.
Closesrust-lang/rust#155073 .
also removes E0452 and splits
`tests/rustdoc-ui/lints/renamed-lint-still-applies` into 2 tests
this is because of delayed warn lint being lost on compiler aborting on
error
Emit pre-expansion feature gate warnings for negative impls and specialization
Follow up to rust-lang/rust#154475; part of rust-lang/rust#154045.
This shouldn't need any extra input from T-compiler or T-lang since it's legitimized by [MCP 535](https://github.com/rust-lang/compiler-team/issues/535).
However, I have a feeling that negative impls & specialization behind "`#[cfg(feature = "nightly")]`" are more prevalent in the ecosystem compared to e.g., auto traits & box patterns, so these new warnings will probably hit a bunch of users. In any case, it's only a warning for now not an error so e.g., running crater "in deny mode" or nominating for a T-lang meeting discussion would be disproportionate (esp. since T-lang [has confirmed in the past](https://github.com/rust-lang/rust/pull/116393#issuecomment-1745571299) that this is a T-compiler matter).
move many tests from `structs-enums` to `structs` or `enum`
This PR moves most of the tests in `ui/structs-enums` that are only about structs or only about enums to their respective directory, as a step towards removing `ui/structs-enums`.
Followup to rust-lang/rust#154131.
r? @Kivooeo
- On `const` and `static` point at the type (like we do for let bindings)
- On fn calls, point at const parameter in fn definition
- On type, point at const parameter in type definition
- On array type lengths, explain that array length is always `usize`
- On enum variant discriminant, mention `repr`
Improve irrefutable let-else lint wording
Update the `irrefutable_let_patterns` wording for let-else to better reflect that the `else` clause is unreachable when the LHS pattern always matches.
Closesrust-lang/rust#152938
Remove unhelpful hint from trivial bound errors
The `= help: see issue #48214` hint on trivial bound errors isn't useful, most users hitting these errors aren't trying to use the `trivial_bounds` feature. The `disabled_nightly_features` call already handles suggesting the feature gate on nightly.
Closesrust-lang/rust#152872