Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<layout-error> on u32 bitflags struct #19231

Open
edwloef opened this issue Feb 26, 2025 · 1 comment · May be fixed by #19234
Open

<layout-error> on u32 bitflags struct #19231

edwloef opened this issue Feb 26, 2025 · 1 comment · May be fixed by #19234
Labels
A-layout Memory layout of types A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@edwloef
Copy link

edwloef commented Feb 26, 2025

Image

rust-analyzer version:
rust-analyzer 1.85.0 (4d91de4 2025-02-17)

rustc version:
rustc 1.85.0 (4d91de4e4 2025-02-17)

editor or extension:
occurs in both Zed and Flow Control

relevant settings:
none

repository link (if public, optional):
https://github.com/prokopyl/clack

code snippet to reproduce:
https://github.com/prokopyl/clack/blob/5deaa1be9b5af7078d75cbe54abefee12ed40f63/extensions/src/note_ports.rs#L24-L33

bitflags! {
    #[repr(C)]
    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct NoteDialects: u32 {
        const CLAP = CLAP_NOTE_DIALECT_CLAP;
        const MIDI = CLAP_NOTE_DIALECT_MIDI;
        const MIDI_MPE = CLAP_NOTE_DIALECT_MIDI_MPE;
        const MIDI2 = CLAP_NOTE_DIALECT_MIDI2;
    }
}
@edwloef edwloef added the C-bug Category: bug label Feb 26, 2025
@lnicola
Copy link
Member

lnicola commented Feb 26, 2025

Minimized:

pub trait PublicFlags {
    type Internal;
}

pub struct NoteDialects(<NoteDialects as PublicFlags>::Internal);

impl NoteDialects {
    pub const CLAP: Self = Self(InternalBitFlags);
}

pub struct InternalBitFlags;

impl PublicFlags for NoteDialects {
    type Internal = InternalBitFlags;
}

@lnicola lnicola added the A-ty type system / type inference / traits / method resolution label Feb 26, 2025
@ShoyuVanilla ShoyuVanilla added the A-layout Memory layout of types label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Memory layout of types A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
3 participants