diff options
| author | surechen <chenshuo17@huawei.com> | 2023-11-10 10:11:24 +0800 | 
|---|---|---|
| committer | surechen <chenshuo17@huawei.com> | 2024-02-18 16:38:11 +0800 | 
| commit | a61126cef6c4083d57e22835033eb2eefdd31bac (patch) | |
| tree | 8816d1d780e97b77f943c48de09ee330fee3ac9d /compiler/rustc_resolve/src/diagnostics.rs | |
| parent | d3df8ff85121146f2ac5e863e0c9eaba4bf35d32 (diff) | |
| download | rust-a61126cef6c4083d57e22835033eb2eefdd31bac.tar.gz rust-a61126cef6c4083d57e22835033eb2eefdd31bac.zip | |
By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking.
fixes #117448 For example unnecessary imports in std::prelude that can be eliminated: ```rust use std::option::Option::Some;//~ WARNING the item `Some` is imported redundantly use std::option::Option::None; //~ WARNING the item `None` is imported redundantly ```
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 737481c78db..4b978fefa10 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -33,8 +33,8 @@ use crate::errors::{AddedMacroUse, ChangeImportBinding, ChangeImportBindingSugge use crate::errors::{ConsiderAddingADerive, ExplicitUnsafeTraits, MaybeMissingMacroRulesName}; use crate::imports::{Import, ImportKind}; use crate::late::{PatternSource, Rib}; -use crate::path_names_to_string; use crate::{errors as errs, BindingKey}; +use crate::{path_names_to_string, Used}; use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingError, Finalize}; use crate::{HasGenericParams, MacroRulesScope, Module, ModuleKind, ModuleOrUniformRoot}; use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, VisResolutionError}; @@ -1503,7 +1503,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ); // Silence the 'unused import' warning we might get, // since this diagnostic already covers that import. - self.record_use(ident, binding, false); + self.record_use(ident, binding, Used::Other); return; } } | 
