-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Adding Self: Sized
alters AsyncFnOnce
bounds
#137781
Comments
Minimized: fn run<F, T>(f: F)
where
F: AsyncFnOnce(i32),
(T,): Sized,
{
f(1i32);
}
|
@compiler-errors you probably know what's up |
This compiles fine, so the issue involves specifically the function call syntax sugar #![feature(async_fn_traits)]
fn run<F, T>(f: F)
where
F: AsyncFnOnce(i32),
(T,): Sized,
{
f.async_call_once((1i32,));
} |
This happens iff the arity of the input type of // This causes error
fn run<F, T>(f: F)
where
F: AsyncFnOnce(i32, i32),
(T, T): Sized,
{
f.async_call_once((1i32, 1i32));
}
// But not this
fn run<F, T>(f: F)
where
F: AsyncFnOnce(i32, i32),
(T,): Sized,
{
f.async_call_once((1i32, 1i32));
} |
In the following code @theemathas minimized: #![feature(async_fn_traits)]
fn run<F, T>(f: F)
where
F: AsyncFnOnce(i32),
(T,): Sized,
{
f.async_call_once((1i32,));
} It seems that while Anyway, the next-gen solver doesn't make such confusion. The above code compiles well with |
@rustbot label +fixed-by-next-solver |
This is morally equivalent to this failure in the old solver:
I can put up a fix for the |
I tried this code:
And got error
While removing
Self: Sized
bound solves the problem:use std::future::Future; pub trait Run<Ctx> { fn run(self, ctx: &mut Ctx) -> impl Future; } impl<Ctx, F, A> Run<Ctx> for (F, A) where F: AsyncFnOnce(&mut Ctx, A), - Self: Sized, { fn run(self, ctx: &mut Ctx) -> impl Future { let (f, a) = self; (f)(ctx, a) } }
The text was updated successfully, but these errors were encountered: