-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 detection of Send for async fn #53259
Comments
Simpler repro using generators directly (playground): fn bar() -> impl Generator + Send {
|| {
let bar: Box<dyn Send + 'static> = Box::new(5);
yield;
drop(bar)
}
}
It seems the issue is that |
Interestingly, this simpler example compiles fine: fn need_send<T: ?Sized + Send>() {}
fn main() {
need_send::<dyn Send>();
} So |
@Nemo157's error is very surprising, since I thought @cramertj had correctly identified the error here on the tracking issue:
That is, I thought a reference to receiver was being stored in its state because of the way the However, @Nemo157's is much more surprising |
For the record, |
Potentially related issue: #53548 (has the same |
Does not reproduce if you don't use #![feature(generators, generator_trait)]
use std::ops::Generator;
trait Foo: Send { }
impl Foo for u32 { }
fn bar() -> impl Generator + Send {
|| {
let bar: Box<dyn Foo + 'static> = Box::new(5);
yield;
drop(bar)
}
}
fn main() {} |
Using |
@nikomatsakis Looks like this issue has been fixed! It's one of the few issues I raised while trying to get code using a macro that expands to this to generate code that builds correctly. Basically, I've been minimizing the example to come up with this specific issue. As another minimized error was #53548 that isn't fixed yet I'd assume the overall code doesn't build yet, but I'll make sure to open another issue if I can minimize the original example to another reasonably small code chunk. I think this issue can be closed for now. Thank you! :) |
The following async function appears to not implement
Send
: (simpler reproducer at second post from @Nemo157 using generators)As
futures::channel::mpsc::Receiver
has an impl ofSend+Sync
when its generic parameter isSend
, andBox<Send + 'static>
isSend
, I would expect the future returned by this function to beSend
. However, when trying to require it, I get:I am not 100% sure this issue is actually tied to async/await, but removing the
await!
makes the issue vanish, so… cc #50547A full reproducer can be found here, but unfortunately doesn't compile on the playground due to lack of
futures-0.3
.The text was updated successfully, but these errors were encountered: