mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
add indirect call example to track-caller-ffi.rs
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
use std::panic::Location;
|
||||
|
||||
extern "Rust" {
|
||||
unsafe extern "Rust" {
|
||||
#[track_caller]
|
||||
fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>;
|
||||
fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>;
|
||||
safe fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>;
|
||||
safe fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>;
|
||||
}
|
||||
|
||||
fn rust_track_caller_ffi_test_nested_tracked() -> &'static Location<'static> {
|
||||
unsafe { rust_track_caller_ffi_test_tracked() }
|
||||
rust_track_caller_ffi_test_tracked()
|
||||
}
|
||||
|
||||
mod provides {
|
||||
@@ -31,12 +31,12 @@ fn main() {
|
||||
assert_eq!(location.line(), 29);
|
||||
assert_eq!(location.column(), 20);
|
||||
|
||||
let tracked = unsafe { rust_track_caller_ffi_test_tracked() };
|
||||
let tracked = rust_track_caller_ffi_test_tracked();
|
||||
assert_eq!(tracked.file(), file!());
|
||||
assert_eq!(tracked.line(), 34);
|
||||
assert_eq!(tracked.column(), 28);
|
||||
assert_eq!(tracked.column(), 19);
|
||||
|
||||
let untracked = unsafe { rust_track_caller_ffi_test_untracked() };
|
||||
let untracked = rust_track_caller_ffi_test_untracked();
|
||||
assert_eq!(untracked.file(), file!());
|
||||
assert_eq!(untracked.line(), 24);
|
||||
assert_eq!(untracked.column(), 9);
|
||||
@@ -44,5 +44,10 @@ fn main() {
|
||||
let contained = rust_track_caller_ffi_test_nested_tracked();
|
||||
assert_eq!(contained.file(), file!());
|
||||
assert_eq!(contained.line(), 12);
|
||||
assert_eq!(contained.column(), 14);
|
||||
assert_eq!(contained.column(), 5);
|
||||
|
||||
let indirect = (rust_track_caller_ffi_test_tracked as fn() -> &'static Location<'static>)();
|
||||
assert_eq!(indirect.file(), file!());
|
||||
assert_eq!(indirect.line(), 7);
|
||||
assert_eq!(indirect.column(), 5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user