Auto merge of #109971 - WaffleLapkin:yeet_ownership, r=Nilstrieb
Yeet `owning_ref` Based on the discussions from https://github.com/rust-lang/rust/pull/109948 This replaces `owning_ref` with a far simpler & safer abstraction. Fixes #109974
This commit is contained in:
commit
0f0dc29264
13 changed files with 227 additions and 2012 deletions
|
@ -13,8 +13,7 @@ use object::{
|
|||
use snap::write::FrameEncoder;
|
||||
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::owning_ref::OwningRef;
|
||||
use rustc_data_structures::rustc_erase_owner;
|
||||
use rustc_data_structures::owned_slice::try_slice_owned;
|
||||
use rustc_data_structures::sync::MetadataRef;
|
||||
use rustc_metadata::fs::METADATA_FILENAME;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
|
@ -42,10 +41,10 @@ fn load_metadata_with(
|
|||
) -> Result<MetadataRef, String> {
|
||||
let file =
|
||||
File::open(path).map_err(|e| format!("failed to open file '{}': {}", path.display(), e))?;
|
||||
let data = unsafe { Mmap::map(file) }
|
||||
.map_err(|e| format!("failed to mmap file '{}': {}", path.display(), e))?;
|
||||
let metadata = OwningRef::new(data).try_map(f)?;
|
||||
return Ok(rustc_erase_owner!(metadata.map_owner_box()));
|
||||
|
||||
unsafe { Mmap::map(file) }
|
||||
.map_err(|e| format!("failed to mmap file '{}': {}", path.display(), e))
|
||||
.and_then(|mmap| try_slice_owned(mmap, |mmap| f(mmap)))
|
||||
}
|
||||
|
||||
impl MetadataLoader for DefaultMetadataLoader {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue