rust-lang / rust-lang/rust-analyzer
Function request: adding Size Bound by default to generic virtual text
Open
Nobody has claimed this yet.
A-hover
A-ide
C-feature
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Function request: adding Size Bound by default to generic virtual text
Why are we doing this?
In Rust we specified that the Size Trait bound constraint is implemented for all generic T's, so we should also display it on our own virtual text type prompt instead of popping a T and jumping the Size Trait.
Suppose we have the following generic signature:
impl<T> SomethingOrNothing<T> {}
At this stage
when the mouse moves over the generics, it looks like this:
| T |
|---|
| Go to Size |
I would like to be able to add a trait bound of T: SIze to the virtual text, as shown below:
| T: Size |
|---|
| Go to Size |
Similarly, when we hold down Ctrl to move to generic T, it looks like this:
| T |
|---|
| Go to Size |
| T |
After the change, as shown below:
| T: Size |
|---|
| Go to Size |
| T: Size |
More examples
impl<T: Clone> SomethingOrNothing<T> {}
Display of virtual text
| T: Clone |
|---|
| Go to Clone | Size |
After the change ===>
| T: Clone + Size |
|---|
| Go to Clone | Size |
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
Locate the implementation that renders generic parameters and trait bounds in rust-analyzer's virtual text, then inspect how hover and Ctrl-navigation displays are assembled. Reproduce the examples from the issue and verify that implicit T: Sized appears alongside explicit bounds without changing the navigation targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100