Skip to content

Commit

Permalink
Add test for issue #79636
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Apr 20, 2021
1 parent b6647b5 commit 19e51aa
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/ui/generic-associated-types/issue-79636-1.rs
Original file line number Diff line number Diff line change
@@ -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));
}
19 changes: 19 additions & 0 deletions src/test/ui/generic-associated-types/issue-79636-1.stderr
Original file line number Diff line number Diff line change
@@ -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`.
18 changes: 18 additions & 0 deletions src/test/ui/generic-associated-types/issue-79636-2.rs
Original file line number Diff line number Diff line change
@@ -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() {}
19 changes: 19 additions & 0 deletions src/test/ui/generic-associated-types/issue-79636-2.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 19e51aa

Please sign in to comment.