Skip to content

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

Closed
@nikomatsakis

Description

@nikomatsakis
Contributor

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!

Activity

nikomatsakis

nikomatsakis commented on Jan 10, 2022

@nikomatsakis
ContributorAuthor

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

added a commit that references this issue on Jan 19, 2022

Rollup merge of rust-lang#92783 - FabianWolff:issue-92726, r=nikomats…

9a82f74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @nikomatsakis

      Issue actions

        Annotate dead-code lint with a note that Debug impls are ignored · Issue #92726 · rust-lang/rust