Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request hover support for constants defined with const fn #18685

Open
xpe opened this issue Dec 13, 2024 · 1 comment
Open

Request hover support for constants defined with const fn #18685

xpe opened this issue Dec 13, 2024 · 1 comment
Labels
A-mir C-feature Category: feature request

Comments

@xpe
Copy link

xpe commented Dec 13, 2024

I would like to ask for textDocument/hover support for constants defined with const fn. In my example below, you can see that an add function works, but not usize.ilog2().

Works as expected

pub const fn add(a: u32, b: u32) -> u32 { a + b }
pub const ADD_EXAMPLE: u32 = add(2, 3);

Hovering over ADD_EXAMPLE shows 5 as expected...

Image

Feature request

pub const fn ilog2(n: u32) -> u32 { n.ilog2() }
pub const ILOG2_EXAMPLE: u32 = ilog2(16);

But hovering over ILOG2_EXAMPLE currently shows: ilog2(16) instead of 4...

Image

Background

I have an application where I define constants based on usize.ilog2() and I like to sanity check the results in my editor.

@xpe xpe added the C-feature Category: feature request label Dec 13, 2024
@ChayimFriedman2
Copy link
Contributor

We have a custom MIR lowering and evaluation. We show the value if we can evaluate the constant. I haven't looked where exactly we fail for ilog2(), but we just need to extend our supported set of operations for that. So this isn't really a feature request, more like an in-progress feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

2 participants