about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEllen <supbscripter@gmail.com>2021-09-25 00:34:02 +0100
committerEllen <supbscripter@gmail.com>2021-09-25 00:34:02 +0100
commitf1e71a5b41a0622c21952d23ddeba6f3d9025881 (patch)
tree7e8760986dc921f9545e67c0302ce50776365a04
parent73422130ee96c09e7214c876a3600ac1f32aa8c8 (diff)
downloadrust-f1e71a5b41a0622c21952d23ddeba6f3d9025881.tar.gz
rust-f1e71a5b41a0622c21952d23ddeba6f3d9025881.zip
arrr caught ya caller
awd

-rw-r--r--compiler/rustc_data_structures/src/steal.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs
index 30f659c2f71..a1ffbae8b15 100644
--- a/compiler/rustc_data_structures/src/steal.rs
+++ b/compiler/rustc_data_structures/src/steal.rs
@@ -33,10 +33,11 @@ impl<T> Steal<T> {
 
     #[track_caller]
     pub fn borrow(&self) -> MappedReadGuard<'_, T> {
-        ReadGuard::map(self.value.borrow(), |opt| match *opt {
-            None => panic!("attempted to read from stolen value"),
-            Some(ref v) => v,
-        })
+        let borrow = self.value.borrow();
+        if let None = &*borrow {
+            panic!("attempted to read from stolen value: {}", std::any::type_name::<T>());
+        }
+        ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
     }
 
     #[track_caller]