We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7342213 commit f1e71a5Copy full SHA for f1e71a5
compiler/rustc_data_structures/src/steal.rs
@@ -33,10 +33,11 @@ impl<T> Steal<T> {
33
34
#[track_caller]
35
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
- })
+ let borrow = self.value.borrow();
+ if let None = &*borrow {
+ panic!("attempted to read from stolen value: {}", std::any::type_name::<T>());
+ }
40
+ ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
41
}
42
43
0 commit comments