Skip to content

Commit 8b21296

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 6f72620 + a61126c commit 8b21296

File tree

52 files changed

+283
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+283
-167
lines changed

compiler/rustc_data_structures/src/owned_slice.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::sync::Lrc;
44
// Use our fake Send/Sync traits when on not parallel compiler,
55
// so that `OwnedSlice` only implements/requires Send/Sync
66
// for parallel compiler builds.
7-
use crate::sync::{Send, Sync};
7+
use crate::sync;
88

99
/// An owned slice.
1010
///
@@ -33,7 +33,7 @@ pub struct OwnedSlice {
3333
// \/
3434
// ⊂(´・◡・⊂ )∘˚˳° (I am the phantom remnant of #97770)
3535
#[expect(dead_code)]
36-
owner: Lrc<dyn Send + Sync>,
36+
owner: Lrc<dyn sync::Send + sync::Sync>,
3737
}
3838

3939
/// Makes an [`OwnedSlice`] out of an `owner` and a `slicer` function.
@@ -60,7 +60,7 @@ pub struct OwnedSlice {
6060
/// ```
6161
pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
6262
where
63-
O: Send + Sync + 'static,
63+
O: sync::Send + sync::Sync + 'static,
6464
F: FnOnce(&O) -> &[u8],
6565
{
6666
try_slice_owned(owner, |x| Ok::<_, !>(slicer(x))).into_ok()
@@ -71,7 +71,7 @@ where
7171
/// See [`slice_owned`] for the infallible version.
7272
pub fn try_slice_owned<O, F, E>(owner: O, slicer: F) -> Result<OwnedSlice, E>
7373
where
74-
O: Send + Sync + 'static,
74+
O: sync::Send + sync::Sync + 'static,
7575
F: FnOnce(&O) -> Result<&[u8], E>,
7676
{
7777
// We wrap the owner of the bytes in, so it doesn't move.
@@ -139,11 +139,11 @@ impl Borrow<[u8]> for OwnedSlice {
139139

140140
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Send`
141141
#[cfg(parallel_compiler)]
142-
unsafe impl Send for OwnedSlice {}
142+
unsafe impl sync::Send for OwnedSlice {}
143143

144144
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Sync`
145145
#[cfg(parallel_compiler)]
146-
unsafe impl Sync for OwnedSlice {}
146+
unsafe impl sync::Sync for OwnedSlice {}
147147

148148
#[cfg(test)]
149149
mod tests;

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ use super::compare_impl_item::check_type_bounds;
55
use super::compare_impl_item::{compare_impl_method, compare_impl_ty};
66
use super::*;
77
use rustc_attr as attr;
8-
use rustc_errors::{codes::*, ErrorGuaranteed, MultiSpan};
8+
use rustc_errors::{codes::*, MultiSpan};
99
use rustc_hir as hir;
1010
use rustc_hir::def::{CtorKind, DefKind};
11-
use rustc_hir::def_id::{DefId, LocalDefId};
1211
use rustc_hir::Node;
1312
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
1413
use rustc_infer::traits::{Obligation, TraitEngineExt as _};

compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{errors, structured_errors::StructuredDiagnostic};
2-
use rustc_errors::{codes::*, DiagnosticBuilder, ErrCode};
2+
use rustc_errors::{codes::*, DiagnosticBuilder};
33
use rustc_middle::ty::{Ty, TypeVisitableExt};
44
use rustc_session::Session;
55
use rustc_span::Span;

compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{errors, structured_errors::StructuredDiagnostic};
2-
use rustc_errors::{codes::*, DiagnosticBuilder, ErrCode};
2+
use rustc_errors::{codes::*, DiagnosticBuilder};
33
use rustc_middle::ty::{Ty, TypeVisitableExt};
44
use rustc_session::Session;
55
use rustc_span::Span;

compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::structured_errors::StructuredDiagnostic;
2-
use rustc_errors::{
3-
codes::*, pluralize, Applicability, Diagnostic, DiagnosticBuilder, ErrCode, MultiSpan,
4-
};
2+
use rustc_errors::{codes::*, pluralize, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan};
53
use rustc_hir as hir;
64
use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt};
75
use rustc_session::Session;

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
2727
use rustc_data_structures::unord::UnordMap;
2828
use rustc_errors::{
2929
codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diagnostic,
30-
DiagnosticBuilder, ErrCode, ErrorGuaranteed, StashKey,
30+
DiagnosticBuilder, ErrorGuaranteed, StashKey,
3131
};
3232
use rustc_hir as hir;
3333
use rustc_hir::def::{CtorKind, DefKind, Res};

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use itertools::Itertools;
1313
use rustc_ast as ast;
1414
use rustc_data_structures::fx::FxIndexSet;
1515
use rustc_errors::{
16-
codes::*, pluralize, Applicability, Diagnostic, ErrCode, ErrorGuaranteed, MultiSpan, StashKey,
16+
codes::*, pluralize, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, StashKey,
1717
};
1818
use rustc_hir as hir;
1919
use rustc_hir::def::{CtorOf, DefKind, Res};

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::expectation::Expectation;
5353
use crate::fn_ctxt::LoweredTy;
5454
use crate::gather_locals::GatherLocalsVisitor;
5555
use rustc_data_structures::unord::UnordSet;
56-
use rustc_errors::{codes::*, struct_span_code_err, ErrCode, ErrorGuaranteed};
56+
use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
5757
use rustc_hir as hir;
5858
use rustc_hir::def::{DefKind, Res};
5959
use rustc_hir::intravisit::Visitor;

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::errors::{
55
use crate::infer::error_reporting::TypeErrCtxt;
66
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
77
use crate::infer::InferCtxt;
8-
use rustc_errors::{codes::*, DiagnosticBuilder, ErrCode, IntoDiagnosticArg};
8+
use rustc_errors::{codes::*, DiagnosticBuilder, IntoDiagnosticArg};
99
use rustc_hir as hir;
1010
use rustc_hir::def::Res;
1111
use rustc_hir::def::{CtorOf, DefKind, Namespace};

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_data_structures::unhash::UnhashMap;
1313
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
1414
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
1515
use rustc_hir::def::Res;
16-
use rustc_hir::def_id::{DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
16+
use rustc_hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE};
1717
use rustc_hir::definitions::{DefPath, DefPathData};
1818
use rustc_hir::diagnostic_items::DiagnosticItems;
1919
use rustc_index::Idx;

0 commit comments

Comments
 (0)