Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression#155698
Conversation
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| let mutability = self.parse_mutability(); | ||
| let by_ref = self.parse_byref(); | ||
|
|
||
| let fieldname = self.parse_field_name()?; |
There was a problem hiding this comment.
This was the culprit.
Prior to the regressing PR #81235 this used to be let fieldname = self.parse_ident()?;.
Changing it (back) to parse_ident_common makes it consistent again with its expression counterpart, cf:
rust/compiler/rustc_parse/src/parser/expr.rs
Line 4046 in 36ba2c7
There was a problem hiding this comment.
Merged into tests/ui/parser/struct-expr-pat-tuple-index-shorthand.rs.
This test exercises struct expressions while the new struct-expr-pat-tuple-index-shorthand.rs tests both expressions and patterns to make it less likely that they accidentally diverge again.
There was a problem hiding this comment.
Split into
tests/ui/structs/struct-pat-unmentioned-tuple-indices.rs- the
if let E::S { 0: a } = x { //~ ERROR: pattern does not mention field `1`part to be precise
- the
tests/ui/tuple/tuple-variant-written-as-empty-struct-variant.rs- the
S { } => {} //~ ERROR: tuple variant `S` written as struct variant [E0769]part to be precise
- the
The third test case, E::S { 0, 1 } => {} // //~^ ERROR tuple variant `E::S` written as struct variant [E0769] is superseded by the test case in tests/ui/parser/struct-expr-pat-tuple-index-shorthand.rs since that snippet is now a syntax error again and no longer a semantic error.
e72ed63 to
e778b9b
Compare
… a correctness regression
e778b9b to
07d015e
Compare
|
LGTM! @bors r+ rollup=always |
Rollup of 9 pull requests Successful merges: - #155684 (Generalize IO Traits for `Arc<T>` where `&T: IoTrait`) - #155081 (Move and clean up some ui test) - #155379 (Avoid query cycles in DataflowConstProp) - #155663 (Eliminate `CrateMetadataRef`.) - #155669 (Add `Sender` diagnostic item for `std::sync::mpsc::Sender`) - #155698 (Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression) - #155703 (Remove myself as a maintainer of `wasm32-wasip1-threads`) - #155706 (Remove `AttributeLintKind` variants - part 7) - #155712 (Forbid `*-pass` and `*-fail` directives in tests/crashes)
Rollup merge of #155698 - fmease:no-struct-pat-tuple-index-shorthand, r=mu001999 Syntactically reject tuple index shorthands in struct patterns to fix a correctness regression Split out of PR #154492. This fixes a correctness regression introduced in PR #81235 from 2021. Crater was run in my other PR and didn't report any real regressions (#154492 (comment)); a rerun has been issued for a few spurious builds (#154492 (comment)) 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.
Split out of PR #154492. This fixes a correctness regression introduced in PR #81235 from 2021. Crater was run in my other PR and didn't report any real regressions (#154492 (comment)); a rerun has been issued for a few spurious builds (#154492 (comment)) 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.