- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Place tail expression behind terminating scope #125293
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
Place tail expression behind terminating scope #125293
Conversation
| 
          
 rustbot has assigned @petrochenkov. Use   | 
    
| 
           cc @traviscross for edition 2024 update cc @eholk for context who has worked on async iterator  | 
    
| 
           r? compiler  | 
    
      
        
              This comment was marked as resolved.
        
        
      
    
  This comment was marked as resolved.
21d1190    to
    2f0ad0d      
    Compare
  
    66c2762    to
    5b86c0d      
    Compare
  
    | 
           r? @estebank  | 
    
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.
LGTM, but I'll let Esteban review it too
| 
           @bors r=estebank,davidtwco  | 
    
…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) } { ... } } ```
…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
5b86c0d    to
    0f8c3f7      
    Compare
  
    | 
           @matthiaskrgr would you mind giving it another shot? 🙏  | 
    
| 
           @bors try  | 
    
| 
           @dingxiangfei2009: 🔑 Insufficient privileges: not in try users  | 
    
      
        
              This comment was marked as resolved.
        
        
      
    
  This comment was marked as resolved.
| 
           Tested locally and it seems to pass. @bors r=estebank,davidtwco  | 
    
…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) } { ... } } ```
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
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) } { ... } } ```
This PR implements #123739 so that we can do further experiments in nightly.
A little rewrite has been applied to
for awaitlowering. It was previouslyunsafe { Pin::unchecked_new(into_async_iter(..)) }. Under the edition 2024 rule, however,into_async_itergets dropped at the end of theunsafeblock. This presumably the first Edition 2024 migration rule goes by hoistinginto_async_iter(..)intomatchone level above, so it now looks like the following.