mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
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:
commit
218a96cae0
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user