mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 11:53:44 +00:00
![]() Better diagnostic when pattern matching tuple structs Fixes #108284 When trying to pattern match a tuple struct we might get a flawed error message if there are missing fields. E.g. ``` let x = Foo(100, 200); if let Foo { 0: bar } = x { ... } ``` Produces this error: ``` error[E0769]: tuple variant `Foo` written as struct variant --> hello.rs:5:12 | 5 | if let Foo { 0: foo } = x { | ^^^^^^^^^^^^^^ | help: use the tuple variant pattern syntax instead | 5 | if let Foo(_, _) = x { | ~~~~~~ ``` Which doesn't highlight that we can still use the struct syntax but we need to fill missing fields. This pr changes this error to: ``` error[E0027]: pattern does not mention field `1` --> hello.rs:5:12 | 5 | if let Foo { 0: foo } = x { | ^^^^^^^^^^^^^^ missing field `1` | help: include the missing field in the pattern | 5 | if let Foo { 0: foo, 1: _ } = x { | ~~~~~~~~ help: if you don't care about this missing field, you can explicitly ignore it | 5 | if let Foo { 0: foo, .. } = x { | ~~~~~~ ``` |
||
---|---|---|
.. | ||
assembly | ||
auxiliary | ||
codegen | ||
codegen-units | ||
debuginfo | ||
incremental | ||
mir-opt | ||
pretty | ||
run-make | ||
run-make-fulldeps | ||
run-pass-valgrind | ||
rustdoc | ||
rustdoc-gui | ||
rustdoc-js | ||
rustdoc-js-std | ||
rustdoc-json | ||
rustdoc-ui | ||
ui | ||
ui-fulldeps | ||
COMPILER_TESTS.md |