2019-10-24 10:03:57 -05:00
|
|
|
// run-pass
|
2020-02-08 15:46:57 -06:00
|
|
|
// revisions: default mir-opt
|
2021-03-04 07:21:13 -06:00
|
|
|
//[mir-opt] compile-flags: -Zmir-opt-level=4
|
2019-10-24 10:03:57 -05:00
|
|
|
|
2021-05-07 11:56:16 -05:00
|
|
|
#![feature(const_caller_location)]
|
2019-10-24 10:03:57 -05:00
|
|
|
|
2019-11-10 15:11:25 -06:00
|
|
|
use std::panic::Location;
|
2019-10-24 10:03:57 -05:00
|
|
|
|
2019-11-10 15:11:25 -06:00
|
|
|
const LOCATION: &Location = Location::caller();
|
2019-11-11 10:45:52 -06:00
|
|
|
|
|
|
|
const TRACKED: &Location = tracked();
|
|
|
|
#[track_caller]
|
|
|
|
const fn tracked() -> &'static Location <'static> {
|
2019-11-10 15:11:25 -06:00
|
|
|
Location::caller()
|
2019-11-11 10:45:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const NESTED: &Location = nested_location();
|
|
|
|
const fn nested_location() -> &'static Location<'static> {
|
2019-11-10 15:11:25 -06:00
|
|
|
Location::caller()
|
2019-11-11 10:45:52 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const CONTAINED: &Location = contained();
|
|
|
|
const fn contained() -> &'static Location<'static> {
|
|
|
|
tracked()
|
|
|
|
}
|
2019-10-24 10:03:57 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(LOCATION.file(), file!());
|
2020-02-08 15:46:57 -06:00
|
|
|
assert_eq!(LOCATION.line(), 9);
|
2019-10-24 10:03:57 -05:00
|
|
|
assert_eq!(LOCATION.column(), 29);
|
|
|
|
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(TRACKED.file(), file!());
|
2020-02-08 15:46:57 -06:00
|
|
|
assert_eq!(TRACKED.line(), 11);
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(TRACKED.column(), 28);
|
|
|
|
|
2019-10-24 10:03:57 -05:00
|
|
|
assert_eq!(NESTED.file(), file!());
|
2020-02-08 15:46:57 -06:00
|
|
|
assert_eq!(NESTED.line(), 19);
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(NESTED.column(), 5);
|
|
|
|
|
|
|
|
assert_eq!(CONTAINED.file(), file!());
|
2020-02-08 15:46:57 -06:00
|
|
|
assert_eq!(CONTAINED.line(), 24);
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(CONTAINED.column(), 5);
|
2019-10-24 10:03:57 -05:00
|
|
|
}
|