Skip to content
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

unused-extern-crates causes false positive with macro_use #30849

Closed
Ms2ger opened this issue Jan 12, 2016 · 7 comments
Closed

unused-extern-crates causes false positive with macro_use #30849

Ms2ger opened this issue Jan 12, 2016 · 7 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Jan 12, 2016

For example, it warns for bitflags/lazy_static even when those macros are used in the crate.

@alexcrichton
Copy link
Member

This is why the lint is allow-by-default, it's got false positives

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Jan 12, 2016

Sure, but that doesn't mean some of them can't be fixed.

@steveklabnik steveklabnik added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 26, 2016
@zbynekwinkler
Copy link

@SimonSapin
Copy link
Contributor

On IRC about this:

@eddyb: s/false positives/macros aren't integrated with name resolution yet/

@eddyb
Copy link
Member

eddyb commented Apr 29, 2016

It's actually possible to silence the error by adding #[no_link] to the macro-only extern crate bitflags; (which is what librustc does), effectively removing bitflags from the scope.

If/when we move name resolution earlier and use it during macro expansion, the macro will actually be imported through the bitflags name and the warning wouldn't get triggered.

@Ms2ger
Copy link
Contributor Author

Ms2ger commented Jan 23, 2017

#39060 improved this.

CC @jseyfried

@jseyfried
Copy link
Contributor

@eddyb

If/when we move name resolution earlier and use it during macro expansion, the macro will actually be imported through the bitflags name and the warning wouldn't get triggered.

Now that macro modularization is implemented, this is true today!

adding #[no_link] to the macro-only extern crate bitflags; effectively [removes] bitflags from the scope.

For the record, this changed in #37247 to support use macro imports from #[no_link] crates.

bors added a commit that referenced this issue Aug 27, 2017
Make unused-extern-crate warn-by-default

Apart from enabling the lint, this pull request also removes existing unused crates in the codebase, and fix some amount of false positives on crates with special purposes.

Now that all false positive issues are closed, it should be possible to make it available to wider users.

Quote:
> Now that macro modularization is implemented, this is true today! *#30849 (comment)

Concerns: can break some `#[deny(warnings)]`.

Close #42591
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

7 participants