Skip to content

Commit

Permalink
Remove explicit returns where unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Aug 4, 2018
1 parent 579adf8 commit 1667950
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl Layout {

let len_rounded_up = len.wrapping_add(align).wrapping_sub(1)
& !align.wrapping_sub(1);
return len_rounded_up.wrapping_sub(len);
len_rounded_up.wrapping_sub(len)
}

/// Creates a layout describing the record for `n` instances of
Expand Down Expand Up @@ -971,9 +971,9 @@ pub unsafe trait Alloc {
// _l <= layout.size() [guaranteed by usable_size()]
// layout.size() <= new_layout.size() [required by this method]
if new_size <= u {
return Ok(());
Ok(())
} else {
return Err(CannotReallocInPlace);
Err(CannotReallocInPlace)
}
}

Expand Down Expand Up @@ -1026,9 +1026,9 @@ pub unsafe trait Alloc {
// layout.size() <= _u [guaranteed by usable_size()]
// new_layout.size() <= layout.size() [required by this method]
if l <= new_size {
return Ok(());
Ok(())
} else {
return Err(CannotReallocInPlace);
Err(CannotReallocInPlace)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ impl Iterator for EscapeDefault {
None
}
},
EscapeDefaultState::Done => return None,
EscapeDefaultState::Unicode(ref mut i) => return i.nth(n),
EscapeDefaultState::Done => None,
EscapeDefaultState::Unicode(ref mut i) => i.nth(n),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {

let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1];
if m <= INV_TABLE_MOD {
return table_inverse & (m - 1);
table_inverse & (m - 1)
} else {
// We iterate "up" using the following formula:
//
Expand Down Expand Up @@ -2375,7 +2375,7 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
}

// Cannot be aligned at all.
return usize::max_value();
usize::max_value()
}


Expand Down
20 changes: 10 additions & 10 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ impl<T> [T] {
ctz_b = ::intrinsics::cttz_nonzero(b);
}
}
return a << k;
a << k
}
let gcd: usize = gcd(::mem::size_of::<T>(), ::mem::size_of::<U>());
let ts: usize = ::mem::size_of::<U>() / gcd;
Expand All @@ -1737,7 +1737,7 @@ impl<T> [T] {
let us_len = self.len() / ts * us;
// And how many `T`s will be in the trailing slice!
let ts_len = self.len() % ts;
return (us_len, ts_len);
(us_len, ts_len)
}

/// Transmute the slice to a slice of another type, ensuring aligment of the types is
Expand Down Expand Up @@ -1782,13 +1782,13 @@ impl<T> [T] {
let ptr = self.as_ptr();
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
if offset > self.len() {
return (self, &[], &[]);
(self, &[], &[])
} else {
let (left, rest) = self.split_at(offset);
let (us_len, ts_len) = rest.align_to_offsets::<U>();
return (left,
from_raw_parts(rest.as_ptr() as *const U, us_len),
from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
(left,
from_raw_parts(rest.as_ptr() as *const U, us_len),
from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
}
}

Expand Down Expand Up @@ -1834,14 +1834,14 @@ impl<T> [T] {
let ptr = self.as_ptr();
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
if offset > self.len() {
return (self, &mut [], &mut []);
(self, &mut [], &mut [])
} else {
let (left, rest) = self.split_at_mut(offset);
let (us_len, ts_len) = rest.align_to_offsets::<U>();
let mut_ptr = rest.as_mut_ptr();
return (left,
from_raw_parts_mut(mut_ptr as *mut U, us_len),
from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
(left,
from_raw_parts_mut(mut_ptr as *mut U, us_len),
from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/lossy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
broken: &[],
};
self.source = &[];
return Some(r);
Some(r)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
#[unstable(feature = "str_internals", issue = "0")]
#[inline]
pub fn utf8_char_width(b: u8) -> usize {
return UTF8_CHAR_WIDTH[b as usize] as usize;
UTF8_CHAR_WIDTH[b as usize] as usize
}

/// Mask of the value bits of a continuation byte.
Expand Down
2 changes: 1 addition & 1 deletion src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
t!(io::copy(&mut io.take(amt),
&mut t!(File::create(&dst))));
t!(fs::set_permissions(&dst, Permissions::from_mode(0o755)));
return dst
dst
}

fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {
Expand Down

0 comments on commit 1667950

Please sign in to comment.