Rollup merge of #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 #68178.
This commit is contained in:
commit
8d2bac8dff
4 changed files with 100 additions and 31 deletions
19
src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs
Normal file
19
src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs
Normal file
|
|
@ -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, ());
|
||||
}
|
||||
19
src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs
Normal file
19
src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs
Normal file
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue