2024 No migration for tail expression temporary drop #132814
Open
Description
opened on Nov 9, 2024
I tried this code:
#![warn(rust_2024_compatibility)]
unsafe fn f() -> i32 {
1
}
fn check(_: &i32) {}
fn main() {
check(unsafe { &f() });
}
I expected to see this happen: Warning about the temporary being dropped too early. Or...I'm not fully understanding RFC 3606, and can't explain to myself why the temporary is not extended to the statement.
Instead, this happened: No warning, and this fails on 2024 with:
error[E0716]: temporary value dropped while borrowed
--> src/main.rs:11:21
|
11 | check(unsafe { &f() });
| ----- ^^-
| | | |
| | | temporary value is freed at the end of this statement
| | creates a temporary value which is freed while still in use
| borrow later used by call
|
= note: consider using a `let` binding to create a longer lived value
For more information about this error, try `rustc --explain E0716`.
Meta
rustc --version --verbose
:
rustc 1.84.0-nightly (b91a3a056 2024-11-07)
binary: rustc
commit-hash: b91a3a05609a46f73d23e0995ae7ebb4a4f429a5
commit-date: 2024-11-07
host: aarch64-apple-darwin
release: 1.84.0-nightly
LLVM version: 19.1.3
Activity