Skip to content

Commit df1ed0c

Browse files
committed
Make a method that doesn't need Self a free function instead
1 parent a835555 commit df1ed0c

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
176176
) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>> {
177177
// get_bytes_unchecked tests alignment and relocation edges
178178
let bytes = self.get_bytes_with_undef_and_ptr(
179-
cx, ptr, size, ptr_align.min(self.int_align(cx, size))
179+
cx, ptr, size, ptr_align.min(int_align(cx, size))
180180
)?;
181181
// Undef check happens *after* we established that the alignment is correct.
182182
// We must not return Ok() for unaligned pointers!
@@ -272,24 +272,23 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
272272
let ptr_size = cx.data_layout().pointer_size;
273273
self.write_scalar(cx, ptr.into(), ptr_align, val, ptr_size)
274274
}
275+
}
275276

276-
fn int_align(
277-
&self,
278-
cx: &impl HasDataLayout,
279-
size: Size,
280-
) -> Align {
281-
// We assume pointer-sized integers have the same alignment as pointers.
282-
// We also assume signed and unsigned integers of the same size have the same alignment.
283-
let ity = match size.bytes() {
284-
1 => layout::I8,
285-
2 => layout::I16,
286-
4 => layout::I32,
287-
8 => layout::I64,
288-
16 => layout::I128,
289-
_ => bug!("bad integer size: {}", size.bytes()),
290-
};
291-
ity.align(cx).abi
292-
}
277+
fn int_align(
278+
cx: &impl HasDataLayout,
279+
size: Size,
280+
) -> Align {
281+
// We assume pointer-sized integers have the same alignment as pointers.
282+
// We also assume signed and unsigned integers of the same size have the same alignment.
283+
let ity = match size.bytes() {
284+
1 => layout::I8,
285+
2 => layout::I16,
286+
4 => layout::I32,
287+
8 => layout::I64,
288+
16 => layout::I128,
289+
_ => bug!("bad integer size: {}", size.bytes()),
290+
};
291+
ity.align(cx).abi
293292
}
294293

295294
/// Byte accessors

0 commit comments

Comments
 (0)