File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
#![ feature( option_expect_none, option_unwrap_none) ]
2
-
3
2
//! Test that panic locations for `#[track_caller]` functions in std have the correct
4
3
//! location reported.
5
4
5
+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
6
+
7
+ static HOOK_COUNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
8
+
6
9
fn main ( ) {
7
10
// inspect the `PanicInfo` we receive to ensure the right file is the source
8
11
std:: panic:: set_hook ( Box :: new ( |info| {
12
+ HOOK_COUNT . fetch_add ( 1 , Ordering :: Relaxed ) ;
9
13
let actual = info. location ( ) . unwrap ( ) ;
10
14
if actual. file ( ) != file ! ( ) {
11
15
eprintln ! ( "expected a location in the test file, found {:?}" , actual) ;
@@ -35,4 +39,6 @@ fn main() {
35
39
36
40
// Cleanup: reset to default hook.
37
41
drop ( std:: panic:: take_hook ( ) ) ;
42
+
43
+ assert_eq ! ( HOOK_COUNT . load( Ordering :: Relaxed ) , 8 ) ;
38
44
}
You can’t perform that action at this time.
0 commit comments