Skip to content

raw mut/raw const expands to the wrong kind of reference when used in custom snippet #21035

@Paladynee

Description

@Paladynee

this problem arised from the solution to the issue #20999, where i requested snippets for &raw const and &raw mut and got told to use custom snippets, which expanded to missing code when i tried to expand them.

rust-analyzer version: rust-analyzer version: 1.93.0-nightly (25d319a 2025-11-11)

rustc version:

rustc 1.93.0-nightly (25d319a0f 2025-11-11)
binary: rustc
commit-hash: 25d319a0f656ee8faa7a534da299e76e96068a40
commit-date: 2025-11-11
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

editor or extension: VSCode extension v0.3.2675 with nightly server

relevant settings: custom snippets VScode:

"rust-analyzer.completion.snippets.custom": {
    "Grouping": {
        "postfix": "group",
        "body": "(${receiver})",
        "description": "Wrap the expression in parens `(expr)`",
        "scope": "expr",
    }
}

code snippet to reproduce:

&raw mut (a).b
// apply Grouping snippet
&raw mut (a.)b.group<TAB>
// observed
(&mut (a).b)
// expected
(&raw mut (a).b)

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