Skip to content

Deep dead_code warning is annoying #18472

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

Closed
comex opened this issue Oct 30, 2014 · 3 comments
Closed

Deep dead_code warning is annoying #18472

comex opened this issue Oct 30, 2014 · 3 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@comex
Copy link
Contributor

comex commented Oct 30, 2014

Currently, any code which is not reachable is considered dead and warned about, even if there are references to it from other dead code. Thus if I implement a tree of functions/methods which call each other, but haven't yet implemented any code to actually call into it yet, every single function in the family will produce a dead code warning, not only the root functions that actually lack any textual references. This is annoyingly verbose.

As a comparison, Clang and GCC only produce warnings for the roots in the equivalent situation for C code.

@huonw huonw added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Oct 31, 2014
@thestinger
Copy link
Contributor

I find it very useful. It frequently finds graphs of genuinely dead code that either indicates a bug or allows for removing a bunch of obsolete code. In my opinion, the entire point of having this stuff as warnings instead of errors is so that it doesn't get in the way of development.

@sanxiyn
Copy link
Member

sanxiyn commented Jan 19, 2015

This is by design. I note that if you add #[allow(dead_code)] to the root, warnings are silenced for the entire tree. You do not need to add allow attributes to all of them.

@steveklabnik
Copy link
Member

At this point, I believe a change to a lint like this would need an RFC. As @sanxiyn notes, this is intended behavior currently.

lnicola added a commit to lnicola/rust that referenced this issue Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

5 participants