Skip to content

Internal Compiler Error deriving Debug on packed zero_copy structs #4072

@Lbqds

Description

@Lbqds

Description

When using declare_program! to generate a program that includes #[zero_copy(unsafe)] structs, Anchor automatically derives Debug and marks these structs with #[repr(Rust, packed)].

This triggers a Rust Internal Compiler Error because the derived Debug implementation creates references to fields in a packed struct:

error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:17: builtin derive created an unaligned reference

Reproduction

You can run cargo build in the demo repository to reproduce this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions