Skip to content

"#[derive] can't be used on a non-Copy #[repr(packed)] struct" but struct is Copy #50826

Open
@RalfJung

Description

@RalfJung

Reported by @retep998 at #46043 (comment), here's a minimal example:

#[repr(packed)]
#[derive(Debug)]
struct Foo {
    x: usize,
}

impl Clone for Foo {
    fn clone(&self) -> Self {
        Foo { x: self.x }
    }
}
impl Copy for Foo {}

play

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-repr-packedArea: the naughtiest reprC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions