Skip to content

dead_code lint fires on struct despite its static method getting called #34276

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
nagisa opened this issue Jun 14, 2016 · 2 comments
Closed

dead_code lint fires on struct despite its static method getting called #34276

nagisa opened this issue Jun 14, 2016 · 2 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@nagisa
Copy link
Member

nagisa commented Jun 14, 2016

struct A;
trait As {
    fn banana();
}

impl As for A {
    fn banana() { panic!("banana"); }
}

trait Bs<T: As> {
    fn do_it(&self) { T::banana() }
}

struct B;

impl Bs<A> for B {}

fn main() {
    Bs::do_it(&B)
}

When compiled, the dead_code lint fires, claiming that A is not used.

This code, when run, panics with banana, thus proving that A is, in fact, used.

Possibly similar to #32998.

@nagisa nagisa added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jun 14, 2016
@apasel422
Copy link
Contributor

Duplicate of #19613?

@nagisa
Copy link
Member Author

nagisa commented Jun 14, 2016

Seems to be right. I’ll update the said issue. Thanks @apasel422!

@nagisa nagisa closed this as completed Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

2 participants