about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-08 01:08:26 +0000
committerbors <bors@rust-lang.org>2023-04-08 01:08:26 +0000
commit0f0dc292641cb29f441e979ea26f10e1402b931f (patch)
treeb8a5a4288da1476c4fa7264b52f116bc5848a63f /compiler/rustc_codegen_ssa/src/back
parentba86600c9452508a0ab05cd4bdc9af4c96f7d4ba (diff)
parentfbe0591c6897216042a201795185bc0c0dac42c1 (diff)
downloadrust-0f0dc292641cb29f441e979ea26f10e1402b931f.tar.gz
rust-0f0dc292641cb29f441e979ea26f10e1402b931f.zip
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
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/metadata.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index 4ab56699922..3e3fcc08bd6 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -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 {