File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ impl Once {
256
256
///
257
257
/// [poison]: struct.Mutex.html#poisoning
258
258
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
259
+ #[ track_caller]
259
260
pub fn call_once < F > ( & self , f : F )
260
261
where
261
262
F : FnOnce ( ) ,
@@ -390,6 +391,7 @@ impl Once {
390
391
// currently no way to take an `FnOnce` and call it via virtual dispatch
391
392
// without some allocation overhead.
392
393
#[ cold]
394
+ #[ track_caller]
393
395
fn call_inner ( & self , ignore_poisoning : bool , init : & mut dyn FnMut ( & OnceState ) ) {
394
396
let mut state_and_queue = self . state_and_queue . load ( Ordering :: Acquire ) ;
395
397
loop {
Original file line number Diff line number Diff line change
1
+ // test for #87707
2
+ // edition:2018
3
+ // run-fail
4
+ // check-run-results
5
+
6
+ use std:: sync:: Once ;
7
+ use std:: panic;
8
+
9
+ fn main ( ) {
10
+ let o = Once :: new ( ) ;
11
+ let _ = panic:: catch_unwind ( || {
12
+ o. call_once ( || panic ! ( "Here Once instance is poisoned." ) ) ;
13
+ } ) ;
14
+ o. call_once ( || { } ) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:12:24
2
+ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3
+ thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:14:7
You can’t perform that action at this time.
0 commit comments