Skip to content

Place tail expression behind terminating scope #125293

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

dingxiangfei2009
Copy link
Contributor

This PR implements #123739 so that we can do further experiments in nightly.

A little rewrite has been applied to for await lowering. It was previously unsafe { Pin::unchecked_new(into_async_iter(..)) }. Under the edition 2024 rule, however, into_async_iter gets dropped at the end of the unsafe block. This presumably the first Edition 2024 migration rule goes by hoisting into_async_iter(..) into match one level above, so it now looks like the following.

match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}

@rustbot
Copy link
Collaborator

rustbot commented May 19, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 19, 2024
@dingxiangfei2009
Copy link
Contributor Author

dingxiangfei2009 commented May 19, 2024

cc @traviscross for edition 2024 update

cc @eholk for context who has worked on async iterator

@dingxiangfei2009 dingxiangfei2009 changed the title Edition 2024: place tail expression behind terminating scope Place tail expression behind terminating scope May 19, 2024
@petrochenkov
Copy link
Contributor

r? compiler

@rustbot rustbot assigned davidtwco and unassigned petrochenkov May 22, 2024
@bors

This comment was marked as resolved.

@dingxiangfei2009 dingxiangfei2009 force-pushed the tail-expr-temp-lifetime branch from 21d1190 to 2f0ad0d Compare May 26, 2024 20:30
@dingxiangfei2009 dingxiangfei2009 force-pushed the tail-expr-temp-lifetime branch 4 times, most recently from 66c2762 to 5b86c0d Compare June 5, 2024 14:56
@traviscross
Copy link
Contributor

r? @estebank

@rustbot rustbot assigned estebank and unassigned davidtwco Jun 11, 2024
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'll let Esteban review it too

@estebank
Copy link
Contributor

@bors r=estebank,davidtwco

@bors
Copy link
Collaborator

bors commented Jun 13, 2024

📌 Commit 5b86c0d has been approved by estebank,davidtwco

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 Jun 13, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 14, 2024
…fetime, r=estebank,davidtwco

Place tail expression behind terminating scope

This PR implements rust-lang#123739 so that we can do further experiments in nightly.

A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following.
```rust
match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 14, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#125293 (Place tail expression behind terminating scope)
 - rust-lang#125722 (Indicate in `non_local_defs` lint that the macro needs to change)
 - rust-lang#126192 (Various Redox OS fixes and add i686 Redox OS target)
 - rust-lang#126285 (`UniqueRc`: support allocators and `T: ?Sized`.)
 - rust-lang#126352 (ci: Update centos:7 to use vault repos)
 - rust-lang#126399 (extend the check for LLVM build)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#126461 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 14, 2024
@dingxiangfei2009 dingxiangfei2009 force-pushed the tail-expr-temp-lifetime branch from 5b86c0d to 0f8c3f7 Compare June 17, 2024 20:14
@dingxiangfei2009
Copy link
Contributor Author

@matthiaskrgr would you mind giving it another shot? 🙏

@dingxiangfei2009
Copy link
Contributor Author

@bors try

@bors
Copy link
Collaborator

bors commented Jun 17, 2024

@dingxiangfei2009: 🔑 Insufficient privileges: not in try users

@bors

This comment was marked as resolved.

@ehuss
Copy link
Contributor

ehuss commented Jun 18, 2024

Tested locally and it seems to pass.

@bors r=estebank,davidtwco

@bors
Copy link
Collaborator

bors commented Jun 18, 2024

📌 Commit 0f8c3f7 has been approved by estebank,davidtwco

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 18, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jun 19, 2024
…fetime, r=estebank,davidtwco

Place tail expression behind terminating scope

This PR implements rust-lang#123739 so that we can do further experiments in nightly.

A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following.
```rust
match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}
```
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2024
Rollup of 10 pull requests

Successful merges:

 - rust-lang#124135 (delegation: Implement glob delegation)
 - rust-lang#125078 (fix: break inside async closure has incorrect span for enclosing closure)
 - rust-lang#125293 (Place tail expression behind terminating scope)
 - rust-lang#126422 (Suggest using a standalone doctest for non-local impl defs)
 - rust-lang#126493 (safe transmute: support non-ZST, variantful, uninhabited enums)
 - rust-lang#126504 (Sync fuchsia test runner with clang test runner)
 - rust-lang#126558 (hir_typeck: be more conservative in making "note caller chooses ty param" note)
 - rust-lang#126586 (Add `@badboy` and `@BlackHoleFox` as Mac Catalyst maintainers)
 - rust-lang#126615 (Add `rustc-ice*` to `.gitignore`)
 - rust-lang#126632 (Replace `move||` with `move ||`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8eb2e5f into rust-lang:master Jun 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2024
Rollup merge of rust-lang#125293 - dingxiangfei2009:tail-expr-temp-lifetime, r=estebank,davidtwco

Place tail expression behind terminating scope

This PR implements rust-lang#123739 so that we can do further experiments in nightly.

A little rewrite has been applied to `for await` lowering. It was previously `unsafe { Pin::unchecked_new(into_async_iter(..)) }`. Under the edition 2024 rule, however, `into_async_iter` gets dropped at the end of the `unsafe` block. This presumably the first Edition 2024 migration rule goes by hoisting `into_async_iter(..)` into `match` one level above, so it now looks like the following.
```rust
match into_async_iter($iter_expr) {
  ref mut iter => match unsafe { Pin::unchecked_new(iter) } {
    ...
  }
}
```
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.

10 participants