Skip to content

pub type Foo = foo::Foo causes bad dead_code warnings on enum variants #17632

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lilyball opened this issue Sep 29, 2014 · 5 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lilyball
Copy link
Contributor

The following code triggers dead_code warnings on each enum variant:

pub type Foo = foo::Foo;
pub mod foo {
    pub enum Foo {
        One,
        Two
    }
}

This happens even though the enum is fully public. Commenting put the pub type line gets rid of the warnings.

@kmcallister kmcallister added A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. I-wrong labels Sep 29, 2014
@ghost ghost self-assigned this Oct 21, 2014
@dherman
Copy link
Contributor

dherman commented Mar 26, 2015

I ran into a similar issue:

mod tc39 {
    #[derive(Debug, Copy, Eq, PartialEq)]
    pub enum Politics {
        Good,
        Bad,
        Ugly
    }
}

use tc39::Politics::*;

fn main() {
    match Good {
        Good => println!("good!"),
        Bad => println!("bad!"),
        Ugly => println!("ugly!")
    }
}

This warns that Bad and Ugly aren't used.

@arielb1 arielb1 removed the I-wrong label Jun 29, 2015
@sanxiyn
Copy link
Member

sanxiyn commented Nov 9, 2015

@kballard's code does not warn any more. @dherman's code does.

@birkenfeld
Copy link
Contributor

@dherman's still does, but isn't that correct? The module is not public, neither is the import. If you make the use tc39::Politics::* a pub use, there is no warning anymore.

@sanxiyn
Copy link
Member

sanxiyn commented May 18, 2016

This seems to be a case of #19140. Use in pattern doesn't count as use.

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

Yes, we don't consider this sort of use a use, since it doesn't construct the value. Closing in favor of #19140.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants