]> git.lizzy.rs Git - rust.git/blob - example/track-caller-attribute.rs
Implement sym operands for global asm
[rust.git] / example / track-caller-attribute.rs
1 // Based on https://github.com/anp/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
2
3 // run-pass
4
5 use std::panic::Location;
6
7 #[track_caller]
8 fn tracked() -> &'static Location<'static> {
9     Location::caller()
10 }
11
12 fn nested_intrinsic() -> &'static Location<'static> {
13     Location::caller()
14 }
15
16 fn nested_tracked() -> &'static Location<'static> {
17     tracked()
18 }
19
20 fn main() {
21     let location = Location::caller();
22     assert_eq!(location.file(), file!());
23     assert_eq!(location.line(), 21);
24     assert_eq!(location.column(), 20);
25
26     let tracked = tracked();
27     assert_eq!(tracked.file(), file!());
28     assert_eq!(tracked.line(), 26);
29     assert_eq!(tracked.column(), 19);
30
31     let nested = nested_intrinsic();
32     assert_eq!(nested.file(), file!());
33     assert_eq!(nested.line(), 13);
34     assert_eq!(nested.column(), 5);
35
36     let contained = nested_tracked();
37     assert_eq!(contained.file(), file!());
38     assert_eq!(contained.line(), 17);
39     assert_eq!(contained.column(), 5);
40 }