Skip to content

Commit 8b21296

Browse files
committedFeb 18, 2024
Auto merge of #117772 - surechen:for_117448, r=petrochenkov
Tracking import use types for more accurate redundant import checking fixes #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 _};

0 commit comments

Comments
 (0)
Please sign in to comment.