diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-21 07:32:45 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-21 07:32:45 +0900 |
| commit | 8d2bac8dff232f3e5ee3208c22865136a370ca72 (patch) | |
| tree | bfe5d992d0675376071b1ae4673e4b540aaa97cf /src/test | |
| parent | bff216c56f472dd751d3da636027d5e2d821e979 (diff) | |
| parent | 72dffac6cf170c6c16c043299e35848014aae8d4 (diff) | |
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.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs | 19 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs b/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs new file mode 100644 index 00000000000..0407eafbfd4 --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs @@ -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, ()); +} diff --git a/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs b/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs new file mode 100644 index 00000000000..a4baaa26ced --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/tracked-fn-ptr.rs @@ -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); +} |
