Interesting. Both the linter on my local machine and the one used by https://play.rust-lang.org/ complained "enum is never used". Which version of Rust are you using?
The code you linked to the playground is different from the code in your original post.
At that link you see that the main function is using one of the variants of the enum, so the lint message changes.
The message you get without the main function is still accurate. It's telling you that you have created an enum that you never use. It will still compile, it's just letting you know that you might want to clean the code up.
Ah, I see. If I click "Build", it warns "main fn is never used" and, I guess, therefore is eliminated, which results in "enum is never used". But if I click "Run", main fn is used and thus enum Foo is used. Interesting...
This is an artifact of the playground trying to be helpful by not requiring you to have a main() function just to play with some code. When you hit "Build", your code is built as a library not an executable which implicitly calls main(). Since your main function isn't public, it can't be called which triggers the dead code warnings you're seeing.
If this problem is small reproduction of something you are seeing in a library you are building, the problem stems from Foo not being public. If it is public, the compiler will know that it is not required to be used in the current crate, so changing it to be pub enum Foo{} will also solve your problem! If you dont want it to be public, then i would remove the dead code. #[allow(dead_code)] is never a good idea imo :).
FTR I wasn't necessarily recommending #[allow(dead_code)] in real practice, just pointing out it would hide the error in cases where it was trivial and annoying.