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
Fix name collision between C enum and typedef #2326
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☔ The latest upstream changes (presumably f160d11) made this pull request unmergeable. Please resolve the merge conflicts. |
error[E0428]: the name `Enum` is defined multiple times --> bindgen-tests/tests/expectations/tests/enum-typedef.rs:10:1 | 9 | pub type Enum = ::std::os::raw::c_uint; | --------------------------------------- previous definition of the type `Enum` here 10 | pub type Enum = i16; | ^^^^^^^^^^^^^^^^^^^^ `Enum` redefined here | = note: `Enum` must be defined only once in the type namespace of this module error[E0428]: the name `TypedefFirst` is defined multiple times --> bindgen-tests/tests/expectations/tests/enum-typedef.rs:13:1 | 11 | pub type TypedefFirst = i16; | ---------------------------- previous definition of the type `TypedefFirst` here 12 | pub const TypedefFirst_Variant2: TypedefFirst = 0; 13 | pub type TypedefFirst = ::std::os::raw::c_uint; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `TypedefFirst` redefined here | = note: `TypedefFirst` must be defined only once in the type namespace of this module
|
pvdrz
approved these changes
Nov 28, 2022
facebook-github-bot
pushed a commit
to facebookexperimental/rust-shed
that referenced
this pull request
Mar 22, 2023
Summary: Both waiting-in PRs have been merged and released: - rust-lang/rust-bindgen#2319 - rust-lang/rust-bindgen#2326 Adding `artifact = "bin"` removes the need for the `lib.rs` patch: - fbsource/bindgen@3579276 Reviewed By: jsgf Differential Revision: D44301594 fbshipit-source-id: d5ac1b54b099655e8e87974e42439bcd32aa5aed
facebook-github-bot
pushed a commit
to facebook/fb303
that referenced
this pull request
Mar 22, 2023
Summary: Both waiting-in PRs have been merged and released: - rust-lang/rust-bindgen#2319 - rust-lang/rust-bindgen#2326 Adding `artifact = "bin"` removes the need for the `lib.rs` patch: - fbsource/bindgen@3579276 Reviewed By: jsgf Differential Revision: D44301594 fbshipit-source-id: d5ac1b54b099655e8e87974e42439bcd32aa5aed
facebook-github-bot
pushed a commit
to facebook/sapling
that referenced
this pull request
Mar 22, 2023
Summary: Both waiting-in PRs have been merged and released: - rust-lang/rust-bindgen#2319 - rust-lang/rust-bindgen#2326 Adding `artifact = "bin"` removes the need for the `lib.rs` patch: - fbsource/bindgen@3579276 Reviewed By: jsgf Differential Revision: D44301594 fbshipit-source-id: d5ac1b54b099655e8e87974e42439bcd32aa5aed
LoganBarnett
pushed a commit
to LoganBarnett/rust-bindgen
that referenced
this pull request
Dec 2, 2023
Fixes rust-lang#2008. Example: ```c enum Enum { Variant }; typedef int16_t Enum; ``` This is valid and idiomatic C (though not valid C++). `cbindgen` uses this idiom as the default C translation of Rust enums, the equivalent of what would be `enum Enum : int16_t { Variant };` in C++. `bindgen header.h` before: ```rust pub const Enum_Variant: Enum = 0; pub type Enum = ::std::os::raw::c_uint; pub type Enum = i16; ``` ```console error[E0428]: the name `Enum` is defined multiple times --> generated.rs:3:1 | 2 | pub type Enum = ::std::os::raw::c_uint; | --------------------------------------- previous definition of the type `Enum` here 3 | pub type Enum = i16; | ^^^^^^^^^^^^^^^^^^^^ `Enum` redefined here | = note: `Enum` must be defined only once in the type namespace of this module ``` After: ```rust pub const Enum_Variant: Enum = 0; pub type Enum = i16; ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2008.
Example:
This is valid and idiomatic C (though not valid C++).
cbindgen
uses this idiom as the default C translation of Rust enums, the equivalent of what would beenum Enum : int16_t { Variant };
in C++.bindgen header.h
before:After: