Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,16 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
continue;
}

let module = self
.r
.get_nearest_non_block_module(self.r.local_def_id(extern_crate.id).to_def_id());
if module.no_implicit_prelude {
// If the module has `no_implicit_prelude`, then we don't suggest
// replacing the extern crate with a use, as it would not be
// inserted into the prelude. User writes `extern` style deliberately.
continue;
}

let vis_span = extern_crate
.vis_span
.find_ancestor_inside(extern_crate.span)
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/resolve/extern-crate-lint-issue-141785.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ check-pass
//@ edition:2018

#![no_implicit_prelude]
#![warn(unused_extern_crates)]

extern crate std;
fn main() {
let r = 1u16..10;
std::println!("{:?}", r.is_empty());
}
Loading