Skip to content

Commit bcf0832

Browse files
author
bors-servo
authored
Auto merge of #1078 - fitzgen:bitfield-width, r=pepyakin
Rename `bitfield` to `bitfield_width` Its more clear what the methods/fields are returning/storing when we add "width" to the name. r? @pepyakin
2 parents fc63260 + 1f15e60 commit bcf0832

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/codegen/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ impl<'a> FieldCodegen<'a> for FieldData {
961961
{
962962
// Bitfields are handled by `FieldCodegen` implementations for
963963
// `BitfieldUnit` and `Bitfield`.
964-
assert!(self.bitfield().is_none());
964+
assert!(self.bitfield_width().is_none());
965965

966966
let field_item = self.ty().into_resolver().through_type_refs().resolve(ctx);
967967
let field_ty = field_item.expect_type();
@@ -1166,7 +1166,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
11661166
} else {
11671167
helpers::blob(self.layout())
11681168
};
1169-
1169+
11701170
let unit_field_name = format!("_bitfield_{}", self.nth());
11711171
let unit_field_ident = ctx.rust_ident(&unit_field_name);
11721172

@@ -1656,8 +1656,8 @@ impl CodeGenerator for CompInfo {
16561656
if item.can_derive_partialeq(ctx) {
16571657
derives.push("PartialEq");
16581658
} else {
1659-
needs_partialeq_impl =
1660-
ctx.options().derive_partialeq &&
1659+
needs_partialeq_impl =
1660+
ctx.options().derive_partialeq &&
16611661
ctx.options().impl_partialeq &&
16621662
ctx.lookup_can_derive_partialeq_or_partialord(item.id())
16631663
.map_or(true, |x| {
@@ -1889,7 +1889,7 @@ impl CodeGenerator for CompInfo {
18891889

18901890
if needs_partialeq_impl {
18911891
if let Some(impl_) = impl_partialeq::gen_partialeq_impl(ctx, self, item, &ty_for_impl) {
1892-
1892+
18931893
let partialeq_bounds = if !generic_param_names.is_empty() {
18941894
let bounds = generic_param_names.iter().map(|t| {
18951895
quote! { #t: PartialEq }

src/ir/comp.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait FieldMethods {
118118
fn comment(&self) -> Option<&str>;
119119

120120
/// If this is a bitfield, how many bits does it need?
121-
fn bitfield(&self) -> Option<u32>;
121+
fn bitfield_width(&self) -> Option<u32>;
122122

123123
/// Is this field marked as `mutable`?
124124
fn is_mutable(&self) -> bool;
@@ -295,20 +295,20 @@ pub struct Bitfield {
295295
data: FieldData,
296296

297297
/// Name of the generated Rust getter for this bitfield.
298-
///
298+
///
299299
/// Should be assigned before codegen.
300300
getter_name: Option<String>,
301301

302302
/// Name of the generated Rust setter for this bitfield.
303-
///
303+
///
304304
/// Should be assigned before codegen.
305305
setter_name: Option<String>,
306306
}
307307

308308
impl Bitfield {
309309
/// Construct a new bitfield.
310310
fn new(offset_into_unit: usize, raw: RawField) -> Bitfield {
311-
assert!(raw.bitfield().is_some());
311+
assert!(raw.bitfield_width().is_some());
312312

313313
Bitfield {
314314
offset_into_unit: offset_into_unit,
@@ -342,12 +342,12 @@ impl Bitfield {
342342

343343
/// Get the bit width of this bitfield.
344344
pub fn width(&self) -> u32 {
345-
self.data.bitfield().unwrap()
345+
self.data.bitfield_width().unwrap()
346346
}
347347

348348
/// Name of the generated Rust getter for this bitfield.
349-
///
350-
/// Panics if called before assigning bitfield accessor names or if
349+
///
350+
/// Panics if called before assigning bitfield accessor names or if
351351
/// this bitfield have no name.
352352
pub fn getter_name(&self) -> &str {
353353
assert!(self.name().is_some(), "`Bitfield::getter_name` called on anonymous field");
@@ -358,8 +358,8 @@ impl Bitfield {
358358
}
359359

360360
/// Name of the generated Rust setter for this bitfield.
361-
///
362-
/// Panics if called before assigning bitfield accessor names or if
361+
///
362+
/// Panics if called before assigning bitfield accessor names or if
363363
/// this bitfield have no name.
364364
pub fn setter_name(&self) -> &str {
365365
assert!(self.name().is_some(), "`Bitfield::setter_name` called on anonymous field");
@@ -383,8 +383,8 @@ impl FieldMethods for Bitfield {
383383
self.data.comment()
384384
}
385385

386-
fn bitfield(&self) -> Option<u32> {
387-
self.data.bitfield()
386+
fn bitfield_width(&self) -> Option<u32> {
387+
self.data.bitfield_width()
388388
}
389389

390390
fn is_mutable(&self) -> bool {
@@ -415,7 +415,7 @@ impl RawField {
415415
ty: TypeId,
416416
comment: Option<String>,
417417
annotations: Option<Annotations>,
418-
bitfield: Option<u32>,
418+
bitfield_width: Option<u32>,
419419
mutable: bool,
420420
offset: Option<usize>,
421421
) -> RawField {
@@ -424,7 +424,7 @@ impl RawField {
424424
ty: ty,
425425
comment: comment,
426426
annotations: annotations.unwrap_or_default(),
427-
bitfield: bitfield,
427+
bitfield_width: bitfield_width,
428428
mutable: mutable,
429429
offset: offset,
430430
})
@@ -444,8 +444,8 @@ impl FieldMethods for RawField {
444444
self.0.comment()
445445
}
446446

447-
fn bitfield(&self) -> Option<u32> {
448-
self.0.bitfield()
447+
fn bitfield_width(&self) -> Option<u32> {
448+
self.0.bitfield_width()
449449
}
450450

451451
fn is_mutable(&self) -> bool {
@@ -481,7 +481,7 @@ where
481481
{
482482
let non_bitfields = raw_fields
483483
.by_ref()
484-
.peeking_take_while(|f| f.bitfield().is_none())
484+
.peeking_take_while(|f| f.bitfield_width().is_none())
485485
.map(|f| Field::DataMember(f.0));
486486
fields.extend(non_bitfields);
487487
}
@@ -491,7 +491,7 @@ where
491491
// the Itanium C++ ABI.
492492
let mut bitfields = raw_fields
493493
.by_ref()
494-
.peeking_take_while(|f| f.bitfield().is_some())
494+
.peeking_take_while(|f| f.bitfield_width().is_some())
495495
.peekable();
496496

497497
if bitfields.peek().is_none() {
@@ -569,7 +569,7 @@ fn bitfields_to_allocation_units<E, I>(
569569
const is_ms_struct: bool = false;
570570

571571
for bitfield in raw_bitfields {
572-
let bitfield_width = bitfield.bitfield().unwrap() as usize;
572+
let bitfield_width = bitfield.bitfield_width().unwrap() as usize;
573573
let bitfield_layout = ctx.resolve_type(bitfield.ty())
574574
.layout(ctx)
575575
.expect("Bitfield without layout? Gah!");
@@ -813,7 +813,7 @@ pub struct FieldData {
813813
annotations: Annotations,
814814

815815
/// If this field is a bitfield, and how many bits does it contain if it is.
816-
bitfield: Option<u32>,
816+
bitfield_width: Option<u32>,
817817

818818
/// If the C++ field is marked as `mutable`
819819
mutable: bool,
@@ -835,8 +835,8 @@ impl FieldMethods for FieldData {
835835
self.comment.as_ref().map(|c| &**c)
836836
}
837837

838-
fn bitfield(&self) -> Option<u32> {
839-
self.bitfield
838+
fn bitfield_width(&self) -> Option<u32> {
839+
self.bitfield_width
840840
}
841841

842842
fn is_mutable(&self) -> bool {

0 commit comments

Comments
 (0)