Skip to content

Commit 8fca246

Browse files
committed
check_struct_for_power_alignment: pick a more sensible variable name
1 parent 0ce0251 commit 8fca246

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

compiler/rustc_lint/src/types.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1623,15 +1623,13 @@ impl ImproperCTypesDefinitions {
16231623
cx: &LateContext<'tcx>,
16241624
ty: Ty<'tcx>,
16251625
) -> bool {
1626+
assert!(cx.tcx.sess.target.os == "aix");
16261627
// Structs (under repr(C)) follow the power alignment rule if:
16271628
// - the first field of the struct is a floating-point type that
16281629
// is greater than 4-bytes, or
16291630
// - the first field of the struct is an aggregate whose
16301631
// recursively first field is a floating-point type greater than
16311632
// 4 bytes.
1632-
if cx.tcx.sess.target.os != "aix" {
1633-
return false;
1634-
}
16351633
if ty.is_floating_point() && ty.primitive_size(cx.tcx).bytes() > 4 {
16361634
return true;
16371635
} else if let Adt(adt_def, _) = ty.kind()
@@ -1668,15 +1666,11 @@ impl ImproperCTypesDefinitions {
16681666
// power alignment rule, as fields after the first are likely
16691667
// to be the fields that are misaligned.
16701668
if index != 0 {
1671-
let first_field_def = struct_variant_data.fields()[index];
1672-
let def_id = first_field_def.def_id;
1669+
let field_def = struct_variant_data.fields()[index];
1670+
let def_id = field_def.def_id;
16731671
let ty = cx.tcx.type_of(def_id).instantiate_identity();
16741672
if self.check_arg_for_power_alignment(cx, ty) {
1675-
cx.emit_span_lint(
1676-
USES_POWER_ALIGNMENT,
1677-
first_field_def.span,
1678-
UsesPowerAlignment,
1679-
);
1673+
cx.emit_span_lint(USES_POWER_ALIGNMENT, field_def.span, UsesPowerAlignment);
16801674
}
16811675
}
16821676
}

0 commit comments

Comments
 (0)