#![feature(generic_associated_types)]
trait A {
type I<'a>;
}
pub struct TestA<F>
{
f: F,
}
impl<F> A for TestA<F> {
type I<'a> = &'a F;
}
struct TestB<Q, F>
{
q: Q,
f: F,
}
impl<'q, Q, I, F> A for TestB<Q, F>
where
Q: A<I<'q> = &'q I>,
F: Fn(I),
{
type I<'a> = ();
}
I expected it to compile. Instead, I've got the following error:
error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
--> src/lib.rs:22:13
|
22 | impl<'q, Q, I, F> A for TestB<Q, F>
| ^ unconstrained type parameter
For more information about this error, try `rustc --explain E0207`.
error: could not compile `playground` due to previous error
I'm not 100% sure that this is a bug, but the fact, that adding a GAT parameter to (as it seems) an unrelated type produces such an error, looks strange to me.
I tried this code:
I expected it to compile. Instead, I've got the following error:
If I remove the GAT, the code compiles successfully. I've created the following two playground examples to play around with (the first one compiles, the second one doesn't): https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=15548086c5da59870ffbf5b4fe4de27a https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=725c4e36f367bd3b1ba30917cfc38b65
I'm not 100% sure that this is a bug, but the fact, that adding a GAT parameter to (as it seems) an unrelated type produces such an error, looks strange to me.
Meta
rustc --version --verbose
: