Skip to content

repr(transparent) newtypes do not preserved preferred alignment #109560

Open
@RalfJung

Description

@RalfJung

This type

#[repr(transparent)]
struct S(u8);

has a "preferred" alignment of 8, but u8's "preferred" alignment is 1. I would expect such a transparent newtype to preserve "preferred" alignment.

Preferred alignment is not directly visible to Rust programs, it's an internal thing inside the compiler, so this is not a big deal -- but it is still surprising.
Cc @oli-obk @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeT-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