]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | // Ensure that a `#[track_caller]` function, returning `caller_location()`, |
2 | // which coerced (to a function pointer) and called, inside a `const fn`, | |
3 | // in turn called, results in the same output irrespective of whether | |
4 | // we're in a const or runtime context. | |
5 | ||
6 | // run-pass | |
7 | // compile-flags: -Z unleash-the-miri-inside-of-you | |
8 | ||
17df50a5 | 9 | #![feature(core_intrinsics, const_caller_location)] |
74b04a01 XL |
10 | |
11 | type L = &'static std::panic::Location<'static>; | |
12 | ||
13 | #[track_caller] | |
14 | const fn attributed() -> L { | |
15 | std::intrinsics::caller_location() | |
16 | } | |
17 | ||
18 | const fn calling_attributed() -> L { | |
19 | // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers. | |
20 | let ptr: fn() -> L = attributed; | |
f9f354fc | 21 | ptr() |
74b04a01 XL |
22 | } |
23 | ||
24 | fn main() { | |
25 | const CONSTANT: L = calling_attributed(); | |
26 | let runtime = calling_attributed(); | |
27 | ||
28 | assert_eq!( | |
29 | (runtime.file(), runtime.line(), runtime.column()), | |
30 | (CONSTANT.file(), CONSTANT.line(), CONSTANT.column()), | |
31 | ); | |
32 | } |