Skip to content

Commit 35e6def

Browse files
committed
clippy
1 parent cff5a7c commit 35e6def

File tree

7 files changed

+8
-10
lines changed

7 files changed

+8
-10
lines changed

src/tools/miri/src/alloc/isolated_alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl IsolatedAlloc {
189189
};
190190
assert_ne!(page_ptr.addr(), usize::MAX, "mmap failed");
191191
// `page_infos` has to have one bit for each `COMPRESSION_FACTOR`-sized chunk of bytes in the page.
192-
assert!(self.page_size % COMPRESSION_FACTOR == 0);
192+
assert!(self.page_size.is_multiple_of(COMPRESSION_FACTOR));
193193
self.page_infos.push(DenseBitSet::new_empty(self.page_size / COMPRESSION_FACTOR));
194194
self.page_ptrs.push(NonNull::new(page_ptr).unwrap());
195195
(NonNull::new(page_ptr).unwrap(), self.page_infos.last_mut().unwrap())

src/tools/miri/src/alloc_addresses/reuse_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl ReusePool {
129129
let idx = rng.random_range(begin..end);
130130
// Remove it from the pool and return.
131131
let (chosen_addr, chosen_size, chosen_thread, clock) = subpool.remove(idx);
132-
debug_assert!(chosen_size >= size && chosen_addr % align.bytes() == 0);
132+
debug_assert!(chosen_size >= size && chosen_addr.is_multiple_of(align.bytes()));
133133
debug_assert!(cross_thread_reuse || chosen_thread == thread);
134134
// No synchronization needed if we reused from the current thread.
135135
Some((chosen_addr, if chosen_thread == thread { None } else { Some(clock) }))

src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ mod tests {
327327
for i in 0..1000 {
328328
i.hash(&mut hasher);
329329
let rng = hasher.finish();
330-
let op = rng % 3 == 0;
330+
let op = rng.is_multiple_of(3);
331331
let key = (rng / 2) % 50;
332332
let val = (rng / 100) % 1000;
333333
if op {

src/tools/miri/src/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10561056
// What's the offset between us and the promised alignment?
10571057
let distance = offset.bytes().wrapping_sub(promised_offset.bytes());
10581058
// That must also be aligned.
1059-
if distance % align.bytes() == 0 {
1059+
if distance.is_multiple_of(align.bytes()) {
10601060
// All looking good!
10611061
None
10621062
} else {
@@ -1612,7 +1612,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
16121612
ecx.machine.since_gc += 1;
16131613
// Possibly report our progress. This will point at the terminator we are about to execute.
16141614
if let Some(report_progress) = ecx.machine.report_progress {
1615-
if ecx.machine.basic_block_count % u64::from(report_progress) == 0 {
1615+
if ecx.machine.basic_block_count.is_multiple_of(u64::from(report_progress)) {
16161616
ecx.emit_diagnostic(NonHaltingDiagnostic::ProgressReport {
16171617
block_count: ecx.machine.basic_block_count,
16181618
});

src/tools/miri/src/shims/unix/linux/mem.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2222
let flags = this.read_scalar(flags)?.to_i32()?;
2323

2424
// old_address must be a multiple of the page size
25-
#[expect(clippy::arithmetic_side_effects)] // PAGE_SIZE is nonzero
26-
if old_address.addr().bytes() % this.machine.page_size != 0 || new_size == 0 {
25+
if !old_address.addr().bytes().is_multiple_of(this.machine.page_size) || new_size == 0 {
2726
this.set_last_error(LibcError("EINVAL"))?;
2827
return interp_ok(this.eval_libc("MAP_FAILED"));
2928
}

src/tools/miri/src/shims/unix/mem.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
130130

131131
// addr must be a multiple of the page size, but apart from that munmap is just implemented
132132
// as a dealloc.
133-
#[expect(clippy::arithmetic_side_effects)] // PAGE_SIZE is nonzero
134-
if addr.addr().bytes() % this.machine.page_size != 0 {
133+
if !addr.addr().bytes().is_multiple_of(this.machine.page_size) {
135134
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
136135
}
137136

src/tools/miri/src/shims/unix/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn bytewise_equal_atomic_relaxed<'tcx>(
1717

1818
// We do this in chunks of 4, so that we are okay to race with (sufficiently aligned)
1919
// 4-byte atomic accesses.
20-
assert!(size.bytes() % 4 == 0);
20+
assert!(size.bytes().is_multiple_of(4));
2121
for i in 0..(size.bytes() / 4) {
2222
let offset = Size::from_bytes(i.strict_mul(4));
2323
let load = |place: &MPlaceTy<'tcx>| {

0 commit comments

Comments
 (0)