Open
Description
For the following code, I get a compiler warning:
#[derive(PartialEq, Eq)]
pub enum Thing { Foo(bool), Bar(Vec<()>) }
impl Thing {
pub const FOO: Thing = Self::Foo(true);
}
pub fn foo(thing: Thing) {
match thing {
Thing::FOO => {},
_ => {},
}
}
And the warning:
warning: to use a constant of type `Vec<()>` in a pattern, the constant's initializer must be trivial or `Vec<()>` must be annotated with `#[derive(PartialEq, Eq)]`
--> src/lib.rs:10:9
|
10 | Thing::FOO => {},
| ^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, [see issue #73448 <https://github.com/rust-lang/rust/issues/73448>](https://github.com/rust-lang/rust/issues/73448)
= note: `#[warn(nontrivial_structural_match)]` on by default
What makes me think this warning is incorrect is that the constant's initializer does not produce the Vec
-containing variant like the warning suggests, and changing Self::
to Thing::
in the initializer resolves the error despite those (afaik) being equivalent.