Skip to content

Commit 3f2574e

Browse files
Test that RPITITs have RPIT scope and not impl-wide scope
1 parent ef04c97 commit 3f2574e

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,21 @@
1+
// Checks that a sibling function (i.e. `foo`) cannot constrain
2+
// an RPITIT from another function (`bar`).
3+
4+
trait Trait {
5+
fn foo();
6+
7+
fn bar() -> impl Sized;
8+
}
9+
10+
impl Trait for () {
11+
fn foo() {
12+
let _: String = Self::bar();
13+
//~^ ERROR mismatched types
14+
}
15+
16+
fn bar() -> impl Sized {
17+
loop {}
18+
}
19+
}
20+
21+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/sibling-function-constraint.rs:12:25
3+
|
4+
LL | let _: String = Self::bar();
5+
| ------ ^^^^^^^^^^^ expected `String`, found opaque type
6+
| |
7+
| expected due to this
8+
...
9+
LL | fn bar() -> impl Sized {
10+
| ---------- the found opaque type
11+
|
12+
= note: expected struct `String`
13+
found opaque type `impl Sized`
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)