Skip to content

Commit f5f91cc

Browse files
committed
add a test for combining RPIT with explicit tail calls
1 parent 9312cd6 commit f5f91cc

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(explicit_tail_calls)]
2+
#![expect(incomplete_features)]
3+
4+
// Regression test for https://github.com/rust-lang/rust/issues/139305.
5+
//
6+
// Combining return position impl trait (RPIT) with guaranteed tail calls does not
7+
// currently work, but at least it does not ICE.
8+
9+
fn foo(x: u32, y: u32) -> u32 {
10+
x + y
11+
}
12+
13+
fn bar(x: u32, y: u32) -> impl ToString {
14+
become foo(x, y);
15+
//~^ ERROR mismatched signatures
16+
}
17+
18+
fn main() {
19+
assert_eq!(bar(1, 2).to_string(), "3");
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: mismatched signatures
2+
--> $DIR/rpit.rs:14:5
3+
|
4+
LL | become foo(x, y);
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
= note: `become` requires caller and callee to have matching signatures
8+
= note: caller signature: `fn(u32, u32) -> impl ToString`
9+
= note: callee signature: `fn(u32, u32) -> u32`
10+
11+
error: aborting due to 1 previous error
12+

0 commit comments

Comments
 (0)