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

Annotate dead-code lint with a note that Debug impls are ignored #92726

Closed
nikomatsakis opened this issue Jan 10, 2022 · 1 comment · Fixed by #92783
Closed

Annotate dead-code lint with a note that Debug impls are ignored #92726

nikomatsakis opened this issue Jan 10, 2022 · 1 comment · Fixed by #92783

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jan 10, 2022

PR #85200 modified the dead-code lint so that it ignores Debug impls (and perhaps a few others, I forget) for the purposes of dead-code detection. This is pretty reasonable, but it does create false dead-code warnings when one has structs that exist solely to be debug printed. As evidenced by #88900, users are confused by this in practice.

@pmetzger had a good suggestion:

Even if this warning is reasonable, it would be a good idea if the message explained that derive(Debug) is ignored for purposes of the lint. As it happens, I spent a lot of time tearing my hair out trying to figure out why the warning was being triggered. (In my case I have structs that exist only to be dumped to a log using debug prints.)

I think the ideal would be to note that an "ignored impl" is present and issue a note on the lint. I'm not sure how easy that would be to do!

@nikomatsakis
Copy link
Contributor Author

cc @FabianWolff, author of #85200 -- would you be interested in taking a look at this?

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

Successfully merging a pull request may close this issue.

1 participant