diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-13 14:32:39 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-24 11:36:31 +0100 |
| commit | df1ed0c2a68d0a38d98434b734ed042f7b976e5e (patch) | |
| tree | d60884d8e620d55debca23a9e7dbb4fd5f9b8865 | |
| parent | a835555474c87def84099df412816d5edfa2b9cb (diff) | |
| download | rust-df1ed0c2a68d0a38d98434b734ed042f7b976e5e.tar.gz rust-df1ed0c2a68d0a38d98434b734ed042f7b976e5e.zip | |
Make a method that doesn't need `Self` a free function instead
| -rw-r--r-- | src/librustc/mir/interpret/allocation.rs | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index ba2755b29f0..bafa32df848 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -176,7 +176,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> { ) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>> { // get_bytes_unchecked tests alignment and relocation edges let bytes = self.get_bytes_with_undef_and_ptr( - cx, ptr, size, ptr_align.min(self.int_align(cx, size)) + cx, ptr, size, ptr_align.min(int_align(cx, size)) )?; // Undef check happens *after* we established that the alignment is correct. // We must not return Ok() for unaligned pointers! @@ -272,24 +272,23 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> { let ptr_size = cx.data_layout().pointer_size; self.write_scalar(cx, ptr.into(), ptr_align, val, ptr_size) } +} - fn int_align( - &self, - cx: &impl HasDataLayout, - size: Size, - ) -> Align { - // We assume pointer-sized integers have the same alignment as pointers. - // We also assume signed and unsigned integers of the same size have the same alignment. - let ity = match size.bytes() { - 1 => layout::I8, - 2 => layout::I16, - 4 => layout::I32, - 8 => layout::I64, - 16 => layout::I128, - _ => bug!("bad integer size: {}", size.bytes()), - }; - ity.align(cx).abi - } +fn int_align( + cx: &impl HasDataLayout, + size: Size, +) -> Align { + // We assume pointer-sized integers have the same alignment as pointers. + // We also assume signed and unsigned integers of the same size have the same alignment. + let ity = match size.bytes() { + 1 => layout::I8, + 2 => layout::I16, + 4 => layout::I32, + 8 => layout::I64, + 16 => layout::I128, + _ => bug!("bad integer size: {}", size.bytes()), + }; + ity.align(cx).abi } /// Byte accessors |
