]> git.proxmox.com Git - rustc.git/blame - src/test/ui/rfc-2091-track-caller/intrinsic-wrapper.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / rfc-2091-track-caller / intrinsic-wrapper.rs
CommitLineData
60c5eb7d 1// run-pass
29967ef6 2// revisions: default mir-opt
6a06907d 3//[mir-opt] compile-flags: -Zmir-opt-level=4
60c5eb7d 4
60c5eb7d
XL
5macro_rules! caller_location_from_macro {
6 () => (core::panic::Location::caller());
7}
8
9fn main() {
10 let loc = core::panic::Location::caller();
11 assert_eq!(loc.file(), file!());
29967ef6 12 assert_eq!(loc.line(), 10);
60c5eb7d
XL
13 assert_eq!(loc.column(), 15);
14
15 // `Location::caller()` in a macro should behave similarly to `file!` and `line!`,
16 // i.e. point to where the macro was invoked, instead of the macro itself.
17 let loc2 = caller_location_from_macro!();
18 assert_eq!(loc2.file(), file!());
29967ef6 19 assert_eq!(loc2.line(), 17);
60c5eb7d
XL
20 assert_eq!(loc2.column(), 16);
21}