2020-02-03 09:15:30 -06:00
|
|
|
// Ensure that a `#[track_caller]` function, returning `caller_location()`,
|
|
|
|
// which coerced (to a function pointer) and called, inside a `const fn`,
|
|
|
|
// in turn called, results in the same output irrespective of whether
|
|
|
|
// we're in a const or runtime context.
|
|
|
|
|
|
|
|
// run-pass
|
|
|
|
// compile-flags: -Z unleash-the-miri-inside-of-you
|
|
|
|
|
2021-05-07 11:56:16 -05:00
|
|
|
#![feature(core_intrinsics, const_caller_location)]
|
2020-02-03 09:15:30 -06:00
|
|
|
|
|
|
|
type L = &'static std::panic::Location<'static>;
|
|
|
|
|
|
|
|
#[track_caller]
|
|
|
|
const fn attributed() -> L {
|
|
|
|
std::intrinsics::caller_location()
|
|
|
|
}
|
|
|
|
|
2020-05-03 11:04:24 -05:00
|
|
|
const fn calling_attributed() -> L {
|
2020-02-03 09:15:30 -06:00
|
|
|
// We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers.
|
|
|
|
let ptr: fn() -> L = attributed;
|
2020-04-29 02:53:22 -05:00
|
|
|
ptr()
|
2020-02-03 09:15:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
const CONSTANT: L = calling_attributed();
|
|
|
|
let runtime = calling_attributed();
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
(runtime.file(), runtime.line(), runtime.column()),
|
|
|
|
(CONSTANT.file(), CONSTANT.line(), CONSTANT.column()),
|
|
|
|
);
|
|
|
|
}
|