Deprecation warning not easily avoidable when using elim form of enum with deprecated field #80107
Open
Description
opened on Dec 17, 2020
The code below warns for the use of the deprecated field:
enum A {
X{
#[deprecated(
since = "0.0.1",
note = "Don't use this")]
x: u32
}
}
fn takeA(a: A) {
match a {
A::X{x} => (),
}
}
warning: use of deprecated field `A::X::x`: Don't use this
--> src/lib.rs:13:14
|
13 | A::X{x} => (),
| ^
|
= note: `#[warn(deprecated)]` on by default
But I don't see a good way to avoid the warning. I tried matching with A::X{x: _}
, but that emits the same warning. If I omit the field entirely, I get an error because the pattern fails to mention field 'x'. If I use A::X{..}
, that works, but it applies to all remaining fields, not just x. I want to get an error if, in the future, a new field is added to the enum and I need to consider adding that field to my case.
My suggestion would be to make matching with A::X{x: _}
suppress the warning.
Activity