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

Type size not displayed when using expressions instead of literal numbers #14784

Closed
antonilol opened this issue May 11, 2023 · 1 comment
Closed
Labels
C-bug Category: bug

Comments

@antonilol
Copy link

when hovering on a type rust analyzer displays the size

working examples:

struct Example1(u32);

struct Example2([u16; 3]);

type Example3 = Option<Example2>;

const SIZE_4: usize = 4;
struct Example4 {
    a: [u8; SIZE_4],
    b: Example3,
}

const SIZE_5: usize = {
    let mut s = 5;
    while s < 18 {
        s += 4;
    }
    s
};
struct Example5([(Example1, Example2); SIZE_5]);

when using expressions like a function or even { 1 } the size (and align) is no longer displayed

struct Example6([u64; { 1 }]);

struct Example7([i16; (1)]);

struct Example8([u8; 8 / 2]);

const fn one() -> usize {
    1
}
struct Example9([Example1; one()]);

rust-analyzer version: 0.4.1509-standalone

rustc version: rustc 1.69.0 (84c898d65 2023-04-16)

relevant settings: None

related: #4091

@antonilol antonilol added the C-bug Category: bug label May 11, 2023
@HKalbasi
Copy link
Member

Const generic support is a work in progress. We currently don't lower anything more complex that a scalar (like 2) and a simple name (like N). The above examples also didn't work until very recently, but now that they work, you can name your constants as a workaround.

Closing in favor of #7434

@HKalbasi HKalbasi closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants