You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) } {
...
}
}
```
LL | if let Ok(mut byte) = cell.try_borrow_mut() {
8
+
| ^^^^-----------------
9
+
| |
10
+
| borrowed value does not live long enough
11
+
| a temporary with access to the borrow is created here ...
12
+
...
13
+
LL | }
14
+
| -
15
+
| |
16
+
| `cell` dropped here while still borrowed
17
+
| ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Result<RefMut<'_, u8>, BorrowMutError>`
18
+
|
19
+
help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
20
+
|
21
+
LL | };
22
+
| +
23
+
24
+
error: aborting due to 1 previous error
25
+
26
+
For more information about this error, try `rustc --explain E0597`.
0 commit comments