rust-lang / rust-lang/rust-analyzer

Allow us to put fields before trait methods in autocompletion

Open
#17,847 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-completion C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I'm using rust-analyzer in a bevy game project.
Most of my structs derive from Reflect, which adds a lot of trait-methods that spam the autocompletion for me, and hide the actually relevant fields:
image
image

I never use the Reflect methods in my own code, I only derive from it so that Bevy (and other core packages) can benefit from it.

IDK how common it for general rust projects to encounter this issue, but from what I've seen it will always happen when working with bevy.

I see 2 solutions for this:

  • Make fields appear at the start of the list, alongside methods defined on the object itself, instead of alongside trait methods.
  • Allow us to hide methods of a specific trait from the list, or move them to the end.
    I could see a world in which some first-class methods are defined in a trait, and you would also not want these methods to get hidden behind all of the unimportant Reflect methods.

(keywords: order)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing rust-analyzer's completion ordering for struct fields and trait methods, using the reported Bevy and Reflect scenario as the reproduction case. Clarify with maintainers whether fields should be ranked first or whether trait methods should be hideable or movable, then add coverage showing the agreed ordering or filtering behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.