diff options
| author | yukang <moorekang@gmail.com> | 2025-06-02 17:40:35 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2025-06-02 17:49:01 +0800 |
| commit | 7167e7ce06437ec093e80cc4ff20bf33dbf1fef5 (patch) | |
| tree | b9cf50a61c76c1bf3f6a7503ca8124bbd8082896 /compiler/rustc_resolve/src | |
| parent | 91fad92585b2dafc52a074e502b2a6c1f093ca35 (diff) | |
| download | rust-7167e7ce06437ec093e80cc4ff20bf33dbf1fef5.tar.gz rust-7167e7ce06437ec093e80cc4ff20bf33dbf1fef5.zip | |
Fix false positive lint error from no_implicit_prelude attr
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/check_unused.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 0579e91c0d6..e0b2adb3fc9 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -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) |
