Skip to content

Commit c0b9b7a

Browse files
committed
Add failing test for codegen'd track_caller attribute.
1 parent cb61b93 commit c0b9b7a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// run-pass
2+
3+
#![feature(const_fn, core_intrinsics, track_caller)]
4+
5+
use std::{intrinsics::caller_location, panic::Location};
6+
7+
#[track_caller]
8+
fn tracked() -> &'static Location <'static> {
9+
caller_location()
10+
}
11+
12+
fn nested_intrinsic() -> &'static Location<'static> {
13+
caller_location()
14+
}
15+
16+
fn nested_tracked() -> &'static Location<'static> {
17+
tracked()
18+
}
19+
20+
fn main() {
21+
let location = caller_location();
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: the feature `track_caller` is incomplete and may cause the compiler to crash
2+
--> $DIR/track-caller-attribute.rs:3:39
3+
|
4+
LL | #![feature(const_fn, core_intrinsics, track_caller)]
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+

0 commit comments

Comments
 (0)