Add test for issue #79636

This commit is contained in:
marmeladema 2021-04-20 23:33:13 +01:00
parent b6647b5692
commit 19e51aaef7
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
trait Monad {
type Unwrapped;
type Wrapped<B>;
//~^ ERROR: missing generics for associated type `Monad::Wrapped`
fn bind<B, F>(self, f: F) -> Self::Wrapped<B> {
todo!()
}
}
fn join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A>
where
MOuter: Monad<Unwrapped = MInner>,
MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>,
{
outer.bind(|inner| inner)
}
fn main() {
assert_eq!(join(Some(Some(true))), Some(true));
}

View File

@ -0,0 +1,19 @@
error[E0107]: missing generics for associated type `Monad::Wrapped`
--> $DIR/issue-79636-1.rs:6:10
|
LL | type Wrapped<B>;
| ^^^^^^^ expected 1 type argument
|
note: associated type defined here, with 1 type parameter: `B`
--> $DIR/issue-79636-1.rs:6:10
|
LL | type Wrapped<B>;
| ^^^^^^^ -
help: use angle brackets to add missing type argument
|
LL | type Wrapped<B><B>;
| ^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0107`.

View File

@ -0,0 +1,18 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
trait SomeTrait {
type Wrapped<A>: SomeTrait;
//~^ ERROR: missing generics for associated type `SomeTrait::Wrapped`
fn f() -> ();
}
fn program<W>() -> ()
where
W: SomeTrait<Wrapped = W>,
{
return W::f();
}
fn main() {}

View File

@ -0,0 +1,19 @@
error[E0107]: missing generics for associated type `SomeTrait::Wrapped`
--> $DIR/issue-79636-2.rs:5:10
|
LL | type Wrapped<A>: SomeTrait;
| ^^^^^^^ expected 1 type argument
|
note: associated type defined here, with 1 type parameter: `A`
--> $DIR/issue-79636-2.rs:5:10
|
LL | type Wrapped<A>: SomeTrait;
| ^^^^^^^ -
help: use angle brackets to add missing type argument
|
LL | type Wrapped<A><A>: SomeTrait;
| ^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0107`.