Skip to content

Commit 4a75b21

Browse files
kulpemilio
authored andcommitted
Make anon-fields-prefix non-optional
1 parent dfeff89 commit 4a75b21

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/ir/comp.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -825,15 +825,11 @@ impl CompFields {
825825
}
826826

827827
anon_field_counter += 1;
828-
if let Some(ref prefix) = ctx.options().anon_fields_prefix {
829-
*name =
830-
Some(format!("{}{}", prefix, anon_field_counter));
831-
} else {
832-
*name = Some(format!(
833-
"__bindgen_anon_{}",
834-
anon_field_counter
835-
));
836-
}
828+
*name = Some(format!(
829+
"{}{}",
830+
ctx.options().anon_fields_prefix,
831+
anon_field_counter
832+
));
837833
}
838834
Field::Bitfields(ref mut bu) => {
839835
for bitfield in &mut bu.bitfields {

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl Builder {
385385
output_vector.push(prefix.clone());
386386
}
387387

388-
if let Some(ref prefix) = self.options.anon_fields_prefix {
388+
if let prefix = &self.options.anon_fields_prefix {
389389
output_vector.push("--anon-fields-prefix".into());
390390
output_vector.push(prefix.clone());
391391
}
@@ -1217,9 +1217,9 @@ impl Builder {
12171217
self
12181218
}
12191219

1220-
/// Use the given prefix for the anon fields instead of `__bindgen_anon_`.
1220+
/// Use the given prefix for the anon fields.
12211221
pub fn anon_fields_prefix<T: Into<String>>(mut self, prefix: T) -> Builder {
1222-
self.options.anon_fields_prefix = Some(prefix.into());
1222+
self.options.anon_fields_prefix = prefix.into();
12231223
self
12241224
}
12251225

@@ -1601,8 +1601,8 @@ struct BindgenOptions {
16011601
/// An optional prefix for the "raw" types, like `c_int`, `c_void`...
16021602
ctypes_prefix: Option<String>,
16031603

1604-
/// An optional prefix for the anon fields instead of `__bindgen_anon_`.
1605-
anon_fields_prefix: Option<String>,
1604+
/// The prefix for the anon fields.
1605+
anon_fields_prefix: String,
16061606

16071607
/// Whether to time the bindgen phases.
16081608
time_phases: bool,
@@ -1823,7 +1823,7 @@ impl Default for BindgenOptions {
18231823
disable_header_comment: false,
18241824
use_core: false,
18251825
ctypes_prefix: None,
1826-
anon_fields_prefix: None,
1826+
anon_fields_prefix: "__bindgen_anon_".into(),
18271827
namespaced_constants: true,
18281828
msvc_mangling: false,
18291829
convert_floats: true,

src/options.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,9 @@ where
236236
.takes_value(true),
237237
Arg::with_name("anon-fields-prefix")
238238
.long("anon-fields-prefix")
239-
.help(
240-
"Use the given prefix for the anon fields instead of \
241-
__bindgen_anon_.",
242-
)
239+
.help("Use the given prefix for the anon fields.")
243240
.value_name("prefix")
241+
.default_value("__bindgen_anon_")
244242
.takes_value(true),
245243
Arg::with_name("time-phases")
246244
.long("time-phases")

0 commit comments

Comments
 (0)