Skip to content

Commit 426c6cf

Browse files
authored
Rollup merge of rust-lang#64178 - mati865:clippy, r=scottmcm
More Clippy fixes for alloc, core and std Continuation of rust-lang#63805
2 parents 4a8c5b2 + bedbf3b commit 426c6cf

File tree

20 files changed

+33
-37
lines changed

20 files changed

+33
-37
lines changed

src/liballoc/collections/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ impl<T> VecDeque<T> {
18171817
}
18181818
}
18191819

1820-
return elem;
1820+
elem
18211821
}
18221822

18231823
/// Splits the `VecDeque` into two at the given index.

src/liballoc/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl str {
456456
}
457457
}
458458
}
459-
return s;
459+
s
460460
}
461461

462462
/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.

src/liballoc/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ impl<T: ?Sized> Clone for Weak<T> {
16381638
}
16391639
}
16401640

1641-
return Weak { ptr: self.ptr };
1641+
Weak { ptr: self.ptr }
16421642
}
16431643
}
16441644

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ impl<T: ?Sized> Pointer for *const T {
20252025
if f.alternate() {
20262026
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);
20272027

2028-
if let None = f.width {
2028+
if f.width.is_none() {
20292029
f.width = Some(((mem::size_of::<usize>() * 8) / 4) + 2);
20302030
}
20312031
}

src/libcore/num/dec2flt/algorithm.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,12 @@ pub fn fast_path<T: RawFloat>(integral: &[u8], fractional: &[u8], e: i64) -> Opt
143143
/// > not a bound for the true error, but bounds the difference between the approximation z and
144144
/// > the best possible approximation that uses p bits of significand.)
145145
pub fn bellerophon<T: RawFloat>(f: &Big, e: i16) -> T {
146-
let slop;
147-
if f <= &Big::from_u64(T::MAX_SIG) {
146+
let slop = if f <= &Big::from_u64(T::MAX_SIG) {
148147
// The cases abs(e) < log5(2^N) are in fast_path()
149-
slop = if e >= 0 { 0 } else { 3 };
148+
if e >= 0 { 0 } else { 3 }
150149
} else {
151-
slop = if e >= 0 { 1 } else { 4 };
152-
}
150+
if e >= 0 { 1 } else { 4 }
151+
};
153152
let z = rawfp::big_to_fp(f).mul(&power_of_ten(e)).normalize();
154153
let exp_p_n = 1 << (P - T::SIG_BITS as u32);
155154
let lowbits: i64 = (z.f % exp_p_n) as i64;

src/libcore/option.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,8 @@ impl<T> Option<T> {
837837
#[inline]
838838
#[stable(feature = "option_entry", since = "1.20.0")]
839839
pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
840-
match *self {
841-
None => *self = Some(f()),
842-
_ => (),
840+
if let None = *self {
841+
*self = Some(f());
843842
}
844843

845844
match *self {

src/libpanic_unwind/gcc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,21 @@ unsafe extern "C" fn rust_eh_personality(version: c_int,
156156
if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 {
157157
match eh_action {
158158
EHAction::None |
159-
EHAction::Cleanup(_) => return uw::_URC_CONTINUE_UNWIND,
160-
EHAction::Catch(_) => return uw::_URC_HANDLER_FOUND,
161-
EHAction::Terminate => return uw::_URC_FATAL_PHASE1_ERROR,
159+
EHAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND,
160+
EHAction::Catch(_) => uw::_URC_HANDLER_FOUND,
161+
EHAction::Terminate => uw::_URC_FATAL_PHASE1_ERROR,
162162
}
163163
} else {
164164
match eh_action {
165-
EHAction::None => return uw::_URC_CONTINUE_UNWIND,
165+
EHAction::None => uw::_URC_CONTINUE_UNWIND,
166166
EHAction::Cleanup(lpad) |
167167
EHAction::Catch(lpad) => {
168168
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.0, exception_object as uintptr_t);
169169
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.1, 0);
170170
uw::_Unwind_SetIP(context, lpad);
171-
return uw::_URC_INSTALL_CONTEXT;
171+
uw::_URC_INSTALL_CONTEXT
172172
}
173-
EHAction::Terminate => return uw::_URC_FATAL_PHASE2_ERROR,
173+
EHAction::Terminate => uw::_URC_FATAL_PHASE2_ERROR,
174174
}
175175
}
176176
}

src/libpanic_unwind/seh64_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn payload() -> *mut u8 {
4646

4747
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
4848
let panic_ctx = Box::from_raw(ptr as *mut PanicData);
49-
return panic_ctx.data;
49+
panic_ctx.data
5050
}
5151

5252
// SEH doesn't support resuming unwinds after calling a landing pad like

src/libstd/panicking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn update_panic_count(amt: isize) -> usize {
217217
PANIC_COUNT.with(|c| {
218218
let next = (c.get() as isize + amt) as usize;
219219
c.set(next);
220-
return next
220+
next
221221
})
222222
}
223223

src/libstd/sys/unix/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
88
mem::size_of_val(&v));
99
imp::fill_bytes(view);
1010
}
11-
return v
11+
v
1212
}
1313

1414
#[cfg(all(unix,

0 commit comments

Comments
 (0)