Skip to content

Commit 73b6429

Browse files
committed
Fix new clippy::precedence errors
`clippy::precedence` now applies to bitwise `&` and `|`. Update with all of its suggestions, including a separate elided lifetime suggestion.
1 parent ef00132 commit 73b6429

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

examples/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ fn run() {
640640
fn something_with_a_dtor(f: &dyn Fn()) {
641641
struct A<'a>(&'a (dyn Fn() + 'a));
642642

643-
impl<'a> Drop for A<'a> {
643+
impl Drop for A<'_> {
644644
fn drop(&mut self) {
645645
(self.0)();
646646
}

src/float/add.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ where
143143

144144
// If the addition carried up, we need to right-shift the result and
145145
// adjust the exponent:
146-
if a_significand & implicit_bit << 4 != MinInt::ZERO {
146+
if a_significand & (implicit_bit << 4) != MinInt::ZERO {
147147
let sticky = F::Int::from_bool(a_significand & one != MinInt::ZERO);
148-
a_significand = a_significand >> 1 | sticky;
148+
a_significand = (a_significand >> 1) | sticky;
149149
a_exponent += 1;
150150
}
151151
}
@@ -161,7 +161,7 @@ where
161161
let shift = (1 - a_exponent).cast();
162162
let sticky =
163163
F::Int::from_bool((a_significand << bits.wrapping_sub(shift).cast()) != MinInt::ZERO);
164-
a_significand = a_significand >> shift.cast() | sticky;
164+
a_significand = (a_significand >> shift.cast()) | sticky;
165165
a_exponent = 0;
166166
}
167167

@@ -170,7 +170,7 @@ where
170170
let round_guard_sticky: i32 = a_significand_i32 & 0x7;
171171

172172
// Shift the significand into place, and mask off the implicit bit.
173-
let mut result = a_significand >> 3 & significand_mask;
173+
let mut result = (a_significand >> 3) & significand_mask;
174174

175175
// Insert the exponent and sign.
176176
result |= a_exponent.cast() << significand_bits;

src/float/conv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod int_to_float {
4242
fn m_adj<F: Float>(m_base: F::Int, dropped_bits: F::Int) -> F::Int {
4343
// Branchlessly extract a `1` if rounding up should happen, 0 otherwise
4444
// This accounts for rounding to even.
45-
let adj = (dropped_bits - (dropped_bits >> (F::BITS - 1) & !m_base)) >> (F::BITS - 1);
45+
let adj = (dropped_bits - ((dropped_bits >> (F::BITS - 1)) & !m_base)) >> (F::BITS - 1);
4646

4747
// Add one when we need to round up. Break ties to even.
4848
m_base + adj
@@ -129,7 +129,7 @@ mod int_to_float {
129129
let m_base: u32 = (i_m >> shift_f_lt_i::<u64, f32>()) as u32;
130130
// The entire lower half of `i` will be truncated (masked portion), plus the
131131
// next `EXP_BITS` bits.
132-
let adj = (i_m >> f32::EXP_BITS | i_m & 0xFFFF) as u32;
132+
let adj = ((i_m >> f32::EXP_BITS) | i_m & 0xFFFF) as u32;
133133
let m = m_adj::<f32>(m_base, adj);
134134
let e = if i == 0 { 0 } else { exp::<u64, f32>(n) - 1 };
135135
repr::<f32>(e, m)
@@ -187,7 +187,7 @@ mod int_to_float {
187187
let m_base: u64 = (i_m >> shift_f_lt_i::<u128, f64>()) as u64;
188188
// The entire lower half of `i` will be truncated (masked portion), plus the
189189
// next `EXP_BITS` bits.
190-
let adj = (i_m >> f64::EXP_BITS | i_m & 0xFFFF_FFFF) as u64;
190+
let adj = ((i_m >> f64::EXP_BITS) | i_m & 0xFFFF_FFFF) as u64;
191191
let m = m_adj::<f64>(m_base, adj);
192192
let e = if i == 0 { 0 } else { exp::<u128, f64>(n) - 1 };
193193
repr::<f64>(e, m)
@@ -377,7 +377,7 @@ where
377377
};
378378

379379
// Set the implicit 1-bit.
380-
let m: I::UnsignedInt = I::UnsignedInt::ONE << (I::BITS - 1) | m_base;
380+
let m: I::UnsignedInt = (I::UnsignedInt::ONE << (I::BITS - 1)) | m_base;
381381

382382
// Shift based on the exponent and bias.
383383
let s: u32 = (foobar) - u32::cast_from(fbits >> F::SIG_BITS);

src/float/div.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ where
261261
let c_hw = c_hw::<F>();
262262

263263
// Check that the top bit is set, i.e. value is within `[1, 2)`.
264-
debug_assert!(b_uq1_hw & one_hw << (HalfRep::<F>::BITS - 1) > zero_hw);
264+
debug_assert!(b_uq1_hw & (one_hw << (HalfRep::<F>::BITS - 1)) > zero_hw);
265265

266266
// b >= 1, thus an upper bound for 3/4 + 1/sqrt(2) - b/2 is about 0.9572,
267267
// so x0 fits to UQ0.HW without wrapping.

src/float/mul.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ where
154154
// not all zero so that the result is correctly rounded below.
155155
let sticky = product_low << (bits - shift) != zero;
156156
product_low =
157-
product_high << (bits - shift) | product_low >> shift | (sticky as u32).cast();
157+
(product_high << (bits - shift)) | (product_low >> shift) | (sticky as u32).cast();
158158
product_high >>= shift;
159159
} else {
160160
// Result is normal before rounding; insert the exponent.

src/float/trunc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
} else {
9797
src_zero
9898
};
99-
let denormalized_significand: F::Int = significand >> shift | sticky;
99+
let denormalized_significand: F::Int = (significand >> shift) | sticky;
100100
abs_result = (denormalized_significand >> (F::SIG_BITS - R::SIG_BITS)).cast();
101101
let round_bits = denormalized_significand & round_mask;
102102
// Round to nearest

src/mem/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ where
111111
let mut x = T::from(c);
112112
let mut i = 1;
113113
while i < mem::size_of::<T>() {
114-
x = x << 8 | T::from(c);
114+
x = (x << 8) | T::from(c);
115115
i += 1;
116116
}
117117

0 commit comments

Comments
 (0)