-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Do not propose to remove async move
if variables are captured by ref
#10490
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
Conversation
r? @xFrednet (rustbot has picked a reviewer for you, use r? to override) |
The |
a0a3d1f
to
fe10b58
Compare
Is there an estimated release date for this, our codebase is running into this quite a bit when we launch tasks to drive components |
!future.span.from_expansion() && | ||
!await_in_expr(future) | ||
{ | ||
if matches!(capture, CaptureBy::Value) && captured_by_ref(last) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix is rather incomplete because CaptureBy::Ref
can also move a value into the closure:
use std::future::Future;
async fn work(_: &str) {}
fn spawn(_: impl Future<Output = ()> + 'static) {}
fn main() {
let val = "Hello World".to_owned();
spawn(async { work(&{ val }).await }); // false-positive
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, fixed.
66f3ebf
to
d84b246
Compare
I also propose to put the lint in nursery for the time being, notably because of #10509. |
Hey, thank you for the PR and comments left by others. I'll sadly be busy until the end of the week, but you'll get a review by the end of next week :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me, I have a few questions, regarding names and documentation, but I'd say this is ready, once they've been cleared up.
Thank you for your patience, while waiting for the review :)
d84b246
to
3497086
Compare
Looks good to me, thank you! @bors r+ I've added the |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This will make it into the same release as the commit that added the lint. No action required. |
Fixes #10482
changelog: FP [
redundant_async_block
] Do not propose to removeasync move
if variables are captured by ref