Skip to content

No default in Shape struct when using top level #[facet(default)] on enum #2113

@wiiznokes

Description

@wiiznokes
#[derive(Facet, Debug, Default)]
#[facet(default)]
#[repr(u8)]
pub enum DefaultTraitEnum {
    #[default]
    A,
    B,
}
Shape {
    id: TypeId(0xfc49579bcb5f58db9b85439232af2ad9),
    layout: Sized(Layout { size: 1, align: 1 (1 << 0) }),
    vtable: VTable { .. },
    marker_traits: (empty),
    ty: User(
        Enum(
            EnumType {
                repr: Repr {
                    base: Rust,
                    packed: false,
                },
                enum_repr: U8,
                variants: [
                    Variant {
                        name: "A",
                        rename: None,
                        discriminant: Some(
                            0,
                        ),
                        attributes: [],
                        data: StructType {
                            repr: Repr {
                                base: C,
                                packed: false,
                            },
                            kind: Unit,
                            fields: [],
                        },
                        doc: [],
                    },
                    Variant {
                        name: "B",
                        rename: None,
                        discriminant: Some(
                            1,
                        ),
                        attributes: [],
                        data: StructType {
                            repr: Repr {
                                base: C,
                                packed: false,
                            },
                            kind: Unit,
                            fields: [],
                        },
                        doc: [],
                    },
                ],
                is_cow: false,
            },
        ),
    ),
    def: Undefined,
    type_identifier: "DefaultTraitEnum",
    type_params: [],
    const_params: [],
    doc: [],
    attributes: [
        default(()),
    ],
    type_tag: None,
    inner: None,
}

Also, maybe the default field should not be in the variants field, so we don't have to iterate all variant to know witch one it the default ?

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