Skip to content

Commit 72dffac

Browse files
committed
Test that ReifyShim + caller_location return the def site.
1 parent 19d8527 commit 72dffac

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ fn pass_to_ptr_call<T>(f: fn(T), x: T) {
88

99
#[track_caller]
1010
fn tracked_unit(_: ()) {
11-
assert_eq!(std::panic::Location::caller().file(), file!());
11+
let expected_line = line!() - 1;
12+
let location = std::panic::Location::caller();
13+
assert_eq!(location.file(), file!());
14+
assert_eq!(location.line(), expected_line, "call shims report location as fn definition");
1215
}
1316

1417
fn main() {

src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ fn ptr_call(f: fn()) {
88

99
#[track_caller]
1010
fn tracked() {
11-
assert_eq!(std::panic::Location::caller().file(), file!());
11+
let expected_line = line!() - 1;
12+
let location = std::panic::Location::caller();
13+
assert_eq!(location.file(), file!());
14+
assert_eq!(location.line(), expected_line, "call shims report location as fn definition");
1215
}
1316

1417
fn main() {

0 commit comments

Comments
 (0)