Skip to content

Commit

Permalink
Test that ReifyShim + caller_location return the def site.
Browse files Browse the repository at this point in the history
  • Loading branch information
anp committed Jan 19, 2020
1 parent 19d8527 commit 72dffac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ fn pass_to_ptr_call<T>(f: fn(T), x: T) {

#[track_caller]
fn tracked_unit(_: ()) {
assert_eq!(std::panic::Location::caller().file(), file!());
let expected_line = line!() - 1;
let location = std::panic::Location::caller();
assert_eq!(location.file(), file!());
assert_eq!(location.line(), expected_line, "call shims report location as fn definition");
}

fn main() {
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ fn ptr_call(f: fn()) {

#[track_caller]
fn tracked() {
assert_eq!(std::panic::Location::caller().file(), file!());
let expected_line = line!() - 1;
let location = std::panic::Location::caller();
assert_eq!(location.file(), file!());
assert_eq!(location.line(), expected_line, "call shims report location as fn definition");
}

fn main() {
Expand Down

0 comments on commit 72dffac

Please sign in to comment.