Skip to content

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

Closed
@Ms2ger

Description

@Ms2ger
Contributor

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

Activity

alexcrichton

alexcrichton commented on Jan 12, 2016

@alexcrichton
Member

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

Ms2ger

Ms2ger commented on Jan 12, 2016

@Ms2ger
ContributorAuthor

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

added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
on Jan 26, 2016
SimonSapin

SimonSapin commented on Apr 29, 2016

@SimonSapin
Contributor

On IRC about this:

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

eddyb

eddyb commented on Apr 29, 2016

@eddyb
Member

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

Ms2ger commented on Jan 23, 2017

@Ms2ger
ContributorAuthor

#39060 improved this.

CC @jseyfried

jseyfried

jseyfried commented on Mar 14, 2017

@jseyfried
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@alexcrichton@eddyb@Ms2ger@SimonSapin

        Issue actions

          unused-extern-crates causes false positive with macro_use · Issue #30849 · rust-lang/rust