forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that RPITITs have RPIT scope and not impl-wide scope
- Loading branch information
1 parent
ef04c97
commit 3f2574e
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
tests/ui/impl-trait/in-trait/sibling-function-constraint.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Checks that a sibling function (i.e. `foo`) cannot constrain | ||
// an RPITIT from another function (`bar`). | ||
|
||
trait Trait { | ||
fn foo(); | ||
|
||
fn bar() -> impl Sized; | ||
} | ||
|
||
impl Trait for () { | ||
fn foo() { | ||
let _: String = Self::bar(); | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
fn bar() -> impl Sized { | ||
loop {} | ||
} | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/sibling-function-constraint.rs:12:25 | ||
| | ||
LL | let _: String = Self::bar(); | ||
| ------ ^^^^^^^^^^^ expected `String`, found opaque type | ||
| | | ||
| expected due to this | ||
... | ||
LL | fn bar() -> impl Sized { | ||
| ---------- the found opaque type | ||
| | ||
= note: expected struct `String` | ||
found opaque type `impl Sized` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |