Skip to content
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

Merged
merged 2 commits into from
Sep 26, 2022

Conversation

compiler-errors
Copy link
Member

Fixes #102219

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 24, 2022
@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 24, 2022
@compiler-errors compiler-errors added the F-async_fn_in_trait Static async fn in traits label Sep 24, 2022
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) {
Copy link
Member Author

@compiler-errors compiler-errors Sep 24, 2022

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.

Copy link
Contributor

@cjgillot cjgillot left a 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));
Copy link
Contributor

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?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 25, 2022

r? @cjgillot

@rust-highfive rust-highfive assigned cjgillot and unassigned oli-obk Sep 25, 2022
@compiler-errors
Copy link
Member Author

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Sep 25, 2022

📌 Commit e99f6fe has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 26, 2022
…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
@bors bors merged commit c807277 into rust-lang:master Sep 26, 2022
@rustbot rustbot added this to the 1.66.0 milestone Sep 26, 2022
@compiler-errors compiler-errors deleted the issue-102219 branch November 2, 2022 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-async_fn_in_trait Static async fn in traits S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE with async trait in lib crate
6 participants