]> git.lizzy.rs Git - rust.git/blob - src/test/ui/uninhabited/uninhabited-irrefutable.stderr
Suggest `if let`/`let_else` for refutable pat in `let`
[rust.git] / src / test / ui / uninhabited / uninhabited-irrefutable.stderr
1 error[E0005]: refutable pattern in local binding: `A(_)` not covered
2   --> $DIR/uninhabited-irrefutable.rs:27:9
3    |
4 LL |     let Foo::D(_y, _z) = x;
5    |         ^^^^^^^^^^^^^^ pattern `A(_)` not covered
6    |
7    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
8    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
9 note: `Foo` defined here
10   --> $DIR/uninhabited-irrefutable.rs:19:5
11    |
12 LL | enum Foo {
13    |      ---
14 LL |     A(foo::SecretlyEmpty),
15    |     ^ not covered
16    = note: the matched value is of type `Foo`
17 help: you might want to use `if let` to ignore the variant that isn't matched
18    |
19 LL |     let (_y, _z) = if let Foo::D(_y, _z) = x { (_y, _z) } else { todo!() };
20    |     +++++++++++++++++                        +++++++++++++++++++++++++++++
21 help: alternatively, on nightly, you might want to use `#![feature(let_else)]` to handle the variant that isn't matched
22    |
23 LL |     let Foo::D(_y, _z) = x else { todo!() };
24    |                            ++++++++++++++++
25
26 error: aborting due to previous error
27
28 For more information about this error, try `rustc --explain E0005`.