about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-18 13:56:07 +0000
committerbors <bors@rust-lang.org>2024-02-18 13:56:07 +0000
commit8b21296b5db6d5724d6b8440dcf459fa82fd88b5 (patch)
tree65acaf8e7a0d42e30db5834ab49841ffe6ce1eb3 /compiler/rustc_data_structures
parent6f726205a1b7992537ddec96c83f2b054b03e04f (diff)
parenta61126cef6c4083d57e22835033eb2eefdd31bac (diff)
downloadrust-8b21296b5db6d5724d6b8440dcf459fa82fd88b5.tar.gz
rust-8b21296b5db6d5724d6b8440dcf459fa82fd88b5.zip
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
```
Diffstat (limited to 'compiler/rustc_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/owned_slice.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_data_structures/src/owned_slice.rs b/compiler/rustc_data_structures/src/owned_slice.rs
index cbb3047d884..bb664795860 100644
--- a/compiler/rustc_data_structures/src/owned_slice.rs
+++ b/compiler/rustc_data_structures/src/owned_slice.rs
@@ -4,7 +4,7 @@ use crate::sync::Lrc;
 // Use our fake Send/Sync traits when on not parallel compiler,
 // so that `OwnedSlice` only implements/requires Send/Sync
 // for parallel compiler builds.
-use crate::sync::{Send, Sync};
+use crate::sync;
 
 /// An owned slice.
 ///
@@ -33,7 +33,7 @@ pub struct OwnedSlice {
     //       \/
     //      ⊂(´・◡・⊂ )∘˚˳° (I am the phantom remnant of #97770)
     #[expect(dead_code)]
-    owner: Lrc<dyn Send + Sync>,
+    owner: Lrc<dyn sync::Send + sync::Sync>,
 }
 
 /// Makes an [`OwnedSlice`] out of an `owner` and a `slicer` function.
@@ -60,7 +60,7 @@ pub struct OwnedSlice {
 /// ```
 pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
 where
-    O: Send + Sync + 'static,
+    O: sync::Send + sync::Sync + 'static,
     F: FnOnce(&O) -> &[u8],
 {
     try_slice_owned(owner, |x| Ok::<_, !>(slicer(x))).into_ok()
@@ -71,7 +71,7 @@ where
 /// See [`slice_owned`] for the infallible version.
 pub fn try_slice_owned<O, F, E>(owner: O, slicer: F) -> Result<OwnedSlice, E>
 where
-    O: Send + Sync + 'static,
+    O: sync::Send + sync::Sync + 'static,
     F: FnOnce(&O) -> Result<&[u8], E>,
 {
     // We wrap the owner of the bytes in, so it doesn't move.
@@ -139,11 +139,11 @@ impl Borrow<[u8]> for OwnedSlice {
 
 // Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Send`
 #[cfg(parallel_compiler)]
-unsafe impl Send for OwnedSlice {}
+unsafe impl sync::Send for OwnedSlice {}
 
 // Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Sync`
 #[cfg(parallel_compiler)]
-unsafe impl Sync for OwnedSlice {}
+unsafe impl sync::Sync for OwnedSlice {}
 
 #[cfg(test)]
 mod tests;