rust-lang / rust-lang/rust-analyzer

hovering over constant containing function pointers shows internal constants

Open
#17,200 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: rust-analyzer version: 0.4.1943-standalone

rustc version: rustc 1.77.0 (aedd173a2 2024-03-17)

editor or extension: code oss, arch linux

relevant settings: None

code snippet to reproduce:

pub const FN: &[fn(usize, usize) -> usize] = &[or, xor];

pub fn or(a: usize, b: usize) -> usize {
    a | b
}

pub fn xor(a: usize, b: usize) -> usize {
    a ^ b
}

hovering over the FN constant shows

pub const FN: &[fn(usize, usize) -> usize] = &[0x3E8 as fn(usize, usize) -> usize, 0x3E9 as fn(usize, usize) -> usize]

which is not very useful (the internal constants and repeating the type)

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 with the minimal Rust snippet in the issue and inspect rust-analyzer's hover output for the FN constant. Trace the hover rendering and type/value display until you find why function pointers become internal numeric constants; done means the hover is useful and no longer repeats the type unnecessarily.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.