I'm making this change in an enum
- ScalarPair(Scalar, Scalar),
+ ScalarPair {
+ a: Scalar,
+ b: Scalar,
+ b_offset: Size,
+ },
And of course that leads to all the pattern-matching to fail to compile.
Awkwardly, though, it's giving a misleading error:
error[E0164]: expected tuple struct or tuple variant, found struct variant `BackendRepr::ScalarPair`
--> compiler\rustc_const_eval\src\interpret\validity.rs:1489:21
|
1489 | BackendRepr::ScalarPair(a_layout, b_layout) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant
|
help: the struct variant's fields are being ignored
|
1489 - BackendRepr::ScalarPair(a_layout, b_layout) => {
1489 + BackendRepr::ScalarPair { a: _, b: _, b_offset: _ } => {
|
Saying they're being "ignored" is a bit weird here -- that's not really the problem. It would be nice if the help for a variant that does exist the help would be a bit more focused.
Maybe the message could put the patterns into the struct-variant pattern in declaration order or something? Something like this would be nice:
error[E0164]: expected tuple struct or tuple variant, found struct variant `BackendRepr::ScalarPair`
--> compiler\rustc_const_eval\src\interpret\validity.rs:1489:21
|
1489 | BackendRepr::ScalarPair(a_layout, b_layout) => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant
|
help: add the names to match a struct variant's fields
|
1489 - BackendRepr::ScalarPair(a_layout, b_layout) => {
1489 + BackendRepr::ScalarPair { a: a_layout, b: b_layout, b_offset: _ } => {
|
with bonus points if the existing patterns are uncoloured to emphasize that you're preserving the names.
Perhaps overly-minimized repro, but it shows the error: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=5846d1e37cf841b875b54274fd23e4f9
(Low pri because the diff in the error does make it really clear what one needs to do. It could just be a bit nicer.)
I'm making this change in an enum
And of course that leads to all the pattern-matching to fail to compile.
Awkwardly, though, it's giving a misleading error:
Saying they're being "ignored" is a bit weird here -- that's not really the problem. It would be nice if the help for a variant that does exist the help would be a bit more focused.
Maybe the message could put the patterns into the struct-variant pattern in declaration order or something? Something like this would be nice:
with bonus points if the existing patterns are uncoloured to emphasize that you're preserving the names.
Perhaps overly-minimized repro, but it shows the error: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=5846d1e37cf841b875b54274fd23e4f9
(Low pri because the diff in the error does make it really clear what one needs to do. It could just be a bit nicer.)