Skip to content

Commit f1e71a5

Browse files
committed
arrr caught ya caller
awd
1 parent 7342213 commit f1e71a5

File tree

1 file changed

+5
-4
lines changed
  • compiler/rustc_data_structures/src

1 file changed

+5
-4
lines changed

compiler/rustc_data_structures/src/steal.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ impl<T> Steal<T> {
3333

3434
#[track_caller]
3535
pub fn borrow(&self) -> MappedReadGuard<'_, T> {
36-
ReadGuard::map(self.value.borrow(), |opt| match *opt {
37-
None => panic!("attempted to read from stolen value"),
38-
Some(ref v) => v,
39-
})
36+
let borrow = self.value.borrow();
37+
if let None = &*borrow {
38+
panic!("attempted to read from stolen value: {}", std::any::type_name::<T>());
39+
}
40+
ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
4041
}
4142

4243
#[track_caller]

0 commit comments

Comments
 (0)