1
Fork 0

Add some tests to show what happens when you compare two opaque types that are both within the defining scope

This commit is contained in:
Oli Scherer 2022-01-26 17:20:48 +00:00
parent cbfd736292
commit 5a374dc813
4 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,20 @@
#![feature(type_alias_impl_trait)]
// check-pass
type A = impl Foo;
type B = impl Foo;
trait Foo {}
fn muh(x: A) -> B {
if false {
return Bar; // B's hidden type is Bar
}
x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other
}
struct Bar;
impl Foo for Bar {}
fn main() {}

View file

@ -0,0 +1,16 @@
#![feature(type_alias_impl_trait)]
type A = impl Foo;
//~^ ERROR could not find defining uses
type B = impl Foo;
trait Foo {}
fn muh(x: A) -> B {
x // B's hidden type is A (opaquely)
}
struct Bar;
impl Foo for Bar {}
fn main() {}

View file

@ -0,0 +1,8 @@
error: could not find defining uses
--> $DIR/two_tait_defining_each_other2.rs:3:10
|
LL | type A = impl Foo;
| ^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,20 @@
#![feature(type_alias_impl_trait)]
// check-pass
type A = impl Foo;
type B = impl Foo;
trait Foo {}
fn muh(x: A) -> B {
if false {
return x; // B's hidden type is A (opaquely)
}
Bar // A's hidden type is `Bar`, because all the return types are compared with each other
}
struct Bar;
impl Foo for Bar {}
fn main() {}