rust-lang / rust-lang/rust-analyzer

Tooltip info should evaluate and display constant expressions of types

Open
#10,825 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-hover A-ide A-ty C-feature E-unknown S-actionable
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 Charblock4 you will see pub 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.