Skip to content

Bogus snippet completions suggested #19906

Closed
@WhyNotHugo

Description

@WhyNotHugo
> rust-analyzer --version
rust-analyzer 2025.05.19
> rustc -V
rustc 1.87.0 (17067e9ac 2025-05-09) (Alpine Linux 1.87.0-r0)
> nvim --version
NVIM v0.11.1
Build type: MinSizeRel
LuaJIT 2.1.1723681758

code snippet to reproduce:

fn main() {
    let s = String::new();
    s.
}

Please the cursor at the end of line s. and trigger auto-completion. rust-analyzer suggests a bunch of snippets: let~ letm, ref~, box~, etc…

All of these are completely bogus in this context. For example, box~ expands to Box::new. The result of applying it is:

fn main() {
    let s = String::new();
    s.Box::new
}

This isn't even valid syntax. These snippets suggestions are completely ignoring context (are they a new feature? I've never seen them before), and add a lot of noise. In most situations, actually valid suggestions are buried behind a bunch of suggestions that don't make sense.

In these situations, snippets should not be suggested; contextual suggestions (like methods on the String type) should be the only suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: support questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions