Skip to content

Commit c950a83

Browse files
authored
Merge branch 'main' into patch-1
2 parents be05b8e + 9d5991b commit c950a83

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
- Add a complex macro fallback API (#2779).
208208
- Add option to use DST structs for flexible arrays (--flexarray-dst, #2772).
209209
- Add option to dynamically load variables (#2812).
210+
- Add option in CLI to use rustified non-exhaustive enums (--rustified-non-exhaustive-enum, #2847).
210211
## Changed
211212
- Remove which and lazy-static dependencies (#2809, #2817).
212213
- Generate compile-time layout tests (#2787).

bindgen-cli/options.rs

+8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ struct BindgenCommand {
114114
/// Mark any enum whose name matches REGEX as a Rust enum.
115115
#[arg(long, value_name = "REGEX")]
116116
rustified_enum: Vec<String>,
117+
/// Mark any enum whose name matches REGEX as a non-exhaustive Rust enum.
118+
#[arg(long, value_name = "REGEX")]
119+
rustified_non_exhaustive_enum: Vec<String>,
117120
/// Mark any enum whose name matches REGEX as a series of constants.
118121
#[arg(long, value_name = "REGEX")]
119122
constified_enum: Vec<String>,
@@ -469,6 +472,7 @@ where
469472
newtype_enum,
470473
newtype_global_enum,
471474
rustified_enum,
475+
rustified_non_exhaustive_enum,
472476
constified_enum,
473477
constified_enum_module,
474478
default_macro_constant_type,
@@ -635,6 +639,10 @@ where
635639
builder = builder.rustified_enum(regex);
636640
}
637641

642+
for regex in rustified_non_exhaustive_enum {
643+
builder = builder.rustified_non_exhaustive_enum(regex);
644+
}
645+
638646
for regex in constified_enum {
639647
builder = builder.constified_enum(regex);
640648
}

bindgen/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ impl std::fmt::Display for Formatter {
237237
/// 2. [`bitfield_enum()`](#method.bitfield_enum)
238238
/// 3. [`newtype_enum()`](#method.newtype_enum)
239239
/// 4. [`rustified_enum()`](#method.rustified_enum)
240+
/// 5. [`rustified_non_exhaustive_enum()`](#method.rustified_non_exhaustive_enum)
240241
///
241242
/// For each C enum, bindgen tries to match the pattern in the following order:
242243
///

0 commit comments

Comments
 (0)