Skip to content

Unable to rename enums #3154

Open
Open
@guusw

Description

@guusw

I have an enum like this in C:

enum SHType : uint8_t {
  None,
  Any,
  Enum,
  Bool,
  ...
}

Turns into:

pub const SHType_None: SHType = 0;
pub const SHType_Any: SHType = 1;
pub const SHType_Enum: SHType = 2;
pub const SHType_Bool: SHType = 3;
...
pub type SHType = u8;

Which when used inside match blocks will generate:

warning: constant in pattern `SHType_Float3` should have an upper case name
   --> src\widgets\var_util.rs:194:9
    |
194 |         SHType_Float3 => {
    |         ^^^^^^^^^^^^^ help: convert the identifier to upper case: `SHTYPE_FLOAT3`

I have tried to use ParseCallbacks with enum_variant_name to rename the enum, but it only works on the variant part, not the type (turns into SHType_FLOAT3, instead of SHTYPE_FLOAT3)
I also tried to use item_name in addition which kind of works except it renames the actual type also to SHTYPE, which I want to keep regular, I just want to rename the constants. Anything I'm missing in bindgen that can do this or is it just something that is not possible yet?

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