]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_data_structures/src/steal.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / compiler / rustc_data_structures / src / steal.rs
index 30f659c2f71bd209946b6b94006f35eb235ccaa5..a3ece6550473cce4ce080bbdc5e28f15b69e1cc2 100644 (file)
@@ -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 borrow.is_none() {
+            panic!("attempted to read from stolen value: {}", std::any::type_name::<T>());
+        }
+        ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
     }
 
     #[track_caller]