Skip to content

Commit f82100e

Browse files
authored
Rollup merge of #81125 - jyn514:track-caller, r=lcnr
Add track_caller to .steal() Before: ``` thread 'rustc' panicked at 'attempt to read from stolen value', /home/joshua/rustc/compiler/rustc_data_structures/src/steal.rs:43:15 ``` After: ``` thread 'rustc' panicked at 'attempt to steal from stolen value', compiler/rustc_mir/src/transform/mod.rs:423:25 ``` r? `@lcnr`
2 parents 0654e20 + 394d701 commit f82100e

File tree

1 file changed

+3
-1
lines changed
  • compiler/rustc_data_structures/src

1 file changed

+3
-1
lines changed

compiler/rustc_data_structures/src/steal.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ impl<T> Steal<T> {
3030
Steal { value: RwLock::new(Some(value)) }
3131
}
3232

33+
#[track_caller]
3334
pub fn borrow(&self) -> MappedReadGuard<'_, T> {
3435
ReadGuard::map(self.value.borrow(), |opt| match *opt {
3536
None => panic!("attempted to read from stolen value"),
3637
Some(ref v) => v,
3738
})
3839
}
3940

41+
#[track_caller]
4042
pub fn steal(&self) -> T {
4143
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
4244
let value = value_ref.take();
43-
value.expect("attempt to read from stolen value")
45+
value.expect("attempt to steal from stolen value")
4446
}
4547
}
4648

0 commit comments

Comments
 (0)