Skip to content

Regression: false negative lint dead_code: dead code is not detected for struct if it implements FromStr #142541

Open
@safinaskar

Description

@safinaskar

Code

I tried this code:

#![deny(dead_code)]

impl std::str::FromStr for Foo {
    type Err = ();
    fn from_str(_s: &str) -> Result<Self, Self::Err> {
        panic!();
    }
}

struct Foo;

fn main() {}

I expected to see this happen: compiler should report that struct Foo is never constructed

Instead, this happened: compiler didn't report this

Version it worked on

It most recently worked on: nightly-2019-08-27

Version with regression

nightly-2019-08-28

Notes

cargo-bisect-rustc reports that the following commits happened between these two versions:

get_commits_between returning commits, len: 5
commit[0] 2019-08-26: Auto merge of #63901 - estebank:unknown-receiver-type, r=zackmdavis
commit[1] 2019-08-27: Auto merge of #63926 - Centril:rollup-6kckn9n, r=Centril
commit[2] 2019-08-27: Auto merge of #63940 - Centril:rollup-47qe9gn, r=Centril
commit[3] 2019-08-27: Auto merge of #63639 - Mark-Simulacrum:rustdoc-clean-3, r=GuillaumeGomez
commit[4] 2019-08-27: Auto merge of #63922 - RalfJung:miri, r=nikomatsakis

@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged +A-lints +L-dead_code +L-false-negative

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.L-dead_codeLint: dead_codeL-false-negativeLint: False negative (should have fired but didn't).T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions