diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-05 08:26:32 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-05 10:55:35 +0200 |
| commit | 226b0fbe11812c71c8002b10a40063571cf52b3f (patch) | |
| tree | 20deaf0bfa759fbeeb59a7ea782790d84af63b80 /compiler/rustc_const_eval/src/interpret/memory.rs | |
| parent | 733b47ea4b1b86216f14ef56e49440c33933f230 (diff) | |
| download | rust-226b0fbe11812c71c8002b10a40063571cf52b3f.tar.gz rust-226b0fbe11812c71c8002b10a40063571cf52b3f.zip | |
use `is_multiple_of` instead of manual modulo
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/memory.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index ff822b52a8d..c97d53a45de 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -537,7 +537,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { #[inline] fn is_offset_misaligned(offset: u64, align: Align) -> Option<Misalignment> { - if offset % align.bytes() == 0 { + if offset.is_multiple_of(align.bytes()) { None } else { // The biggest power of two through which `offset` is divisible. @@ -1554,7 +1554,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // If the allocation is N-aligned, and the offset is not divisible by N, // then `base + offset` has a non-zero remainder after division by `N`, // which means `base + offset` cannot be null. - if offset.bytes() % info.align.bytes() != 0 { + if !offset.bytes().is_multiple_of(info.align.bytes()) { return interp_ok(false); } // We don't know enough, this might be null. |
