Skip to content

Commit 1c10aa4

Browse files
committed
Auto merge of rust-lang#117772 - surechen:for_117448, r=petrochenkov
Tracking import use types for more accurate redundant import checking fixes rust-lang#117448 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. 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 ```
2 parents 6b17dba + 5db0494 commit 1c10aa4

File tree

19 files changed

+20
-34
lines changed

19 files changed

+20
-34
lines changed

crates/hir-def/src/body/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use itertools::Itertools;
66

77
use crate::{
88
hir::{
9-
Array, BindingAnnotation, BindingId, CaptureBy, ClosureKind, Literal, LiteralOrConst,
9+
Array, BindingAnnotation, CaptureBy, ClosureKind, Literal, LiteralOrConst,
1010
Movability, Statement,
1111
},
1212
pretty::{print_generic_args, print_path, print_type_ref},

crates/hir-def/src/import_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt, hash::BuildHasherDefault};
44

55
use base_db::CrateId;
6-
use fst::{self, raw::IndexedValue, Automaton, Streamer};
6+
use fst::{raw::IndexedValue, Automaton, Streamer};
77
use hir_expand::name::Name;
88
use indexmap::IndexMap;
99
use itertools::Itertools;

crates/hir-def/src/item_tree/lower.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
33
use std::collections::hash_map::Entry;
44

5-
use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef, HirFileId};
6-
use syntax::ast::{self, HasModuleItem, HasTypeBounds, IsString};
5+
use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef};
6+
use syntax::ast::{HasModuleItem, HasTypeBounds, IsString};
77

88
use crate::{
9-
generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance},
10-
type_ref::{LifetimeRef, TraitBoundModifier, TraitRef},
9+
generics::{GenericParamsCollector, TypeParamData, TypeParamProvenance},
10+
type_ref::{LifetimeRef, TraitBoundModifier},
1111
LocalLifetimeParamId, LocalTypeOrConstParamId,
1212
};
1313

crates/hir-def/src/item_tree/pretty.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//! `ItemTree` debug printer.
22
3-
use std::fmt::{self, Write};
3+
use std::fmt::Write;
44

55
use span::ErasedFileAstId;
66

77
use crate::{
8-
generics::{TypeOrConstParamData, WherePredicate, WherePredicateTypeTarget},
8+
generics::{WherePredicate, WherePredicateTypeTarget},
99
pretty::{print_path, print_type_bounds, print_type_ref},
10-
visibility::RawVisibility,
1110
};
1211

1312
use super::*;

crates/hir-def/src/nameres.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod proc_macro;
5757
#[cfg(test)]
5858
mod tests;
5959

60-
use std::{cmp::Ord, ops::Deref};
60+
use std::ops::Deref;
6161

