-
Notifications
You must be signed in to change notification settings - Fork 13.3k
impl Trait with associated type equality constraint fails to resolve when constraint contains associated type of non-parameter type #53984
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
Comments
Worth mentioning that using a boxed (i.e. type erased) iterator as the return type works just fine, i.e.: fn foo() -> Box<Iterator<Item = Input>> {
Box::new(once(Expr { ident: "my_string".to_string() }))
} |
Here's another instance of the same problem (playground): trait Future {
type Output;
}
impl<T> Future for T {
type Output = T;
}
trait Service<Request> {
type Error;
type Future: Future<Output = Self::Error>;
fn fail(&self, r: Request) -> Self::Future;
}
struct Foo;
struct A;
impl Service<A> for Foo {
type Error = ();
type Future = Self::Error;
fn fail(&self, r: A) -> Self::Future {
()
}
}
impl Foo {
fn fail_fast(&self) -> impl Future<Output = <Self as Service<A>>::Error> {
self.fail(A)
}
} And here too, boxing the return value instead of using |
I've hit this as well #![feature(impl_trait_in_bindings)]
trait Foo {
type Arg;
type Bar: Fn(&Self::Arg);
fn bar(&self) -> Self::Bar;
}
struct X;
impl X {
fn test<F>(this: F)
where
F: Foo<Arg = usize>,
{
let function: impl Fn(&F::Arg) = this.bar();
}
}
While this works as expected (missing the #![feature(impl_trait_in_bindings)]
trait Foo {
type Arg;
type Bar: Fn(&Self::Arg);
fn bar(&self) -> Self::Bar;
}
struct X;
impl X {
fn test<F>(this: F)
where
F: Foo,
{
let function: impl Fn(&F::Arg) = this.bar();
}
} |
I've hit this again, also on stable. I realize that sometimes, there is just not the manpower to tackle everyones issues, especially in OSS. Is there a way we could help with this? |
Further minimised on stable, playground: trait Foo {
type Arg;
type Assoc: Fn(Self::Arg);
fn assoc() -> Self::Assoc;
fn baz(_: Self::Assoc);
}
fn test<F: Foo<Arg = usize>>(this: F) {
F::baz(F::assoc());
} |
This comment has been minimized.
This comment has been minimized.
The above minimzation compiles when using chalk with |
With the somewhat recent update of chalk, it doesn't compile anymore and the issue is still present. |
The above minimization can be made to compile on stable when fully spelling out the bound: trait Foo {
type Arg;
type Assoc: Fn(Self::Arg);
fn assoc() -> Self::Assoc;
fn baz(_: Self::Assoc);
}
fn test<C: Fn(usize), F: Foo<Arg = usize, Assoc = C>>(this: F) {
F::baz(F::assoc());
} |
#55697 being closed made me re-check the status of this issue and now all of the above minimal examples now compile since Rust 1.49, so this issue can be closed i think :) |
Closing since fixed. |
The following code fails to compile:
I get this error message:
I think this case should work, since
<String as TokenSpec>::Ident
can be resolved at type checking time.The text was updated successfully, but these errors were encountered: