rust-lang / reference

The Rust Reference
https://doc.rust-lang.org/nightly/reference/
Apache License 2.0
1.25k stars 493 forks source link

Propagate temporary lifetime extension into if and match expressions #1548

Open xmh0511 opened 4 months ago

xmh0511 commented 4 months ago

Since 1.79, the temporaries are extended in the following example:

let a = if true {
    ..;
    &temp() // used to error, but now gets lifetime extended
} else {
    ..;
    &temp() // used to error, but now gets lifetime extended
};

The list in extending-based-on-expressions seems to be out-of-date.

ehuss commented 4 months ago

cc https://github.com/rust-lang/rust/pull/121346/. @m-ou-se would you be able to help with that?