6262
use base_db::{CrateId, Edition, FileId};
6363
use hir_expand::{

crates/hir-ty/src/diagnostics/match_check/pat_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Originates from `rustc_hir::pat_util`
44
5-
use std::iter::{Enumerate, ExactSizeIterator};
5+
use std::iter::Enumerate;
66

77
pub(crate) struct EnumerateAndAdjust<I> {
88
enumerate: Enumerate<I>,

crates/hir-ty/src/mir/eval/shim.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
use std::cmp;
55

66
use chalk_ir::TyKind;
7-
use hir_def::{
8-
builtin_type::{BuiltinInt, BuiltinUint},
9-
resolver::HasResolver,
10-
};
11-
use hir_expand::mod_path::ModPath;
7+
use hir_def::builtin_type::{BuiltinInt, BuiltinUint};
128

139
use super::*;
1410

crates/hir-ty/src/mir/lower.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This module generates a polymorphic MIR from a hir body
22
3-
use std::{fmt::Write, iter, mem};
3+
use std::{fmt::Write, mem};
44

55
use base_db::{salsa::Cycle, FileId};
66
use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind};
@@ -14,23 +14,19 @@ use hir_def::{
1414
lang_item::{LangItem, LangItemTarget},
1515
path::Path,
1616
resolver::{resolver_for_expr, HasResolver, ResolveValueResult, ValueNs},
17-
AdtId, DefWithBodyId, EnumVariantId, GeneralConstId, HasModule, ItemContainerId, LocalFieldId,
17+
AdtId, EnumVariantId, GeneralConstId, HasModule, ItemContainerId, LocalFieldId,
1818
Lookup, TraitId, TupleId, TypeOrConstParamId,
1919
};
2020
use hir_expand::name::Name;
21-
use la_arena::ArenaMap;
22-
use rustc_hash::FxHashMap;
2321
use syntax::TextRange;
2422
use triomphe::Arc;
2523

2624
use crate::{
2725
consteval::ConstEvalError,
28-
db::{HirDatabase, InternedClosure},
29-
display::HirDisplay,
26+
db::InternedClosure,
3027
infer::{CaptureKind, CapturedItem, TypeMismatch},
3128
inhabitedness::is_ty_uninhabited_from,
3229
layout::LayoutError,
33-
mapping::ToChalk,
3430
static_lifetime,
3531
traits::FnTrait,
3632
utils::{generics, ClosureSubst},

crates/hir-ty/src/mir/lower/pattern_matching.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! MIR lowering for patterns
22
3-
use hir_def::{hir::LiteralOrConst, resolver::HasResolver, AssocItemId};
3+
use hir_def::AssocItemId;
44

55
use crate::BindingMode;
66

crates/ide-assists/src/handlers/generate_delegate_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hir::{self, HasCrate, HasVisibility};
1+
use hir::{HasCrate, HasVisibility};
22
use ide_db::{path_transform::PathTransform, FxHashSet};
33
use syntax::{
44
ast::{

crates/ide-completion/src/completions/item_list/trait_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//! }
3232
//! ```
3333
34-
use hir::{self, HasAttrs};
34+
use hir::HasAttrs;
3535
use ide_db::{
3636
documentation::HasDocs, path_transform::PathTransform,
3737
syntax_helpers::insert_whitespace_into_node, traits::get_missing_assoc_items, SymbolKind,

crates/ide-db/src/symbol_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use base_db::{
3131
salsa::{self, ParallelDatabase},
3232
SourceDatabaseExt, SourceRootId, Upcast,
3333
};
34-
use fst::{self, raw::IndexedValue, Automaton, Streamer};
34+
use fst::{raw::IndexedValue, Automaton, Streamer};
3535
use hir::{
3636
db::HirDatabase,
3737
import_map::{AssocSearchMode, SearchMode},

crates/rust-analyzer/src/cargo_target_spec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::mem;
44

55
use cfg::{CfgAtom, CfgExpr};
66
use ide::{Cancellable, CrateId, FileId, RunnableKind, TestId};
7-
use project_model::{self, CargoFeatures, ManifestPath, TargetKind};
7+
use project_model::{CargoFeatures, ManifestPath, TargetKind};
88
use rustc_hash::FxHashSet;
99
use vfs::AbsPathBuf;
1010

crates/rust-analyzer/src/cli/lsif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ide_db::{
1313
LineIndexDatabase,
1414
};
1515
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
16-
use lsp_types::{self, lsif};
16+
use lsp_types::lsif;
1717
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
1818
use rustc_hash::FxHashMap;
1919
use vfs::{AbsPathBuf, Vfs};

crates/salsa/salsa-macros/src/query_group.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//!
2-
use std::{convert::TryFrom, iter::FromIterator};
32
43
use crate::parenthesized::Parenthesized;
54
use heck::ToUpperCamelCase;

crates/salsa/src/debug.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::durability::Durability;
55
use crate::plumbing::QueryStorageOps;
66
use crate::Query;
77
use crate::QueryTable;
8-
use std::iter::FromIterator;
98

109
/// Additional methods on queries that can be used to "peek into"
1110
/// their current state. These methods are meant for debugging and

crates/salsa/src/derived.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::Runtime;
1313
use crate::{Database, DatabaseKeyIndex, QueryDb, Revision};
1414
use parking_lot::RwLock;
1515
use std::borrow::Borrow;
16-
use std::convert::TryFrom;
1716
use std::hash::Hash;
1817
use std::marker::PhantomData;
1918
use triomphe::Arc;

crates/salsa/src/input.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::Runtime;
1414
use crate::{DatabaseKeyIndex, QueryDb};
1515
use indexmap::map::Entry;
1616
use parking_lot::RwLock;
17-
use std::convert::TryFrom;
1817
use std::iter;
1918
use tracing::debug;
2019

crates/salsa/src/interned.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::{Database, DatabaseKeyIndex, QueryDb};
1313
use parking_lot::RwLock;
1414
use rustc_hash::FxHashMap;
1515
use std::collections::hash_map::Entry;
16-
use std::convert::From;
1716
use std::fmt::Debug;
1817
use std::hash::Hash;
1918
use triomphe::Arc;

0 commit comments

Comments
 (0)