rust-lang / rust-lang/rust-analyzer

Semantic tokens: more granular custom modifiers for assignments

Open
#20,208 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

A very common existing use case is to set a distinct style for function.mutable and method.mutable to highlight sites where mutations can occur.

Image

This is very nice, but it does not cover the case of assignments. Mutation happened, but no distinct style was applied:

Image

It would be great if the place expression and the operator receive an additional .assigning or .mutating modifier, so that they can be specifically selected for highlighting.


Currently without this feature, the next best thing is to set a style for variable.mutable. This way the mutable variable is always highlighted:

Image

But this comes with the downside that the variable is highlighted everywhere even when it's used immutably. Personally I consider this a distraction.

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 semantic-token handling for assignments and inspect how existing function.mutable, method.mutable, and variable.mutable modifiers are produced. Confirm whether the place expression and operator can both receive an assigning or mutating modifier, then add coverage showing that assignment sites are highlighted without affecting immutable uses.

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.