-
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
Missing Send
on "recursive" Future
#135062
Labels
A-async-await
Area: Async & Await
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Comments
A few variations: fn spawn<T: Send>(_: T) { }
fn foo() -> impl std::future::Future<Output = ()> {
spawn(async { foo().await; });
async {}
} Error output
fn spawn<T: Send>(_: T) { }
fn foo() -> impl std::future::Future<Output = ()> {
spawn(async { let _x = foo(); async {}.await; });
async {}
} Error output
fn spawn<T: Send>(_: T) { }
fn foo() -> impl std::future::Future<Output = ()> {
spawn(foo());
async {}
} Error output
|
A version that doesn't use async-await: trait Trait {}
impl Trait for i32 {}
fn require_send(_: impl Send) {}
fn foo() -> impl Trait {
require_send(foo());
123
} Error output
|
Oddly enough, I could cause the same issue with a const block, but not with a const item. const fn require_send(_: impl Send + Copy) {}
const fn foo() -> impl Copy {
const { require_send(foo()); }
123
} Error output
|
Temporarily I'm avoiding the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-async-await
Area: Async & Await
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Yesterday in the rust community discord, we came across the following (minimized) example.
I don't understand why these futures aren't
Send
. Obviously,bar
can only beSend
iffoo
is as well. However, whilebar
requiresfoo
to beSend
in order to successfully type-check, it'sSend
ness shouldn't depend on it.I tried this code:
I expected to see this happen: I believe the code should compile.
Instead, this happened:
Meta
rustc --version --verbose
:This also happens on stable
rustc 1.83.0
.Before
rustc 1.75
the type checker encounters a cycle instead.With
-Znext-solver
there's an ICE.The text was updated successfully, but these errors were encountered: