Skip to content

dbg! postfix snippet duplicates dereference #19758

@narpfel

Description

@narpfel

rust-analyzer version: rust-analyzer 1 (d8887c0758 2025-04-26)

rustc version:

$ rustc -vV
rustc 1.88.0-nightly (2e6882ac5 2025-05-05)
binary: rustc
commit-hash: 2e6882ac5be27a73293d6f7ae56397fdf32848de
commit-date: 2025-05-05
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4

editor or extension: neovim + nvim-lspconfig, also occurs on helix 25.01.1 with the default settings

relevant settings: default settings

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

code snippet to reproduce:

fn main() {
    let x = &42;
    let y = *x;
}

Place the cursor after *x, type .dbg and select the dbg! postfix snippet. This is the result:

fn main() {
    let x = &42;
    let y = *dbg!(*x);
}

Note that the reference is now dereferenced twice.

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