Skip to content

Commit ca2bf57

Browse files
authored
Rollup merge of #158542 - scottmcm:scalar-but-packed, r=workingjubilee
Rename `align` to `default_align` on `Scalar` and `Primitive` To emphasize that just because you see a `Scalar(I32)` that doesn't really tell you anything about the alignment it has -- one should be looking at the type (well, the place) for that. (The `size` method doesn't really have that problem -- i32 is always 4 bytes, no matter the context -- so is left untouched.) No actual layout or behaviour changes in *this* PR. Just the rename and some comments. r? @workingjubilee
2 parents 0b425d4 + 0df4855 commit ca2bf57

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
10651065
},
10661066
)
10671067
} else if let abi::BackendRepr::ScalarPair(ref a, ref b) = place.layout.backend_repr {
1068-
let b_offset = a.size(self).align_to(b.align(self).abi);
1068+
let b_offset = a.size(self).align_to(b.default_align(self).abi);
10691069

10701070
let mut load = |i, scalar: &abi::Scalar, align| {
10711071
let ptr = if i == 0 {

src/type_of.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
325325
return cx.type_i1();
326326
}
327327

328-
let offset = if index == 0 { Size::ZERO } else { a.size(cx).align_to(b.align(cx).abi) };
328+
let offset =
329+
if index == 0 { Size::ZERO } else { a.size(cx).align_to(b.default_align(cx).abi) };
329330
self.scalar_gcc_type_at(cx, scalar, offset)
330331
}
331332

0 commit comments

Comments
 (0)