Skip to content

Commit 218a96c

Browse files
committed
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``
2 parents 60fe8b3 + f1e71a5 commit 218a96c

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)