Open
Description
Code
#![warn(tail_expr_drop_order)]
async fn foo() -> bool {
false
}
pub async fn bar() {
while let true = foo().await {}
}
Current output
warning: relative drop order changing in Rust 2024
--> src/lib.rs:8:28
|
8 | while let true = foo().await {}
| ------^^^^^ - now the temporary value is dropped here, before the local variables in the block or statement
| | |
| | this value will be stored in a temporary; let us call it `#1`
| | up until Edition 2021 `#1` is dropped last but will be dropped earlier in Edition 2024
| `__awaitee` calls a custom destructor
| `__awaitee` will be dropped later as of Edition 2024
|
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
Desired output
Something else instead of “__awaitee
”.
Rationale and extra context
Note that arguably the lint shouldn’t be firing at all because there are no other local variables, but that is just because the example is minimal; in the real cases, there were other local variables with significant Drop
s.
Rust Version
rustc 1.86.0-nightly (2f348cb7c 2025-01-27)
binary: rustc
commit-hash: 2f348cb7ce4063fa4eb40038e6ada3c5214717bd
commit-date: 2025-01-27
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.7
Anything else?
@rustbot label A-edition-2024
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The 2024 editionArea: Lints (warnings about flaws in source code) such as unused_mut.Issue: This issue has been reviewed and triaged by the Edition team.Lint: tail_expr_drop_orderRelevant to the compiler team, which will review and decide on the PR/issue.