rust-lang / rust-lang/rust-analyzer

Delegate method assist on enums

Open
#15,953 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 13h
Merged PRs (30d)
69

Description

Imo, the assist should work on enum variant fields, if all variants have the same named field or a field at the same index if they are tuple variants and all of the fields share a method. Having wrapper enums that "unify" two distinct types that serve similar purposes does happen at times.

enum Enum {
    V1(Type$0),
    V2(Type2),
}

here we should offer the assist to delegate any methods shared by Type and Type2 and then generate a method that matches on the variants and delegates appropriately.

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 locating the delegate-method assist entry point and any tests covering enum or variant-field delegation. Compare the requested behavior for named and tuple fields, then consider the work complete when shared methods are offered and generated delegation matches each enum variant.

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.