Skip to content

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

@antonilol

Description

@antonilol

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions