Skip to content

Commit 90459e8

Browse files
committed
Update to latest clippy
1 parent 32e52e8 commit 90459e8

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

src/tools/miri/src/shims/backtrace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
102102
let ptr_layout = this.layout_of(ptr_ty)?;
103103

104104
for (i, ptr) in ptrs.into_iter().enumerate() {
105-
let offset = ptr_layout.size * i.try_into().unwrap();
105+
let offset = ptr_layout.size.checked_mul(i.try_into().unwrap(), this).unwrap();
106106

107107
let op_place = buf_place.offset(offset, ptr_layout, this)?;
108108

src/tools/miri/src/shims/foreign_items.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
166166
dependency_format.1.iter().enumerate().filter_map(|(num, &linkage)| {
167167
// We add 1 to the number because that's what rustc also does everywhere it
168168
// calls `CrateNum::new`...
169-
#[allow(clippy::integer_arithmetic)]
169+
#[allow(clippy::arithmetic_side_effects)]
170170
(linkage != Linkage::NotLinked).then_some(CrateNum::new(num + 1))
171171
}),
172172
) {
@@ -707,7 +707,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
707707
.position(|&c| c == val)
708708
{
709709
let idx = u64::try_from(idx).unwrap();
710-
#[allow(clippy::integer_arithmetic)] // idx < num, so this never wraps
710+
#[allow(clippy::arithmetic_side_effects)] // idx < num, so this never wraps
711711
let new_ptr = ptr.offset(Size::from_bytes(num - idx - 1), this)?;
712712
this.write_pointer(new_ptr, dest)?;
713713
} else {
@@ -916,10 +916,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
916916
let a = this.read_scalar(a)?.to_u64()?;
917917
let b = this.read_scalar(b)?.to_u64()?;
918918

919-
#[allow(clippy::integer_arithmetic)]
919+
#[allow(clippy::arithmetic_side_effects)]
920920
// adding two u64 and a u8 cannot wrap in a u128
921921
let wide_sum = u128::from(c_in) + u128::from(a) + u128::from(b);
922-
#[allow(clippy::integer_arithmetic)] // it's a u128, we can shift by 64
922+
#[allow(clippy::arithmetic_side_effects)] // it's a u128, we can shift by 64
923923
let (c_out, sum) = ((wide_sum >> 64).truncate::<u8>(), wide_sum.truncate::<u64>());
924924

925925
let c_out_field = this.place_field(dest, 0)?;

src/tools/miri/src/shims/intrinsics/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ fn simd_bitmask_index(idx: u32, vec_len: u32, endianness: Endian) -> u32 {
612612
assert!(idx < vec_len);
613613
match endianness {
614614
Endian::Little => idx,
615-
#[allow(clippy::integer_arithmetic)] // idx < vec_len
615+
#[allow(clippy::arithmetic_side_effects)] // idx < vec_len
616616
Endian::Big => vec_len - 1 - idx, // reverse order of bits
617617
}
618618
}

src/tools/miri/src/shims/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::integer_arithmetic)]
1+
#![warn(clippy::arithmetic_side_effects)]
22

33
mod backtrace;
44
#[cfg(target_os = "linux")]

src/tools/miri/src/shims/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
108108
Ok(0)
109109
}
110110

111-
#[allow(non_snake_case, clippy::integer_arithmetic)]
111+
#[allow(non_snake_case, clippy::arithmetic_side_effects)]
112112
fn GetSystemTimeAsFileTime(
113113
&mut self,
114114
LPFILETIME_op: &OpTy<'tcx, Provenance>,

src/tools/miri/src/shims/tls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'tcx> Default for TlsData<'tcx> {
5656
impl<'tcx> TlsData<'tcx> {
5757
/// Generate a new TLS key with the given destructor.
5858
/// `max_size` determines the integer size the key has to fit in.
59-
#[allow(clippy::integer_arithmetic)]
59+
#[allow(clippy::arithmetic_side_effects)]
6060
pub fn create_tls_key(
6161
&mut self,
6262
dtor: Option<ty::Instance<'tcx>>,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ pub struct DirHandler {
458458
}
459459

460460
impl DirHandler {
461-
#[allow(clippy::integer_arithmetic)]
461+
#[allow(clippy::arithmetic_side_effects)]
462462
fn insert_new(&mut self, read_dir: ReadDir) -> u64 {
463463
let id = self.next_id;
464464
self.next_id += 1;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn futex<'tcx>(
247247
// before doing the syscall.
248248
this.atomic_fence(AtomicFenceOrd::SeqCst)?;
249249
let mut n = 0;
250-
#[allow(clippy::integer_arithmetic)]
250+
#[allow(clippy::arithmetic_side_effects)]
251251
for _ in 0..val {
252252
if let Some(thread) = this.futex_wake(addr_usize, bitset) {
253253
this.unblock_thread(thread);

src/tools/miri/src/shims/windows/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
219219
.copied()
220220
.scan(Size::ZERO, |a, x| {
221221
let res = Some(*a);
222-
*a += x;
222+
*a = a.checked_add(x, this).unwrap();
223223
res
224224
})
225225
.collect();

src/tools/miri/src/shims/windows/handle.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Handle {
6262
let floor_log2 = variant_count.ilog2();
6363

6464
// we need to add one for non powers of two to compensate for the difference
65-
#[allow(clippy::integer_arithmetic)] // cannot overflow
65+
#[allow(clippy::arithmetic_side_effects)] // cannot overflow
6666
if variant_count.is_power_of_two() { floor_log2 } else { floor_log2 + 1 }
6767
}
6868

@@ -87,7 +87,7 @@ impl Handle {
8787

8888
// packs the data into the lower `data_size` bits
8989
// and packs the discriminant right above the data
90-
#[allow(clippy::integer_arithmetic)] // cannot overflow
90+
#[allow(clippy::arithmetic_side_effects)] // cannot overflow
9191
return discriminant << data_size | data;
9292
}
9393

@@ -106,11 +106,11 @@ impl Handle {
106106
let data_size = u32::BITS.checked_sub(disc_size).unwrap();
107107

108108
// the lower `data_size` bits of this mask are 1
109-
#[allow(clippy::integer_arithmetic)] // cannot overflow
109+
#[allow(clippy::arithmetic_side_effects)] // cannot overflow
110110
let data_mask = 2u32.pow(data_size) - 1;
111111

112112
// the discriminant is stored right above the lower `data_size` bits
113-
#[allow(clippy::integer_arithmetic)] // cannot overflow
113+
#[allow(clippy::arithmetic_side_effects)] // cannot overflow
114114
let discriminant = handle >> data_size;
115115

116116
// the data is stored in the lower `data_size` bits

0 commit comments

Comments
 (0)