compiler/rustc_data_structures/src/sync.rs: delete Sync and Send
This commit is contained in:
parent
4a2c7f48b5
commit
d79f9ca257
2 changed files with 5 additions and 11 deletions
|
@ -2,11 +2,6 @@ use std::borrow::Borrow;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
/// An owned slice.
|
/// An owned slice.
|
||||||
///
|
///
|
||||||
/// This is similar to `Arc<[u8]>` but allows slicing and using anything as the
|
/// This is similar to `Arc<[u8]>` but allows slicing and using anything as the
|
||||||
|
@ -34,7 +29,7 @@ pub struct OwnedSlice {
|
||||||
// \/
|
// \/
|
||||||
// ⊂(´・◡・⊂ )∘˚˳° (I am the phantom remnant of #97770)
|
// ⊂(´・◡・⊂ )∘˚˳° (I am the phantom remnant of #97770)
|
||||||
#[expect(dead_code)]
|
#[expect(dead_code)]
|
||||||
owner: Arc<dyn sync::Send + sync::Sync>,
|
owner: Arc<dyn Send + Sync>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Makes an [`OwnedSlice`] out of an `owner` and a `slicer` function.
|
/// Makes an [`OwnedSlice`] out of an `owner` and a `slicer` function.
|
||||||
|
@ -61,7 +56,7 @@ pub struct OwnedSlice {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
|
pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
|
||||||
where
|
where
|
||||||
O: sync::Send + sync::Sync + 'static,
|
O: Send + Sync + 'static,
|
||||||
F: FnOnce(&O) -> &[u8],
|
F: FnOnce(&O) -> &[u8],
|
||||||
{
|
{
|
||||||
try_slice_owned(owner, |x| Ok::<_, !>(slicer(x))).into_ok()
|
try_slice_owned(owner, |x| Ok::<_, !>(slicer(x))).into_ok()
|
||||||
|
@ -72,7 +67,7 @@ where
|
||||||
/// See [`slice_owned`] for the infallible version.
|
/// See [`slice_owned`] for the infallible version.
|
||||||
pub fn try_slice_owned<O, F, E>(owner: O, slicer: F) -> Result<OwnedSlice, E>
|
pub fn try_slice_owned<O, F, E>(owner: O, slicer: F) -> Result<OwnedSlice, E>
|
||||||
where
|
where
|
||||||
O: sync::Send + sync::Sync + 'static,
|
O: Send + Sync + 'static,
|
||||||
F: FnOnce(&O) -> Result<&[u8], E>,
|
F: FnOnce(&O) -> Result<&[u8], E>,
|
||||||
{
|
{
|
||||||
// We wrap the owner of the bytes in, so it doesn't move.
|
// We wrap the owner of the bytes in, so it doesn't move.
|
||||||
|
@ -139,10 +134,10 @@ impl Borrow<[u8]> for OwnedSlice {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Send`
|
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Send`
|
||||||
unsafe impl sync::Send for OwnedSlice {}
|
unsafe impl Send for OwnedSlice {}
|
||||||
|
|
||||||
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Sync`
|
// Safety: `OwnedSlice` is conceptually `(&'self.1 [u8], Arc<dyn Send + Sync>)`, which is `Sync`
|
||||||
unsafe impl sync::Sync for OwnedSlice {}
|
unsafe impl Sync for OwnedSlice {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
@ -97,7 +97,6 @@ mod mode {
|
||||||
|
|
||||||
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
|
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
|
||||||
|
|
||||||
pub use std::marker::{Send, Sync};
|
|
||||||
pub use std::sync::OnceLock;
|
pub use std::sync::OnceLock;
|
||||||
// Use portable AtomicU64 for targets without native 64-bit atomics
|
// Use portable AtomicU64 for targets without native 64-bit atomics
|
||||||
#[cfg(target_has_atomic = "64")]
|
#[cfg(target_has_atomic = "64")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue