Skip to content

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

Closed
@nikomatsakis

Description

@nikomatsakis

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions