blob: 4db4c29e53d580b8b37191d1d4459d0b27512141 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// run-pass
macro_rules! assert_expansion_site_is_tracked {
() => {{
let location = std::panic::Location::caller();
assert_eq!(location.file(), file!());
assert_ne!(location.line(), line!(), "line should be outside this fn");
}}
}
trait Tracked {
fn local_tracked(&self);
#[track_caller]
fn blanket_tracked(&self);
#[track_caller]
fn default_tracked(&self) {
assert_expansion_site_is_tracked!();
}
}
impl Tracked for () {
#[track_caller]
fn local_tracked(&self) {
assert_expansion_site_is_tracked!();
}
fn blanket_tracked(&self) {
assert_expansion_site_is_tracked!();
}
}
impl Tracked for bool {
#[track_caller]
fn local_tracked(&self) {
assert_expansion_site_is_tracked!();
}
fn blanket_tracked(&self) {
assert_expansion_site_is_tracked!();
}
fn default_tracked(&self) {
assert_expansion_site_is_tracked!();
}
}
impl Tracked for u8 {
#[track_caller]
fn local_tracked(&self) {
assert_expansion_site_is_tracked!();
}
fn blanket_tracked(&self) {
assert_expansion_site_is_tracked!();
}
#[track_caller]
fn default_tracked(&self) {
assert_expansion_site_is_tracked!();
}
}
fn main() {
().local_tracked();
().default_tracked();
().blanket_tracked();
true.local_tracked();
true.default_tracked();
true.blanket_tracked();
0u8.local_tracked();
0u8.default_tracked();
0u8.blanket_tracked();
}
|