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

Use common type alias for anonymous enums in consts mode #2191

Merged
merged 1 commit into from Apr 19, 2022

Commits on Apr 19, 2022

  1. Use common type alias for anonymous enums in consts mode

    Previously, anonymous enums generated a type alias but did not use it.
    For example the following:
    
    ```C
    enum {
        ZERO,
        ONE = 4999,
    };
    ```
    
    Generated this:
    
    ```Rust
    /* automatically generated by rust-bindgen 0.59.2 */
    
    pub const ZERO: ::std::os::raw::c_uint = 0;
    pub const ONE: ::std::os::raw::c_uint = 4999;
    pub type _bindgen_ty_1 = ::std::os::raw::c_uint;
    ```
    
    For use cases where humans look at bindgen's Rust output this was a little
    strange since it's a deviation from how the Rust output for named enums
    is organized, where all constants share the same type using the type
    alias. The unused type alias also triggered the dead_code lint.
    
    Change to use the generated type alias.
    XrXr committed Apr 19, 2022
    Configuration menu
    Copy the full SHA
    c4f4fc9 View commit details
    Browse the repository at this point in the history