mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Test that RPITITs have RPIT scope and not impl-wide scope
This commit is contained in:
parent
ef04c9795b
commit
3f2574e8ba
21
tests/ui/impl-trait/in-trait/sibling-function-constraint.rs
Normal file
21
tests/ui/impl-trait/in-trait/sibling-function-constraint.rs
Normal file
@ -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() {}
|
@ -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`.
|
Loading…
Reference in New Issue
Block a user