]>
Commit | Line | Data |
---|---|---|
dfeec247 | 1 | // run-pass |
29967ef6 | 2 | // revisions: default mir-opt |
6a06907d | 3 | //[mir-opt] compile-flags: -Zmir-opt-level=4 |
dfeec247 | 4 | |
dfeec247 XL |
5 | fn ptr_call(f: fn()) { |
6 | f(); | |
7 | } | |
8 | ||
9 | #[track_caller] | |
10 | fn tracked() { | |
11 | let expected_line = line!() - 1; | |
12 | let location = std::panic::Location::caller(); | |
13 | assert_eq!(location.file(), file!()); | |
14 | assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); | |
15 | } | |
16 | ||
ba9703b0 XL |
17 | trait Trait { |
18 | fn trait_tracked(); | |
19 | } | |
20 | ||
21 | impl Trait for () { | |
22 | #[track_caller] | |
23 | fn trait_tracked() { | |
24 | let expected_line = line!() - 1; | |
25 | let location = std::panic::Location::caller(); | |
26 | assert_eq!(location.file(), file!()); | |
27 | assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); | |
28 | } | |
29 | } | |
30 | ||
31 | trait TrackedTrait { | |
32 | #[track_caller] | |
33 | fn trait_tracked_default() { | |
34 | let expected_line = line!() - 1; | |
35 | let location = std::panic::Location::caller(); | |
36 | assert_eq!(location.file(), file!()); | |
37 | assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); | |
38 | } | |
39 | } | |
40 | ||
41 | impl TrackedTrait for () {} | |
42 | ||
43 | trait TraitBlanketTracked { | |
44 | #[track_caller] | |
45 | fn tracked_blanket(); | |
46 | } | |
47 | ||
48 | impl TraitBlanketTracked for () { | |
49 | fn tracked_blanket() { | |
50 | let expected_line = line!() - 1; | |
51 | let location = std::panic::Location::caller(); | |
52 | assert_eq!(location.file(), file!()); | |
53 | assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); | |
54 | } | |
55 | } | |
56 | ||
dfeec247 XL |
57 | fn main() { |
58 | ptr_call(tracked); | |
ba9703b0 XL |
59 | ptr_call(<() as Trait>::trait_tracked); |
60 | ptr_call(<() as TrackedTrait>::trait_tracked_default); | |
61 | ptr_call(<() as TraitBlanketTracked>::tracked_blanket); | |
dfeec247 | 62 | } |