diff options
| author | Ellen <supbscripter@gmail.com> | 2021-09-25 00:34:02 +0100 |
|---|---|---|
| committer | Ellen <supbscripter@gmail.com> | 2021-09-25 00:34:02 +0100 |
| commit | f1e71a5b41a0622c21952d23ddeba6f3d9025881 (patch) | |
| tree | 7e8760986dc921f9545e67c0302ce50776365a04 | |
| parent | 73422130ee96c09e7214c876a3600ac1f32aa8c8 (diff) | |
| download | rust-f1e71a5b41a0622c21952d23ddeba6f3d9025881.tar.gz rust-f1e71a5b41a0622c21952d23ddeba6f3d9025881.zip | |
arrr caught ya caller
awd
| -rw-r--r-- | compiler/rustc_data_structures/src/steal.rs | 9 |
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] |
