rust-lang / rust-lang/rust-analyzer
Tooltip info should evaluate and display constant expressions of types
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Given the following:
pub type Tile4 = [u32; (4 * 8 * 8) / 32];
pub type Charblock4 = [Tile4; 512];
- If one hovers the mouse over
Charblock4you will seepub type Charblock8 = [Tile8; 256], the full type. - If one hovers the mouse over
pub type Tile4 = [u32; _], which is missing the number of elements.
It would be greatly improved if the display could evaluate the expression and show that.
I completely understand if a full const evaluation engine can't be rigged into RA, but at least some const expressions (such as integer literal math) should be possible.
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
Reproduce the hover behavior using the Tile4 and Charblock4 examples in the issue, then trace the rust-analyzer type tooltip rendering and constant-expression handling. Done means the hover for Tile4 displays the evaluated array length for supported expressions, with coverage for the shown integer literal arithmetic.
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