use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::owning_ref::OwningRef;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::MetadataRef;
use snap::read::FrameDecoder;
use std::io::{Read, Result as IoResult, Write};
-use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::{cmp, fmt, fs};
use tracing::{debug, info, warn};
}
}
-/// A trivial wrapper for `Mmap` that implements `StableDeref`.
-struct StableDerefMmap(memmap2::Mmap);
-
-impl Deref for StableDerefMmap {
- type Target = [u8];
-
- fn deref(&self) -> &[u8] {
- self.0.deref()
- }
-}
-
-unsafe impl stable_deref_trait::StableDeref for StableDerefMmap {}
-
fn get_metadata_section(
target: &Target,
flavor: CrateFlavor,
// mmap the file, because only a small fraction of it is read.
let file = std::fs::File::open(filename)
.map_err(|_| format!("failed to open rmeta metadata: '{}'", filename.display()))?;
- let mmap = unsafe { memmap2::Mmap::map(&file) };
+ let mmap = unsafe { Mmap::map(file) };
let mmap = mmap
.map_err(|_| format!("failed to mmap rmeta metadata: '{}'", filename.display()))?;
- rustc_erase_owner!(OwningRef::new(StableDerefMmap(mmap)).map_owner_box())
+ rustc_erase_owner!(OwningRef::new(mmap).map_owner_box())
}
};
let blob = MetadataBlob::new(raw_bytes);