Skip to content

Commit 801a69c

Browse files
committed
Add a regression test for an ICE when using an explicit tail call in a default trait method's implementation.
1 parent e409fd2 commit 801a69c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// A regression test for <https://github.com/rust-lang/rust/issues/144985>.
2+
// Previously, using `become` in a default trait method would lead to an ICE
3+
// in a path determining whether the method in question is marked as `#[track_caller]`.
4+
//
5+
//@ run-pass
6+
7+
#![feature(explicit_tail_calls)]
8+
#![expect(incomplete_features)]
9+
10+
trait Trait {
11+
fn bar(&self) -> usize {
12+
123
13+
}
14+
15+
fn foo(&self) -> usize {
16+
become self.bar();
17+
}
18+
}
19+
20+
struct Struct;
21+
22+
impl Trait for Struct {}
23+
24+
struct OtherStruct;
25+
26+
impl Trait for OtherStruct {
27+
#[track_caller]
28+
fn bar(&self) -> usize {
29+
456
30+
}
31+
}
32+
33+
fn main() {
34+
assert_eq!(Struct.foo(), 123);
35+
assert_eq!(OtherStruct.foo(), 456);
36+
}

0 commit comments

Comments
 (0)