rust-lang / rust-lang/rust-analyzer
Feature request: split trait
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Let’s say I have a trait such as
trait T {
pub fn foo(&self, a: i32) -> bool;
pub fn bar<A>(&self, a: A, b: A) -> A;
pub fn baz(&self) -> &'static str;
}
I want to split T into two traits: T1 (containing foo and bar) and T2 (containing baz). My suggested action would do the following:
- Prompt for which items to assign to
T1and which to assign toT2 - Create these traits
- Optionally retain
Tas a subtrait ofT1 + T2with a blanket implementation - Refine trait bounds of the type
A: TtoA: T1orA: T2if they use items from only one of them - Split all implementations of
Tas well
The opposite action (merging two traits) could be added as well, although I don’t know how useful it would be in practice.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files, tests, or entry points are named in the issue. Begin by locating the trait-related refactoring entry point and its tests, then verify the requested trait creation, optional subtrait retention, bound refinement, and implementation splitting against the examples described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100