Skip to content

Commit 39b633e

Browse files
authored
Rollup merge of #111947 - obeis:issue-111943, r=compiler-errors
Add test for RPIT defined with different hidden types with different substs Close #111943
2 parents 2daecf7 + b37cdc6 commit 39b633e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait Trait {}
2+
impl Trait for () {}
3+
4+
fn foo<T: Trait, U: Trait>() -> impl Trait {
5+
//~^ WARN function cannot return without recursing [unconditional_recursion]
6+
let a: T = foo::<T, U>();
7+
//~^ ERROR concrete type differs from previous defining opaque type use
8+
loop {}
9+
let _: T = foo::<U, T>();
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
warning: function cannot return without recursing
2+
--> $DIR/multiple-defining-usages-in-body.rs:4:1
3+
|
4+
LL | fn foo<T: Trait, U: Trait>() -> impl Trait {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
6+
LL |
7+
LL | let a: T = foo::<T, U>();
8+
| ------------- recursive call site
9+
|
10+
= help: a `loop` may express intention better if this is on purpose
11+
= note: `#[warn(unconditional_recursion)]` on by default
12+
13+
error: concrete type differs from previous defining opaque type use
14+
--> $DIR/multiple-defining-usages-in-body.rs:6:16
15+
|
16+
LL | let a: T = foo::<T, U>();
17+
| ^^^^^^^^^^^^^ expected `U`, got `T`
18+
|
19+
note: previous use here
20+
--> $DIR/multiple-defining-usages-in-body.rs:9:16
21+
|
22+
LL | let _: T = foo::<U, T>();
23+
| ^^^^^^^^^^^^^
24+
25+
error: aborting due to previous error; 1 warning emitted
26+

0 commit comments

Comments
 (0)