Skip to content

Commit ac78e07

Browse files
committed
Rename a couple miscalled identifiers.
See #1575
1 parent ccc43cd commit ac78e07

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/codegen/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -2170,10 +2170,10 @@ impl MethodCodegen for Method {
21702170
#[derive(Copy, Clone, PartialEq, Debug)]
21712171
pub enum EnumVariation {
21722172
/// The code for this enum will use a Rust enum
2173-
///
2174-
/// When the boolean parameter on this variant is set to true,
2175-
/// the generated enum should be non_exhaustive.
2176-
Rust(bool),
2173+
Rust {
2174+
/// Indicates whether the generated struct should be #[non_exhaustive]
2175+
non_exhaustive: bool
2176+
},
21772177
/// The code for this enum will use a bitfield
21782178
Bitfield,
21792179
/// The code for this enum will use consts
@@ -2185,7 +2185,7 @@ pub enum EnumVariation {
21852185
impl EnumVariation {
21862186
fn is_rust(&self) -> bool {
21872187
match *self {
2188-
EnumVariation::Rust(_) => true,
2188+
EnumVariation::Rust{ non_exhaustive: _ } => true,
21892189
_ => false
21902190
}
21912191
}
@@ -2212,8 +2212,8 @@ impl std::str::FromStr for EnumVariation {
22122212
/// Create a `EnumVariation` from a string.
22132213
fn from_str(s: &str) -> Result<Self, Self::Err> {
22142214
match s {
2215-
"rust" => Ok(EnumVariation::Rust(false)),
2216-
"rust_non_exhaustive" => Ok(EnumVariation::Rust(true)),
2215+
"rust" => Ok(EnumVariation::Rust{ non_exhaustive: false }),
2216+
"rust_non_exhaustive" => Ok(EnumVariation::Rust{ non_exhaustive: true }),
22172217
"bitfield" => Ok(EnumVariation::Bitfield),
22182218
"consts" => Ok(EnumVariation::Consts),
22192219
"moduleconsts" => Ok(EnumVariation::ModuleConsts),
@@ -2285,7 +2285,7 @@ impl<'a> EnumBuilder<'a> {
22852285
}
22862286
}
22872287

2288-
EnumVariation::Rust(_) => {
2288+
EnumVariation::Rust { non_exhaustive: _ } => {
22892289
let tokens = quote!();
22902290
EnumBuilder::Rust {
22912291
codegen_depth: enum_codegen_depth + 1,
@@ -2578,9 +2578,9 @@ impl CodeGenerator for Enum {
25782578

25792579
// TODO(emilio): Delegate this to the builders?
25802580
match variation {
2581-
EnumVariation::Rust(non_exhaustive) => {
2581+
EnumVariation::Rust { non_exhaustive: nh } => {
25822582
attrs.push(attributes::repr(repr_name));
2583-
if non_exhaustive {
2583+
if nh {
25842584
attrs.push(attributes::non_exhaustive());
25852585
}
25862586
},

src/ir/enum_ty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ impl Enum {
164164
} else if self.is_matching_enum(ctx, &ctx.options().bitfield_enums, item) {
165165
EnumVariation::Bitfield
166166
} else if self.is_matching_enum(ctx, &ctx.options().rustified_enums, item) {
167-
EnumVariation::Rust(false)
168-
} else if self.is_matching_enum(ctx, &ctx.options().rustified_enums_non_exhaustive, item) {
169-
EnumVariation::Rust(true)
167+
EnumVariation::Rust { non_exhaustive: false }
168+
} else if self.is_matching_enum(ctx, &ctx.options().rustified_non_exhaustive_enums, item) {
169+
EnumVariation::Rust { non_exhaustive: true }
170170
} else if self.is_matching_enum(ctx, &ctx.options().constified_enums, item) {
171171
EnumVariation::Consts
172172
} else {

src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ impl Builder {
226226
if self.options.default_enum_style != Default::default() {
227227
output_vector.push("--default-enum-style=".into());
228228
output_vector.push(match self.options.default_enum_style {
229-
codegen::EnumVariation::Rust(false) => "rust",
230-
codegen::EnumVariation::Rust(true) => "rust_non_exhaustive",
229+
codegen::EnumVariation::Rust { non_exhaustive: false } => "rust",
230+
codegen::EnumVariation::Rust { non_exhaustive: true } => "rust_non_exhaustive",
231231
codegen::EnumVariation::Bitfield => "bitfield",
232232
codegen::EnumVariation::Consts => "consts",
233233
codegen::EnumVariation::ModuleConsts => "moduleconsts",
@@ -255,7 +255,7 @@ impl Builder {
255255
.count();
256256

257257
self.options
258-
.rustified_enums_non_exhaustive
258+
.rustified_non_exhaustive_enums
259259
.get_items()
260260
.iter()
261261
.map(|item| {
@@ -834,8 +834,8 @@ impl Builder {
834834
///
835835
/// This makes bindgen generate enums instead of constants. Regular
836836
/// expressions are supported.
837-
pub fn rustified_enum_non_exhaustive<T: AsRef<str>>(mut self, arg: T) -> Builder {
838-
self.options.rustified_enums_non_exhaustive.insert(arg);
837+
pub fn rustified_non_exhaustive_enum<T: AsRef<str>>(mut self, arg: T) -> Builder {
838+
self.options.rustified_non_exhaustive_enums.insert(arg);
839839
self
840840
}
841841

@@ -1387,7 +1387,7 @@ struct BindgenOptions {
13871387
/// The enum patterns to mark an enum as a Rust enum.
13881388
rustified_enums: RegexSet,
13891389

1390-
rustified_enums_non_exhaustive: RegexSet,
1390+
rustified_non_exhaustive_enums: RegexSet,
13911391

13921392
/// The enum patterns to mark an enum as a module of constants.
13931393
constified_enum_modules: RegexSet,
@@ -1642,7 +1642,7 @@ impl Default for BindgenOptions {
16421642
default_enum_style: Default::default(),
16431643
bitfield_enums: Default::default(),
16441644
rustified_enums: Default::default(),
1645-
rustified_enums_non_exhaustive: Default::default(),
1645+
rustified_non_exhaustive_enums: Default::default(),
16461646
constified_enums: Default::default(),
16471647
constified_enum_modules: Default::default(),
16481648
builtins: false,

0 commit comments

Comments
 (0)