Skip to content

Spurious dead_code warning when type is only used in path #23808

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

Closed
apasel422 opened this issue Mar 28, 2015 · 1 comment
Closed

Spurious dead_code warning when type is only used in path #23808

apasel422 opened this issue Mar 28, 2015 · 1 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. L-dead_code Lint: dead_code T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@apasel422
Copy link
Contributor

foo.rs:

trait Bar {
    fn bar() {}
}

enum Foo {}

impl Bar for Foo {}

fn main() {
    Foo::bar();
}

Warning:

> rustc --version
rustc 1.0.0-nightly (199bdcfef 2015-03-26) (built 2015-03-27)
> rustc foo.rs 
foo.rs:5:1: 5:12 warning: enum is never used: `Foo`, #[warn(dead_code)] on by default
foo.rs:5 enum Foo {}
         ^~~~~~~~~~~
@TimNN
Copy link
Contributor

TimNN commented Aug 5, 2015

By the way, the warning goes away if you explicitly specify the trait who's static method you are calling, like so:

<Foo as Bar>::bar();

TimNN added a commit to TimNN/rust that referenced this issue Aug 12, 2015
bors added a commit that referenced this issue Aug 22, 2015
Fixes #23808, passes `make check-stage1` `run-pass` and `run-fail` locally.
@jieyouxu jieyouxu added 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. L-dead_code Lint: dead_code labels Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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. L-dead_code Lint: dead_code 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

4 participants