]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-eval/const_caller_location.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / const_caller_location.rs
CommitLineData
e74abb32
XL
1// run-pass
2
3#![feature(const_fn, core_intrinsics)]
4
5use std::{intrinsics::caller_location, panic::Location};
6
7const LOCATION: &Location = caller_location();
8const NESTED: &Location = {
9 const fn nested_location() -> &'static Location<'static> {
10 caller_location()
11 };
12 nested_location()
13};
14
15fn main() {
16 assert_eq!(LOCATION.file(), file!());
17 assert_eq!(LOCATION.line(), 7);
18 assert_eq!(LOCATION.column(), 29);
19
20 assert_eq!(NESTED.file(), file!());
21 assert_eq!(NESTED.line(), 10);
22 assert_eq!(NESTED.column(), 9);
23}