Skip to content

Lifetime-extended variable incorrectly reported as 'static #20510

@DaniPopes

Description

@DaniPopes

rust-analyzer version: 0.3.2577-standalone

rustc version: rustc 1.91.0-nightly (05f5a58 2025-08-19)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

relevant settings: N/A

repository link (if public, optional): N/A

code snippet to reproduce:

fn main() {
    let x = 0usize;
    let _s = match Some(()) {
        Some(()) => &format!("{x}"),
        None => "",
    };
}

_s' type hint is &'static str

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesA-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions