2
2
3
3
use std:: panic:: Location ;
4
4
5
- extern "Rust" {
5
+ unsafe extern "Rust" {
6
6
#[ track_caller]
7
- fn rust_track_caller_ffi_test_tracked ( ) -> & ' static Location < ' static > ;
8
- fn rust_track_caller_ffi_test_untracked ( ) -> & ' static Location < ' static > ;
7
+ safe fn rust_track_caller_ffi_test_tracked ( ) -> & ' static Location < ' static > ;
8
+ safe fn rust_track_caller_ffi_test_untracked ( ) -> & ' static Location < ' static > ;
9
9
}
10
10
11
11
fn rust_track_caller_ffi_test_nested_tracked ( ) -> & ' static Location < ' static > {
12
- unsafe { rust_track_caller_ffi_test_tracked ( ) }
12
+ rust_track_caller_ffi_test_tracked ( )
13
13
}
14
14
15
15
mod provides {
@@ -31,18 +31,23 @@ fn main() {
31
31
assert_eq ! ( location. line( ) , 29 ) ;
32
32
assert_eq ! ( location. column( ) , 20 ) ;
33
33
34
- let tracked = unsafe { rust_track_caller_ffi_test_tracked ( ) } ;
34
+ let tracked = rust_track_caller_ffi_test_tracked ( ) ;
35
35
assert_eq ! ( tracked. file( ) , file!( ) ) ;
36
36
assert_eq ! ( tracked. line( ) , 34 ) ;
37
- assert_eq ! ( tracked. column( ) , 28 ) ;
37
+ assert_eq ! ( tracked. column( ) , 19 ) ;
38
38
39
- let untracked = unsafe { rust_track_caller_ffi_test_untracked ( ) } ;
39
+ let untracked = rust_track_caller_ffi_test_untracked ( ) ;
40
40
assert_eq ! ( untracked. file( ) , file!( ) ) ;
41
41
assert_eq ! ( untracked. line( ) , 24 ) ;
42
42
assert_eq ! ( untracked. column( ) , 9 ) ;
43
43
44
44
let contained = rust_track_caller_ffi_test_nested_tracked ( ) ;
45
45
assert_eq ! ( contained. file( ) , file!( ) ) ;
46
46
assert_eq ! ( contained. line( ) , 12 ) ;
47
- assert_eq ! ( contained. column( ) , 14 ) ;
47
+ assert_eq ! ( contained. column( ) , 5 ) ;
48
+
49
+ let indirect = ( rust_track_caller_ffi_test_tracked as fn ( ) -> & ' static Location < ' static > ) ( ) ;
50
+ assert_eq ! ( indirect. file( ) , file!( ) ) ;
51
+ assert_eq ! ( indirect. line( ) , 7 ) ;
52
+ assert_eq ! ( indirect. column( ) , 5 ) ;
48
53
}
0 commit comments