Skip to content

Commit 0d30325

Browse files
committed
Avoid false positive unused_extern_crates.
1 parent 04ca378 commit 0d30325

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/librustc_resolve/build_reduced_graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ impl<'b> Resolver<'b> {
513513
legacy_imports: LegacyMacroImports,
514514
allow_shadowing: bool) {
515515
let import_macro = |this: &mut Self, name, ext: Rc<_>, span| {
516+
this.used_crates.insert(module.def_id().unwrap().krate);
516517
if let SyntaxExtension::NormalTT(..) = *ext {
517518
this.macro_names.insert(name);
518519
}

src/test/compile-fail/lint-unused-extern-crate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extern crate rand; // no error, the use marks it as used
2626

2727
extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used
2828

29+
#[macro_use] extern crate core; // no error, the `#[macro_use]` marks it as used
30+
2931
#[allow(unused_imports)]
3032
use rand::isaac::IsaacRng;
3133

0 commit comments

Comments
 (0)