Yeet owning_ref
Turns out - `owning_ref` is unsound due to `Box` aliasing stuff - `rustc` doesn't need 99% of the `owning_ref` API - `rustc` can use a far simpler abstraction that is `OwnedSlice`
This commit is contained in:
parent
c0ceefdfaf
commit
d7056548f9
6 changed files with 1 additions and 1971 deletions
|
@ -2,9 +2,7 @@ use std::fs::File;
|
|||
use std::io;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use crate::owning_ref::StableAddress;
|
||||
|
||||
/// A trivial wrapper for [`memmap2::Mmap`] that implements [`StableAddress`].
|
||||
/// A trivial wrapper for [`memmap2::Mmap`] (or `Vec<u8>` on WASM).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub struct Mmap(memmap2::Mmap);
|
||||
|
||||
|
@ -46,12 +44,6 @@ impl AsRef<[u8]> for Mmap {
|
|||
}
|
||||
}
|
||||
|
||||
// SAFETY: On architectures other than WASM, mmap is used as backing storage. The address of this
|
||||
// memory map is stable. On WASM, `Vec<u8>` is used as backing storage. The `Mmap` type doesn't
|
||||
// export any function that can cause the `Vec` to be re-allocated. As such the address of the
|
||||
// bytes inside this `Vec` is stable.
|
||||
unsafe impl StableAddress for Mmap {}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub struct MmapMut(memmap2::MmapMut);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue