Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test for issue #79636
  • Loading branch information
marmeladema committed Apr 20, 2021
commit 19e51aaef7cf2f7a9e0e72168caf73a94a1cbfb1
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`.