forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#68302 - anp:caller-fn-ptr, r=eddyb,oli-obk
Fix #[track_caller] and function pointers Starting with failing tests, fix the miscompilation and ICE caused by `ReifyShim` bug. Fixes rust-lang#68178.
- Loading branch information
Showing
4 changed files
with
97 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// run-pass | ||
|
||
#![feature(track_caller)] | ||
|
||
fn pass_to_ptr_call<T>(f: fn(T), x: T) { | ||
f(x); | ||
} | ||
|
||
#[track_caller] | ||
fn tracked_unit(_: ()) { | ||
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() { | ||
pass_to_ptr_call(tracked_unit, ()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// run-pass | ||
|
||
#![feature(track_caller)] | ||
|
||
fn ptr_call(f: fn()) { | ||
f(); | ||
} | ||
|
||
#[track_caller] | ||
fn tracked() { | ||
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() { | ||
ptr_call(tracked); | ||
} |