Skip to content

Missing type layout information in nightly for stdlib generic types #21814

@mischnic

Description

@mischnic

rust-analyzer version: rust-analyzer version: 1.96.0-nightly (3102493c 2026-03-12) [/Users/niklas/.rustup/toolchains/nightly-2026-03-13-aarch64-apple-darwin/bin/rust-analyzer]

rustc version: nightly-2026-03-13

editor or extension: vscode with 0.3.2819

relevant settings:

[toolchain]
channel = "nightly-2026-03-13"
components = ["rustfmt", "clippy", "rust-analyzer"]
profile = "minimal"

repository link: https://github.com/mischnic/rust-analyzer-generic-size-nightly

code snippet to reproduce:

use std::num::NonZero;

pub struct Test<K, T = u8> {
    pub k: K,
    pub t: T,
}

// "needs Drop"
pub struct X {
    pub a: Vec<u32>,     // "needs Drop"
    pub b: NonZero<i32>, // "no Drop"
    pub c: u32,          // "size = 4, align = 0x4, no Drop"
    pub d: Test<i32>,    // "size = 8, align = 0x4, no Drop"
}

fn main() {
    // "size = 8, align = 0x4, no Drop"
    let _x = Test { k: 42, t: 255 };

    // "no Drop"
    let _y = std::num::NonZero::new(1i32).unwrap();
    println!("Hello, world!");
}

When using a recent nightly version, the hover menu doesn't compute the size/alignment/layout information for generic types from the standard library. Locally-declared generic types work fine though.

With channel = "1.94.0", all these types are correctly computed.
1.95.0-beta.3 is broken as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutMemory layout of typesC-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions