-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Only generate closure def id for async fns with body #102244
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
let closure_id = match asyncness { | ||
Async::Yes { closure_id, .. } => closure_id, | ||
Async::No => return self.lower_fn_body_block(span, decl, body), | ||
let (closure_id, body) = match (asyncness, body) { |
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 means that when a (non-trait) async fn is lacking a body, we now lower it to <ExprKind::Err>
instead of wrapping it in an async
block first. This will not affect any code that currently compiles though.
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.
One nit and r=me.
// def-id for it. | ||
if body.is_some() { | ||
let closure_def = self.create_def(closure_id, DefPathData::ClosureExpr, span); | ||
self.with_parent(closure_def, |this| walk_list!(this, visit_block, body)); |
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.
Could you use an if let Some
and avoid the walk_list
here?
r? @cjgillot |
4043bb5
to
e99f6fe
Compare
@bors r=cjgillot |
…fee1-dead Rollup of 4 pull requests Successful merges: - rust-lang#101851 (Clean up (sub)diagnostic derives) - rust-lang#102244 (Only generate closure def id for async fns with body) - rust-lang#102263 (Clarify Iterator::rposition code example) - rust-lang#102280 (rustdoc: clean up `.out-of-band`/`.in-band` CSS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #102219