-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
"variants never constructed" lint regression in Rust 1.64.0 #318
Comments
Ah, one other important detail to note -- the warnings only happen in Simple enums that are just lists of keywords with no values work just fine. |
rkyv-derived enums throw warnings that they are unused. Not sure how to get rid of them; I've tried surrounding them in `#[allow(dead_code)]` directives, and also explicitly creating each enum variant that I'm aware of through some dummy code and some log prints of the dummy code calls to ensure the results are used, and the warnings still persist. Significantly, the warnings only happen for enums that take a value. Simple rkyv enums do not throw a warning. These warnings overwhelm the build logs, so they need to be isolated in order for us to ensure that the build is clean of other more important warnings. The method chosen to isolate them is to take the enums that are problematic, carve them into their own special file, and add a file-wide `#![allow(dead_code)]` directive. This only happens in 7 service crates, and this change commits all of the modifications in a single big commit that could be undone later if this turns out to be a compiler regression or something similar. I also opened an issue with the rkyv maintainer to see what his opinion is on the situation. rkyv/rkyv#318
This might be related to some spanning problems that were fixed up later on in rkyv's life. I'll take a look and see if we can get those backported to a 0.4.* version. |
thanks! For now the work-around I have of moving rkyv-types to their own file is working so far. If it turns out to be a distraction to backport to 0.4.*, we plan to forward-port our bindings to your 0.8 release once that's ready! |
I'm using a fairly old version of rkyv (0.4.3) and wondering if this lint warning is also appearing for users in later versions of rkyv:
This just started appearing in Rust 1.64.0; in Rust 1.63.0 and older, such warnings were not emitted.
We try to keep our builds 100% free of warnings, so we can actually see warnings that matter when the builds happen. Unfortunately, we use a lot of rkyv so with this regression our build logs are overwhelmed with Rust complaining about Archive-derived enums not being used.
I tried to actually construct the derived enums with some code like this:
But even if I call this code and pass the result on to something else, Rust is insisting that we never construct that enum type (tried creating both the ArchivedSha2Result and the Sha2ResultResolver and casting the results to something the compiler shouldn't disregard). I'm guessing maybe the derive creates some extra enum types that I'm not aware of or perhaps it does something exciting with the discriminants that cause the rust linter to think variants are not being used.
Furthermore, if I add
#[allow(dead_code)]
to the enum definition, it still throws the warning; adding#[allow(dead_code)]
to every element has the same result, more warnings.The only way I've been able to silence this is to use the "big hammer" of
#![allow(dead_code)]
to the entire file.So, the current work-around I have is to move all rkyv-derive types to its own file, and then drop the file-wide silencer on top.
This is an acceptable work-around; but now I am left with lingering curiosity!
If this is also happening in the latest rkyv, maybe this is a compiler regression? If it's not happening, something else subtle going on that I'm not understanding in order to construct the derived variants so I can make the warning go away...?
The text was updated successfully, but these errors were encountered: