Skip to content

Commit 65e7db6

Browse files
committed
Add a test for mismatch in #[track_caller] wrt tail calls
1 parent 1d8efed commit 65e7db6

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(explicit_tail_calls)]
2+
use std::panic::Location;
3+
4+
fn get_some_location1() -> &'static Location<'static> {
5+
#[track_caller]
6+
fn inner() -> &'static Location<'static> {
7+
become Location::caller()
8+
}
9+
10+
become inner()
11+
//~^ error: a function mot marked with `#[track_caller]` cannot tail-call one that is
12+
}
13+
14+
#[track_caller]
15+
fn get_some_location2() -> &'static Location<'static> {
16+
fn inner() -> &'static Location<'static> {
17+
become Location::caller()
18+
//~^ error: a function mot marked with `#[track_caller]` cannot tail-call one that is
19+
}
20+
21+
become inner()
22+
//~^ error: a function marked with `#[track_caller]` cannot tail-call one that is not
23+
}
24+
25+
fn main() {
26+
get_some_location1();
27+
get_some_location2();
28+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: a function mot marked with `#[track_caller]` cannot tail-call one that is
2+
--> $DIR/caller-location-mismatch.rs:10:5
3+
|
4+
LL | become inner()
5+
| ^^^^^^^^^^^^^^
6+
7+
error: a function marked with `#[track_caller]` cannot tail-call one that is not
8+
--> $DIR/caller-location-mismatch.rs:21:5
9+
|
10+
LL | become inner()
11+
| ^^^^^^^^^^^^^^
12+
13+
error: a function mot marked with `#[track_caller]` cannot tail-call one that is
14+
--> $DIR/caller-location-mismatch.rs:17:9
15+
|
16+
LL | become Location::caller()
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: aborting due to 3 previous errors
20+

0 commit comments

Comments
 (0)