Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a regression test for issue-63355 #86763

Merged
merged 1 commit into from
Jul 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-63355.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#![feature(min_type_alias_impl_trait)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]

pub trait Foo {}

pub trait Bar {
type Foo: Foo;

fn foo() -> Self::Foo;
}

pub trait Baz {
type Foo: Foo;
type Bar: Bar<Foo = Self::Foo>;

fn foo() -> Self::Foo;
fn bar() -> Self::Bar;
}

impl Foo for () {}

impl Bar for () {
type Foo = FooImpl;

fn foo() -> Self::Foo {
()
}
}

// FIXME(#86731): The below is illegal use of `min_type_alias_impl_trait`
// but the compiler doesn't report it, we should fix it.
pub type FooImpl = impl Foo;
pub type BarImpl = impl Bar<Foo = FooImpl>;
//~^ ERROR: type mismatch resolving `<() as Bar>::Foo == ()`

impl Baz for () {
type Foo = FooImpl;
type Bar = BarImpl;

fn foo() -> Self::Foo {
()
}

fn bar() -> Self::Bar {
()
}
}

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/type-alias-impl-trait/issue-63355.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()`
--> $DIR/issue-63355.rs:34:20
|
LL | pub type FooImpl = impl Foo;
| -------- the found opaque type
LL | pub type BarImpl = impl Bar<Foo = FooImpl>;
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type
|
= note: expected unit type `()`
found opaque type `impl Foo`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0271`.