You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumEnum{Variant{field:u32},OtherVariant,}fnmain(){let whatever = Enum::Variant{field:0};ifletEnum::Variant{field} = whatever {// field left unused}}
This produces the warning:
warning: unused variable: `field`
--> src/main.rs:8:25
|
8 | if let Enum::Variant {field} = whatever {
| ^^^^^
|
= note: #[warn(unused_variables)] on by default
= note: to avoid this warning, consider using `_field` instead
But changing it to _field is an error because that's not the name of the field. The warning should probably suggest to use Enum::Variant {..} instead.
This also occurs in explicit match statements and irrefutable let patterns – probably anywhere you can bind a field of a struct-like variant.