-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Incorrect warning about unused const #47133
Comments
This is because The most I've managed to dig up thus far on the reasoning behind this is this ancient post. |
Interesting, thanks for the background! I can see how the behavior here is consistent with the reasoning there, but I don't think the decision on that was the right one. Warnings like these have to be ignored, which reduces the signal/noise ratio of warnings in general. |
Maybe an unused lint should have a note pointing to the "use site" in order to reduce said confusion |
Edit (2019-10-16): I now firmly believe that the current design is inferior in all use cases, and have yet to see any description of a viable workflow for the use case of deleting all dead code given the current design. I very much agree with @robz's sentiment. IMO, there are two use cases that an "unused" lint can be optimized for:
Go figure, the latter always seems to be the one I actually need, but that might just be cognitive bias due to the "grass is greener" effect. Basically, it helps catch various classes of mistakes that otherwise elude the type system. If we're stuck with having a single one of these two lints, then we have different issues:
|
Strawman idea: #![allow(unused)] // disable all unused warnings...
#![warn(truly_unused)] // ...then reenable warnings for a subset of them |
We could collect all unused things in a graph and report it starting with the items that have no incoming edges ( truly unused) That way the important things show up first |
Triage: the error message is the same today, and I'm not aware of anyone working on the "point to the 'use' site" idea either. |
There is already another issue open on this: #39531 |
I have the same problem when the crate have lib that define pub type and function ( actually extern "stdcall" pub fn ) and a bin that use the lib in the same crate. |
Hello writing from 2020. Update: Test usage of a function that contains const item can't pass the lint IFOF function isn't also used in lib. |
Can you show an example? Normally problems like that can be solved by making the function |
In the following program:
I get a warning about
SIZE
being unused:It seems to me that this warning isn't correct, since
SIZE
is used in the signature of_f
The text was updated successfully, but these errors were encountered: