Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 9: clippy warns against unused enum field when it is only used in debug derivation. #62

Open
Yehuda-blip opened this issue Jul 13, 2024 · 0 comments

Comments

@Yehuda-blip
Copy link

Another fantastic exercise, I love this book!

Clippy will warn against unused code (the numeric fields of the NumberType enum), even though they are printed in the show function.

warning: field `0` is never read
  --> exercises/09_ambiguity_and_ordering/main.rs:10:20
   |
10 |     PositiveNumber(u32),
   |     -------------- ^^^
   |     |
   |     field in this variant
   |
   = note: `NumberType` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
10 |     PositiveNumber(()),
   |                    ~~

I simply put a #[allow(dead_code)] annotation over NumberType to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant