-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed as not planned
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`A-temporary-lifetime-extensionArea: temporary lifetime extensionArea: temporary lifetime extensionC-bugCategory: This is a bug.Category: This is a bug.F-super_letit's super, let's go!it's super, let's go!I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
I tried this code:
writeln!(
cfg.process.stdout().lock(),
"{} ({})",
toolchain.name(),
match source {
ActiveSource::Default => &"default" as &dyn fmt::Display,
_ => &source.to_reason(),
}
)?;This compiles on stable (1.91). However, current nightly fails:
error[E0716]: temporary value dropped while borrowed
--> src/cli/rustup_mode.rs:1225:31
|
1223 | / match source {
1224 | | ActiveSource::Default => &"default" as &dyn fmt::Display,
1225 | | _ => &source.to_reason(),
| | ^^^^^^^^^^^^^^^^^-
| | | |
| | | temporary value is freed at the end of this statement
| | creates a temporary value which is freed while still in use
1226 | | }
| |_____________________- borrow later used here
|
= note: consider using a `let` binding to create a longer lived valueI tried to make a minimal reproduction but this playground fails on stable, too.
Meta
nightly:
rustc 1.93.0-nightly (b15a874aa 2025-11-02)
binary: rustc
commit-hash: b15a874aafe7eab9ea3ac2c1d59c7b03e1425027
commit-date: 2025-11-02
host: aarch64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3
rustc --version --verbose:
rustc 1.91.0 (f8297e351 2025-10-28)
binary: rustc
commit-hash: f8297e351a40c1439a467bbbb6879088047f50b3
commit-date: 2025-10-28
host: aarch64-apple-darwin
release: 1.91.0
LLVM version: 21.1.2
Metadata
Metadata
Assignees
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`A-temporary-lifetime-extensionArea: temporary lifetime extensionArea: temporary lifetime extensionC-bugCategory: This is a bug.Category: This is a bug.F-super_letit's super, let's go!it's super, let's go!I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team