Skip to content

Refactor does not create raw identifier when necessary #15091

Closed
@BenjaminBrienen

Description

@BenjaminBrienen

Summary

Suggestion for "wildcard match will also match any future added variants" will unescape raw identifiers.

Reproducer

I tried this code:

enum Foo {
    A,
    B,
    C,
}
match Foo::A {
    Foo::A => {},
    r#type => {},
}

I expected to see this happen:

enum Foo {
    A,
    B,
    C,
}
match Foo::A {
    Foo::A => {},
    r#type @ Foo::B | r#type @ Foo::C => {},
}

Instead, this happened:

enum Foo {
    A,
    B,
    C,
}
match Foo::A {
    Foo::A => {},
    type @ Foo::B | type @ Foo::C => {},
}

Version

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions