Skip to content

Commit 1f2d7db

Browse files
authored
Rollup merge of #148846 - folkertdev:tail-call-rpit, r=WaffleLapkin
add a test for combining RPIT with explicit tail calls tracking issue: #112788 fixes #139305 Combining return position impl trait (RPIT) with guaranteed tail calls does not currently work, but at least it does not ICE any more. Using RPIT probably should work, see also #144953. The snippet in the issue is not valid for a variety of reasons, and based on the assert that got triggered the ICE was just any `-> impl Trait` at all, so I've made a minimal example using RPIT. r? `@WaffleLapkin`
2 parents 20f111f + f5f91cc commit 1f2d7db

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)