Auto merge of #89237 - BoxyUwU:trackersMcCaller, r=eddyb

make `#[track_caller]` actually do stuff in `Steal::borrow`

makes this ICE message useful:
``thread 'rustc' panicked at 'attempted to read from stolen value', /rustc/ac2d9fc509e36d1b32513744adf58c34bcc4f43c\compiler\rustc_data_structures\src\steal.rs:37:21``
This commit is contained in:
bors 2021-09-25 07:33:25 +00:00
commit 218a96cae0

View 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 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]