Skip to content

debug assertion: Post-projection layout should be non-Ref, but it's... #149191

@saethlin

Description

@saethlin
#![feature(custom_mir, core_intrinsics)]

use std::intrinsics::mir::*;

#[custom_mir(dialect = "runtime", phase = "initial")]
fn main() {
    mir!{
        let _49: (Adt24,);
        let _63: *const Adt24;
        {
            (*_63) = _49.0;
            Return()
        }
    }
}

enum Adt24 {
    Variant1 {
        fld0: f64,
    },
    Variant2 {
        fld0: u64,
    },
}

Will hit a debug assertion:

thread 'rustc' (3695161) panicked at /home/ben/rust/compiler/rustc_codegen_ssa/src/mir/analyze.rs:159:13:
Post-projection (_1.0: Adt24) layout should be non-Ref, but it's TyAndLayout { ty: Adt24, layout: Layout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Int(I64, false), valid_range: 0..=1 }), uninhabited: false, variants: Multiple { tag: Initialized { value: Int(I64, false), valid_range: 0..=1 }, tag_encoding: Direct, tag_field: 0, variants: [Layout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [Size(8 bytes)], memory_index: [0] }, largest_niche: None, uninhabited: false, variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 1530056383329300088 }, Layout { size: Size(16 bytes), align: AbiAlign { abi: Align(8 bytes) }, backend_repr: Memory { sized: true }, fields: Arbitrary { offsets: [Size(8 bytes)], memory_index: [0] }, largest_niche: None, uninhabited: false, variants: Single { index: 1 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 1530056379034332792 }] }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes), randomization_seed: 4590169132808031073 } }

#144347 added the assertion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationA-rustlantisA miscompilation found by RustlantisC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.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