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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+4-5
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

+2-3
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

+6-6
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

+1-1
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

+1-1
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

+1-1
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,

src/libstd/sys/windows/handle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Handle {
4646
pub fn into_raw(self) -> c::HANDLE {
4747
let ret = self.raw();
4848
mem::forget(self);
49-
return ret;
49+
ret
5050
}
5151
}
5252

src/libstd/sys/windows/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn kind() -> Kind {
144144
Some(..) => Kind::SRWLock,
145145
};
146146
KIND.store(ret as usize, Ordering::SeqCst);
147-
return ret;
147+
ret
148148
}
149149

150150
pub struct ReentrantMutex { inner: UnsafeCell<MaybeUninit<c::CRITICAL_SECTION>> }

src/libstd/sys/windows/process.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl Stdio {
257257
let ret = io.duplicate(0, true,
258258
c::DUPLICATE_SAME_ACCESS);
259259
io.into_raw();
260-
return ret
260+
ret
261261
}
262262
Err(..) => Ok(Handle::new(c::INVALID_HANDLE_VALUE)),
263263
}
@@ -472,9 +472,8 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> io::Result<Vec<u16>> {
472472
cmd.push('"' as u16);
473473
}
474474

475-
let mut iter = arg.encode_wide();
476475
let mut backslashes: usize = 0;
477-
while let Some(x) = iter.next() {
476+
for x in arg.encode_wide() {
478477
if x == '\\' as u16 {
479478
backslashes += 1;
480479
} else {

src/libstd/sys/windows/rand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1313
panic!("couldn't generate random bytes: {}",
1414
io::Error::last_os_error());
1515
}
16-
return v
16+
v
1717
}
1818

1919
#[cfg(target_vendor = "uwp")]

src/libstd/sys/windows/thread_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub unsafe fn create(dtor: Option<Dtor>) -> Key {
5252
if let Some(f) = dtor {
5353
register_dtor(key, f);
5454
}
55-
return key;
55+
key
5656
}
5757

5858
#[inline]

src/libstd/sys/windows/time.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl SystemTime {
8080
unsafe {
8181
let mut t: SystemTime = mem::zeroed();
8282
c::GetSystemTimeAsFileTime(&mut t.t);
83-
return t
83+
t
8484
}
8585
}
8686

@@ -228,7 +228,7 @@ mod perf_counter {
228228
FREQUENCY = frequency;
229229
STATE.store(2, SeqCst);
230230
}
231-
return frequency;
231+
frequency
232232
}
233233
}
234234

src/libstd/thread/local.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,8 @@ pub mod os {
509509
pub unsafe fn get(&'static self, init: fn() -> T) -> Option<&'static T> {
510510
let ptr = self.os.get() as *mut Value<T>;
511511
if ptr as usize > 1 {
512-
match (*ptr).inner.get() {
513-
Some(ref value) => return Some(value),
514-
None => {},
512+
if let Some(ref value) = (*ptr).inner.get() {
513+
return Some(value);
515514
}
516515
}
517516
self.try_initialize(init)

src/libtest/bench.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Bencher {
4848
F: FnMut(&mut Bencher),
4949
{
5050
f(self);
51-
return self.summary;
51+
self.summary
5252
}
5353
}
5454

@@ -116,7 +116,7 @@ where
116116
for _ in 0..k {
117117
black_box(inner());
118118
}
119-
return ns_from_dur(start.elapsed());
119+
ns_from_dur(start.elapsed())
120120
}
121121

122122
pub fn iter<T, F>(inner: &mut F) -> stats::Summary

src/libtest/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn optgroups() -> getopts::Options {
149149
`CRITICAL_TIME` here means the limit that should not be exceeded by test.
150150
"
151151
);
152-
return opts;
152+
opts
153153
}
154154

155155
fn usage(binary: &str, options: &getopts::Options) {

src/libtest/console.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
296296

297297
assert!(st.current_test_count() == st.total);
298298

299-
return out.write_run_finish(&st);
299+
out.write_run_finish(&st)
300300
}
301301

302302
// Calculates padding for given test description.

0 commit comments

Comments
 (0)