Skip to content

Nightly regression in writeln! lifetime extension #146701

@DaniPopes

Description

@DaniPopes

Code

I tried this code:

fn main() {
    let x = 0usize;

    let _ = format!("{}{x}", if x == 0 { "-" } else { &x.to_string() }); // stable: OK, nightly: ERROR!
    let _ = format!("{x}{}", if x == 0 { "-" } else { &x.to_string() }); // stable: OK, nightly: ERROR!
    let _ = format!("{}", if x == 0 { "-" } else { &x.to_string() }); // stable, nightly: ERROR
}

I expected to see this happen: format_args!/format! etc. equivalent to writeln!

Instead, this happened: writeln! on nightly regressed in extending lifetime when called with 2 or more arguments

Reduced from here https://github.com/foundry-rs/foundry/actions/runs/17817373054/job/50653220499?pr=11697#step:5:738

Version it worked on

It most recently worked on: stable, yesterday's nightly

Version with regression

rustc --version --verbose:

rustc 1.92.0-nightly (4645a7988 2025-09-17)
binary: rustc
commit-hash: 4645a7988177c286f61609cc667ecae4c571a2e8
commit-date: 2025-09-17
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions