Skip to content

Array value constants with tuple elements fail MIR import #382

Closed

Description

@niklebedenko

Bug

Bare array constants support primitive elements and nested arrays, but an array whose element is a tuple is rejected during MIR import.

const TABLE: [(u8, u32); 2] = [(1, 0x1122_3344), (2, 0x5566_7788)];

#[inline(never)]
fn lookup(i: usize) -> u32 {
    let (tag, value) = TABLE[i & 1];
    value + tag as u32
}
Actual:   byte lowering rejects the tuple element type
Expected: tuple elements are decoded using rustc's array stride and field offsets

The example intentionally places padding between u8 and u32. Treating tuple fields as tightly packed reads the second field from padding even if tuple construction itself succeeds.

Correctness boundary

Tuple decoding must use rustc layout. Constants containing pointer provenance must not reinterpret relocation placeholder bytes as exposed-provenance pointers; they should fail clearly until relocation-aware aggregate materialization exists.

Acceptance criteria

  • Arrays of tuples with supported scalar, enum, nested-tuple, and ZST fields lower correctly.
  • Internal field padding and trailing element-stride padding are preserved.
  • Direct padded tuple constants use the same layout-aware decoder.
  • Pointer-bearing tuple arrays fail with a stable, actionable diagnostic.
  • Existing primitive, nested-array, and pointer-to-array constant behavior remains unchanged.
  • Supported-feature documentation records the new support and its limitations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions