rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.31k stars 1.62k forks source link

Struct fields and function arguments not expanded on completion #18544

Open dmitrii-ubskii opened 1 day ago

dmitrii-ubskii commented 1 day ago

rust-analyzer version: rust-analyzer 0.0.0 (ba56d9b9b 2024-11-17) installed via Homebrew

rustc version: rustc 1.82.0 (f6e511eec 2024-10-15) installed via rustup

editor or extension: NeoVim using neovim/nvim-lspconfig and hrsh7th/nvim-cmp with hrsh7th/cmp-nvim-lsp

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

['rust-analyzer'] = {
    check = { command = "clippy" },
    completion = { privateEditable = { enable = true } },
    rustfmt = { extraArgs = { "+nightly" } },
    numThreads = 8,
}

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

code snippet to reproduce: (| represents cursor position)

struct Type1 { field: u8 }
struct Type2 { field: u8 }
fn main() {
    let T|
}

When calling completion and selecting e.g. the item Type1 {…}, rust-analyzer inserts literal Type1 {…} where it previously would have correctly inserted Type1 { field }. Rust-analyzer 1.82.0 installed via rustup does not exhibit this behaviour, it expands correctly.

Note: I believe this was more easily reproducible on the 2024-11-04 version of RA, but I had updated in hope this had been fixed, and now I also get random symbols like panic! completed instead of the one I've selected (I'm guessing that's related to #18536).