about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml1
-rw-r--r--src/metadata.rs21
3 files changed, 4 insertions, 28 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3cb67032aaa..dc1cd336e15 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -241,15 +241,6 @@ dependencies = [
 ]
 
 [[package]]
-name = "memmap2"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6"
-dependencies = [
- "libc",
-]
-
-[[package]]
 name = "object"
 version = "0.23.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -319,7 +310,6 @@ dependencies = [
  "gimli",
  "indexmap",
  "libloading",
- "memmap2",
  "object",
  "smallvec",
  "target-lexicon",
diff --git a/Cargo.toml b/Cargo.toml
index 59542c414fa..60946ab2808 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,6 @@ ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg
 indexmap = "1.0.2"
 libloading = { version = "0.6.0", optional = true }
 smallvec = "1.6.1"
-memmap2 = "0.2.1"
 
 # Uncomment to use local checkout of cranelift
 #[patch."https://github.com/bytecodealliance/wasmtime/"]
diff --git a/src/metadata.rs b/src/metadata.rs
index c5189c972cd..dbdc8cbad44 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -1,11 +1,11 @@
 //! Reading and writing of the rustc metadata for rlibs and dylibs
 
 use std::fs::File;
-use std::ops::Deref;
 use std::path::Path;
 
 use rustc_codegen_ssa::METADATA_FILENAME;
-use rustc_data_structures::owning_ref::{OwningRef, StableAddress};
+use rustc_data_structures::memmap::Mmap;
+use rustc_data_structures::owning_ref::OwningRef;
 use rustc_data_structures::rustc_erase_owner;
 use rustc_data_structures::sync::MetadataRef;
 use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader};
@@ -17,26 +17,13 @@ use crate::backend::WriteMetadata;
 
 pub(crate) struct CraneliftMetadataLoader;
 
-struct StableMmap(memmap2::Mmap);
-
-impl Deref for StableMmap {
-    type Target = [u8];
-
-    fn deref(&self) -> &[u8] {
-        &*self.0
-    }
-}
-
-unsafe impl StableAddress for StableMmap {}
-
 fn load_metadata_with(
     path: &Path,
     f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>,
 ) -> Result<MetadataRef, String> {
     let file = File::open(path).map_err(|e| format!("{:?}", e))?;
-    let data = unsafe { memmap2::MmapOptions::new().map_copy_read_only(&file) }
-        .map_err(|e| format!("{:?}", e))?;
-    let metadata = OwningRef::new(StableMmap(data)).try_map(f)?;
+    let data = unsafe { Mmap::map(file) }.map_err(|e| format!("{:?}", e))?;
+    let metadata = OwningRef::new(data).try_map(f)?;
     return Ok(rustc_erase_owner!(metadata.map_owner_box()));
 }