Skip to content

Extract function panic #20965

@A4-Tacks

Description

@A4-Tacks

rust-analyzer version: rust-analyzer 0.4.2659-standalone

rustc version: rustc 1.91.0-nightly (040a98a 2025-08-20)

editor or extension: coc-rust-analyzer Vim9.1

code snippet to reproduce:

#[derive(Debug)]
struct Foo(&'static str);

impl Foo {
    fn text(&self) -> &str { self.0 }
}
fn main() {
    let s = Foo("");
    $0let m = format!("{s:?}{}", if s.text().ends_with("x") { "a" } else { "b" });$0
    let _ = format!("{s:?}{m}");
}

Select line let m use 'Extract into function', panic

@rustbot label +A-assists

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions