Skip to content

Commit c1b8d66

Browse files
committed
teach clippy about IeeeFloat, and make all 'allow' into 'expect'
1 parent 3253cc6 commit c1b8d66

File tree

21 files changed

+28
-39
lines changed

21 files changed

+28
-39
lines changed

src/tools/miri/clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
arithmetic-side-effects-allowed = ["rustc_abi::Size"]
1+
arithmetic-side-effects-allowed = ["rustc_abi::Size", "rustc_apfloat::ieee::IeeeFloat"]

src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'tcx> Stack {
354354
self.borrows.get(idx).cloned()
355355
}
356356

357-
#[allow(clippy::len_without_is_empty)] // Stacks are never empty
357+
#[expect(clippy::len_without_is_empty)] // Stacks are never empty
358358
pub fn len(&self) -> usize {
359359
self.borrows.len()
360360
}

src/tools/miri/src/concurrency/weak_memory.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ impl<'tcx> StoreBuffer {
300300
interp_ok(())
301301
}
302302

303-
#[allow(clippy::if_same_then_else, clippy::needless_bool)]
304303
/// Selects a valid store element in the buffer.
305304
fn fetch_store<R: rand::Rng + ?Sized>(
306305
&self,

src/tools/miri/src/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ pub fn create_ecx<'tcx>(
423423
/// Evaluates the entry function specified by `entry_id`.
424424
/// Returns `Some(return_code)` if program executed completed.
425425
/// Returns `None` if an evaluation error occurred.
426-
#[allow(clippy::needless_lifetimes)]
426+
#[expect(clippy::needless_lifetimes)]
427427
pub fn eval_entry<'tcx>(
428428
tcx: TyCtxt<'tcx>,
429429
entry_id: DefId,

src/tools/miri/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn iter_exported_symbols<'tcx>(
156156
for cnum in dependency_format.1.iter().enumerate().filter_map(|(num, &linkage)| {
157157
// We add 1 to the number because that's what rustc also does everywhere it
158158
// calls `CrateNum::new`...
159-
#[allow(clippy::arithmetic_side_effects)]
159+
#[expect(clippy::arithmetic_side_effects)]
160160
(linkage != Linkage::NotLinked).then_some(CrateNum::new(num + 1))
161161
}) {
162162
// We can ignore `_export_info` here: we are a Rust crate, and everything is exported

src/tools/miri/src/intrinsics/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
292292
let b = this.read_scalar(b)?.to_f32()?;
293293
let c = this.read_scalar(c)?.to_f32()?;
294294
let fuse: bool = this.machine.rng.get_mut().gen();
295-
#[allow(clippy::arithmetic_side_effects)] // float ops don't overflow
296295
let res = if fuse {
297296
// FIXME: Using host floats, to work around https://github.com/rust-lang/rustc_apfloat/issues/11
298297
a.to_host().mul_add(b.to_host(), c.to_host()).to_soft()
@@ -308,7 +307,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
308307
let b = this.read_scalar(b)?.to_f64()?;
309308
let c = this.read_scalar(c)?.to_f64()?;
310309
let fuse: bool = this.machine.rng.get_mut().gen();
311-
#[allow(clippy::arithmetic_side_effects)] // float ops don't overflow
312310
let res = if fuse {
313311
// FIXME: Using host floats, to work around https://github.com/rust-lang/rustc_apfloat/issues/11
314312
a.to_host().mul_add(b.to_host(), c.to_host()).to_soft()

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
750750

751751
let val = if simd_element_to_bool(mask)? {
752752
// Size * u64 is implemented as always checked
753-
#[allow(clippy::arithmetic_side_effects)]
754753
let ptr = ptr.wrapping_offset(dest.layout.size * i, this);
755754
let place = this.ptr_to_mplace(ptr, dest.layout);
756755
this.read_immediate(&place)?
@@ -774,7 +773,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
774773

775774
if simd_element_to_bool(mask)? {
776775
// Size * u64 is implemented as always checked
777-
#[allow(clippy::arithmetic_side_effects)]
778776
let ptr = ptr.wrapping_offset(val.layout.size * i, this);
779777
let place = this.ptr_to_mplace(ptr, val.layout);
780778
this.write_immediate(*val, &place)?
@@ -831,7 +829,7 @@ fn simd_bitmask_index(idx: u32, vec_len: u32, endianness: Endian) -> u32 {
831829
assert!(idx < vec_len);
832830
match endianness {
833831
Endian::Little => idx,
834-
#[allow(clippy::arithmetic_side_effects)] // idx < vec_len
832+
#[expect(clippy::arithmetic_side_effects)] // idx < vec_len
835833
Endian::Big => vec_len - 1 - idx, // reverse order of bits
836834
}
837835
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::*;
2121
#[derive(Debug, Copy, Clone)]
2222
pub struct DynSym(Symbol);
2323

24-
#[allow(clippy::should_implement_trait)]
24+
#[expect(clippy::should_implement_trait)]
2525
impl DynSym {
2626
pub fn from_str(name: &str) -> Self {
2727
DynSym(Symbol::intern(name))
@@ -648,7 +648,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
648648
let val = this.read_scalar(val)?.to_i32()?;
649649
let num = this.read_target_usize(num)?;
650650
// The docs say val is "interpreted as unsigned char".
651-
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
651+
#[expect(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
652652
let val = val as u8;
653653

654654
// C requires that this must always be a valid pointer (C18 §7.1.4).
@@ -661,7 +661,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
661661
.position(|&c| c == val)
662662
{
663663
let idx = u64::try_from(idx).unwrap();
664-
#[allow(clippy::arithmetic_side_effects)] // idx < num, so this never wraps
664+
#[expect(clippy::arithmetic_side_effects)] // idx < num, so this never wraps
665665
let new_ptr = ptr.wrapping_offset(Size::from_bytes(num - idx - 1), this);
666666
this.write_pointer(new_ptr, dest)?;
667667
} else {
@@ -675,7 +675,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
675675
let val = this.read_scalar(val)?.to_i32()?;
676676
let num = this.read_target_usize(num)?;
677677
// The docs say val is "interpreted as unsigned char".
678-
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
678+
#[expect(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
679679
let val = val as u8;
680680

681681
// C requires that this must always be a valid pointer (C18 §7.1.4).

src/tools/miri/src/shims/io_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
188188
}
189189

190190
/// The inverse of `io_error_to_errnum`.
191-
#[allow(clippy::needless_return)]
191+
#[expect(clippy::needless_return)]
192192
fn try_errnum_to_io_error(
193193
&self,
194194
errnum: Scalar,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> Default for TlsData<'tcx> {
5353
impl<'tcx> TlsData<'tcx> {
5454
/// Generate a new TLS key with the given destructor.
5555
/// `max_size` determines the integer size the key has to fit in.
56-
#[allow(clippy::arithmetic_side_effects)]
56+
#[expect(clippy::arithmetic_side_effects)]
5757
pub fn create_tls_key(
5858
&mut self,
5959
dtor: Option<ty::Instance<'tcx>>,

0 commit comments

Comments
 (0)