Skip to content

Bug: debug pretty-printing unknown flags display 0x0x #267

@budde25

Description

@budde25

main.rs

use bitflags::bitflags;

bitflags! {
    struct Flags: u8 {
        const TWO = 0x2;
    }
}

fn main() {
    let value = 0b11;
    let flags = unsafe { Flags::from_bits_unchecked(value) };
    println!("{:?}", flags);
    println!("-----------");
    println!("{:#?}", flags);
}

will print the following:

TWO | 0x1
-----------
TWO | 0x0x1

the expected output would either be 0x1 for both, or 1, and 0x1 respectively

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