2019-10-24 10:03:57 -05:00
|
|
|
// run-pass
|
|
|
|
|
2020-05-21 18:43:39 -05:00
|
|
|
#![feature(const_caller_location, const_fn)]
|
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!());
|
|
|
|
assert_eq!(LOCATION.line(), 7);
|
|
|
|
assert_eq!(LOCATION.column(), 29);
|
|
|
|
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(TRACKED.file(), file!());
|
|
|
|
assert_eq!(TRACKED.line(), 9);
|
|
|
|
assert_eq!(TRACKED.column(), 28);
|
|
|
|
|
2019-10-24 10:03:57 -05:00
|
|
|
assert_eq!(NESTED.file(), file!());
|
2019-11-11 10:45:52 -06:00
|
|
|
assert_eq!(NESTED.line(), 17);
|
|
|
|
assert_eq!(NESTED.column(), 5);
|
|
|
|
|
|
|
|
assert_eq!(CONTAINED.file(), file!());
|
|
|
|
assert_eq!(CONTAINED.line(), 22);
|
|
|
|
assert_eq!(CONTAINED.column(), 5);
|
2019-10-24 10:03:57 -05:00
|
|
|
}
|