rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.69k stars 1.5k forks source link

hovering over constant containing function pointers shows internal constants #17200

Open antonilol opened 3 weeks ago

antonilol commented 3 weeks ago

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)

roife commented 3 weeks ago

Might be related to https://github.com/rust-lang/rust-analyzer/blob/9ec04ed43de2476fc40408021d3a2ece5773e31a/crates/hir-ty/src/display.rs#L670-L674

It seems like an address or something else.