Skip to content

transmutability: high memory unsage for types containing references #140610

Open
@tmiasko

Description

@tmiasko

I am running out of memory when trying to compile the following code:

#![feature(transmutability)]
use std::mem::{Assume, TransmuteFrom};
pub fn is_maybe_transmutable<Src, Dst>()
where
    Dst: TransmuteFrom<Src, { Assume::SAFETY }>
{}

pub union U {
    pub a: &'static u8,
    pub b: &'static u16,
    pub c: &'static u32,
    pub d: &'static u64,
}

fn main() {
    is_maybe_transmutable::<[U; 10], [U; 10]>();
}

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (4824c2bb7 2025-05-02)
binary: rustc
commit-hash: 4824c2bb7445cb2478aab0190c268c939d77a0f6
commit-date: 2025-05-02
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-transmutability`#![feature(transmutability)]`I-compilememIssue: Problems and improvements with respect to memory usage during compilation.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions