Skip to content

Commit

Permalink
Rollup merge of rust-lang#64178 - mati865:clippy, r=scottmcm
Browse files Browse the repository at this point in the history
More Clippy fixes for alloc, core and std

Continuation of rust-lang#63805
  • Loading branch information
Centril authored Oct 23, 2019
2 parents 4a8c5b2 + bedbf3b commit 426c6cf
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ impl<T> VecDeque<T> {
}
}

return elem;
elem
}

/// Splits the `VecDeque` into two at the given index.
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl str {
}
}
}
return s;
s
}

/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ impl<T: ?Sized> Clone for Weak<T> {
}
}

return Weak { ptr: self.ptr };
Weak { ptr: self.ptr }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ impl<T: ?Sized> Pointer for *const T {
if f.alternate() {
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);

if let None = f.width {
if f.width.is_none() {
f.width = Some(((mem::size_of::<usize>() * 8) / 4) + 2);
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/libcore/num/dec2flt/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ pub fn fast_path<T: RawFloat>(integral: &[u8], fractional: &[u8], e: i64) -> Opt
/// > not a bound for the true error, but bounds the difference between the approximation z and
/// > the best possible approximation that uses p bits of significand.)
pub fn bellerophon<T: RawFloat>(f: &Big, e: i16) -> T {
let slop;
if f <= &Big::from_u64(T::MAX_SIG) {
let slop = if f <= &Big::from_u64(T::MAX_SIG) {
// The cases abs(e) < log5(2^N) are in fast_path()
slop = if e >= 0 { 0 } else { 3 };
if e >= 0 { 0 } else { 3 }
} else {
slop = if e >= 0 { 1 } else { 4 };
}
if e >= 0 { 1 } else { 4 }
};
let z = rawfp::big_to_fp(f).mul(&power_of_ten(e)).normalize();
let exp_p_n = 1 << (P - T::SIG_BITS as u32);
let lowbits: i64 = (z.f % exp_p_n) as i64;
Expand Down
5 changes: 2 additions & 3 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,8 @@ impl<T> Option<T> {
#[inline]
#[stable(feature = "option_entry", since = "1.20.0")]
pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
match *self {
None => *self = Some(f()),
_ => (),
if let None = *self {
*self = Some(f());
}

match *self {
Expand Down
12 changes: 6 additions & 6 deletions src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ unsafe extern "C" fn rust_eh_personality(version: c_int,
if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 {
match eh_action {
EHAction::None |
EHAction::Cleanup(_) => return uw::_URC_CONTINUE_UNWIND,
EHAction::Catch(_) => return uw::_URC_HANDLER_FOUND,
EHAction::Terminate => return uw::_URC_FATAL_PHASE1_ERROR,
EHAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND,
EHAction::Catch(_) => uw::_URC_HANDLER_FOUND,
EHAction::Terminate => uw::_URC_FATAL_PHASE1_ERROR,
}
} else {
match eh_action {
EHAction::None => return uw::_URC_CONTINUE_UNWIND,
EHAction::None => uw::_URC_CONTINUE_UNWIND,
EHAction::Cleanup(lpad) |
EHAction::Catch(lpad) => {
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.0, exception_object as uintptr_t);
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.1, 0);
uw::_Unwind_SetIP(context, lpad);
return uw::_URC_INSTALL_CONTEXT;
uw::_URC_INSTALL_CONTEXT
}
EHAction::Terminate => return uw::_URC_FATAL_PHASE2_ERROR,
EHAction::Terminate => uw::_URC_FATAL_PHASE2_ERROR,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpanic_unwind/seh64_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn payload() -> *mut u8 {

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

// SEH doesn't support resuming unwinds after calling a landing pad like
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pub fn update_panic_count(amt: isize) -> usize {
PANIC_COUNT.with(|c| {
let next = (c.get() as isize + amt) as usize;
c.set(next);
return next
next
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
mem::size_of_val(&v));
imp::fill_bytes(view);
}
return v
v
}

#[cfg(all(unix,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Handle {
pub fn into_raw(self) -> c::HANDLE {
let ret = self.raw();
mem::forget(self);
return ret;
ret
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn kind() -> Kind {
Some(..) => Kind::SRWLock,
};
KIND.store(ret as usize, Ordering::SeqCst);
return ret;
ret
}

pub struct ReentrantMutex { inner: UnsafeCell<MaybeUninit<c::CRITICAL_SECTION>> }
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Stdio {
let ret = io.duplicate(0, true,
c::DUPLICATE_SAME_ACCESS);
io.into_raw();
return ret
ret
}
Err(..) => Ok(Handle::new(c::INVALID_HANDLE_VALUE)),
}
Expand Down Expand Up @@ -472,9 +472,8 @@ fn make_command_line(prog: &OsStr, args: &[OsString]) -> io::Result<Vec<u16>> {
cmd.push('"' as u16);
}

let mut iter = arg.encode_wide();
let mut backslashes: usize = 0;
while let Some(x) = iter.next() {
for x in arg.encode_wide() {
if x == '\\' as u16 {
backslashes += 1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
panic!("couldn't generate random bytes: {}",
io::Error::last_os_error());
}
return v
v
}

#[cfg(target_vendor = "uwp")]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub unsafe fn create(dtor: Option<Dtor>) -> Key {
if let Some(f) = dtor {
register_dtor(key, f);
}
return key;
key
}

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sys/windows/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl SystemTime {
unsafe {
let mut t: SystemTime = mem::zeroed();
c::GetSystemTimeAsFileTime(&mut t.t);
return t
t
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ mod perf_counter {
FREQUENCY = frequency;
STATE.store(2, SeqCst);
}
return frequency;
frequency
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/libstd/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,8 @@ pub mod os {
pub unsafe fn get(&'static self, init: fn() -> T) -> Option<&'static T> {
let ptr = self.os.get() as *mut Value<T>;
if ptr as usize > 1 {
match (*ptr).inner.get() {
Some(ref value) => return Some(value),
None => {},
if let Some(ref value) = (*ptr).inner.get() {
return Some(value);
}
}
self.try_initialize(init)
Expand Down
4 changes: 2 additions & 2 deletions src/libtest/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Bencher {
F: FnMut(&mut Bencher),
{
f(self);
return self.summary;
self.summary
}
}

Expand Down Expand Up @@ -116,7 +116,7 @@ where
for _ in 0..k {
black_box(inner());
}
return ns_from_dur(start.elapsed());
ns_from_dur(start.elapsed())
}

pub fn iter<T, F>(inner: &mut F) -> stats::Summary
Expand Down
2 changes: 1 addition & 1 deletion src/libtest/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn optgroups() -> getopts::Options {
`CRITICAL_TIME` here means the limit that should not be exceeded by test.
"
);
return opts;
opts
}

fn usage(binary: &str, options: &getopts::Options) {
Expand Down
2 changes: 1 addition & 1 deletion src/libtest/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu

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

return out.write_run_finish(&st);
out.write_run_finish(&st)
}

// Calculates padding for given test description.
Expand Down

0 comments on commit 426c6cf

Please sign in to comment.