Skip to content

Commit 76d9775

Browse files
committed
allow some clippy lints
1 parent 85d6768 commit 76d9775

File tree

9 files changed

+19
-3
lines changed

9 files changed

+19
-3
lines changed

library/core/src/mem/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ pub const fn swap<T>(x: &mut T, y: &mut T) {
803803
#[inline]
804804
#[stable(feature = "mem_take", since = "1.40.0")]
805805
pub fn take<T: Default>(dest: &mut T) -> T {
806+
#[allow(clippy::mem_replace_with_default)] // exempt by being the one true definition
806807
replace(dest, T::default())
807808
}
808809

library/core/src/num/dec2flt/decimal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl Decimal {
5858
// of the x87 FPU stack to be changed so that it directly rounds to 64/32 bit.
5959
// The `set_precision` function takes care of setting the precision on architectures which
6060
// require setting it by changing the global state (like the control word of the x87 FPU).
61+
#[allow(clippy::let_unit_value)]
6162
let _cw = set_precision::<F>();
6263

6364
if !self.can_use_fast_path::<F>() {

library/core/src/num/diy_float.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct Fp {
2121

2222
impl Fp {
2323
/// Returns a correctly rounded product of itself and `other`.
24+
#[allow(clippy::should_implement_trait)]
2425
pub fn mul(self, other: Self) -> Self {
2526
let (lo, hi) = self.f.widening_mul(other.f);
2627
let f = hi + (lo >> 63) /* round */;

library/core/src/num/f32.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//! defined directly on the `f32` type.
1111
1212
#![stable(feature = "rust1", since = "1.0.0")]
13+
#![allow(clippy::excessive_precision)]
1314

1415
use crate::convert::FloatToInt;
1516
use crate::num::FpCategory;
@@ -491,13 +492,15 @@ impl f32 {
491492
/// The concrete bit pattern may change across Rust versions and target platforms.
492493
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
493494
#[rustc_diagnostic_item = "f32_nan"]
494-
#[allow(clippy::eq_op)]
495+
#[allow(clippy::eq_op, clippy::zero_divided_by_zero)]
495496
pub const NAN: f32 = 0.0_f32 / 0.0_f32;
496497
/// Infinity (∞).
497498
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
499+
#[allow(clippy::zero_divided_by_zero)]
498500
pub const INFINITY: f32 = 1.0_f32 / 0.0_f32;
499501
/// Negative infinity (−∞).
500502
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
503+
#[allow(clippy::zero_divided_by_zero)]
501504
pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32;
502505

503506
/// Sign bit

library/core/src/num/f64.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//! defined directly on the `f64` type.
1111
1212
#![stable(feature = "rust1", since = "1.0.0")]
13+
#![allow(clippy::excessive_precision)]
1314

1415
use crate::convert::FloatToInt;
1516
use crate::num::FpCategory;
@@ -490,13 +491,15 @@ impl f64 {
490491
/// The concrete bit pattern may change across Rust versions and target platforms.
491492
#[rustc_diagnostic_item = "f64_nan"]
492493
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
493-
#[allow(clippy::eq_op)]
494+
#[allow(clippy::eq_op, clippy::zero_divided_by_zero)]
494495
pub const NAN: f64 = 0.0_f64 / 0.0_f64;
495496
/// Infinity (∞).
496497
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
498+
#[allow(clippy::zero_divided_by_zero)]
497499
pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
498500
/// Negative infinity (−∞).
499501
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
502+
#[allow(clippy::zero_divided_by_zero)]
500503
pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
501504

502505
/// Sign bit

library/core/src/num/flt2dec/strategy/grisu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub fn max_pow10_no_more_than(x: u32) -> (u8, u32) {
142142
const X2: u32 = 100;
143143
const X1: u32 = 10;
144144

145+
#[allow(clippy::collapsible_else_if)]
145146
if x < X4 {
146147
if x < X2 {
147148
if x < X1 { (0, 1) } else { (1, X1) }

library/core/src/num/fmt.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum Part<'a> {
1919

2020
impl<'a> Part<'a> {
2121
/// Returns the exact byte length of given part.
22+
#[allow(clippy::len_without_is_empty)]
2223
pub fn len(&self) -> usize {
2324
match *self {
2425
Part::Zero(nzeroes) => nzeroes,
@@ -31,8 +32,10 @@ impl<'a> Part<'a> {
3132
} else {
3233
3
3334
}
35+
} else if v < 10_000 {
36+
4
3437
} else {
35-
if v < 10_000 { 4 } else { 5 }
38+
5
3639
}
3740
}
3841
Part::Copy(buf) => buf.len(),
@@ -81,6 +84,7 @@ pub struct Formatted<'a> {
8184

8285
impl<'a> Formatted<'a> {
8386
/// Returns the exact byte length of combined formatted result.
87+
#[allow(clippy::len_without_is_empty)]
8488
pub fn len(&self) -> usize {
8589
let mut len = self.sign.len();
8690
for part in self.parts {

library/core/src/num/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ macro_rules! from_str_int_impl {
14121412
/// ```
14131413
#[inline]
14141414
fn from_str(src: &str) -> Result<$int_ty, ParseIntError> {
1415+
#[allow(clippy::from_str_radix_10)]
14151416
<$int_ty>::from_str_radix(src, 10)
14161417
}
14171418
}

library/core/src/num/nonzero.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ macro_rules! nonzero_integer {
11581158
impl FromStr for NonZero<$Int> {
11591159
type Err = ParseIntError;
11601160
fn from_str(src: &str) -> Result<Self, Self::Err> {
1161+
#[allow(clippy::from_str_radix_10)]
11611162
Self::new(<$Int>::from_str_radix(src, 10)?)
11621163
.ok_or(ParseIntError {
11631164
kind: IntErrorKind::Zero

0 commit comments

Comments
 (0)