Skip to content

Commit 1667950

Browse files
committed
Remove explicit returns where unnecessary
1 parent 579adf8 commit 1667950

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/libcore/alloc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Layout {
217217

218218
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1)
219219
& !align.wrapping_sub(1);
220-
return len_rounded_up.wrapping_sub(len);
220+
len_rounded_up.wrapping_sub(len)
221221
}
222222

223223
/// Creates a layout describing the record for `n` instances of
@@ -971,9 +971,9 @@ pub unsafe trait Alloc {
971971
// _l <= layout.size() [guaranteed by usable_size()]
972972
// layout.size() <= new_layout.size() [required by this method]
973973
if new_size <= u {
974-
return Ok(());
974+
Ok(())
975975
} else {
976-
return Err(CannotReallocInPlace);
976+
Err(CannotReallocInPlace)
977977
}
978978
}
979979

@@ -1026,9 +1026,9 @@ pub unsafe trait Alloc {
10261026
// layout.size() <= _u [guaranteed by usable_size()]
10271027
// new_layout.size() <= layout.size() [required by this method]
10281028
if l <= new_size {
1029-
return Ok(());
1029+
Ok(())
10301030
} else {
1031-
return Err(CannotReallocInPlace);
1031+
Err(CannotReallocInPlace)
10321032
}
10331033
}
10341034

src/libcore/char/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ impl Iterator for EscapeDefault {
312312
None
313313
}
314314
},
315-
EscapeDefaultState::Done => return None,
316-
EscapeDefaultState::Unicode(ref mut i) => return i.nth(n),
315+
EscapeDefaultState::Done => None,
316+
EscapeDefaultState::Unicode(ref mut i) => i.nth(n),
317317
}
318318
}
319319

src/libcore/ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
22882288

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

23772377
// Cannot be aligned at all.
2378-
return usize::max_value();
2378+
usize::max_value()
23792379
}
23802380

23812381

src/libcore/slice/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ impl<T> [T] {
17271727
ctz_b = ::intrinsics::cttz_nonzero(b);
17281728
}
17291729
}
1730-
return a << k;
1730+
a << k
17311731
}
17321732
let gcd: usize = gcd(::mem::size_of::<T>(), ::mem::size_of::<U>());
17331733
let ts: usize = ::mem::size_of::<U>() / gcd;
@@ -1737,7 +1737,7 @@ impl<T> [T] {
17371737
let us_len = self.len() / ts * us;
17381738
// And how many `T`s will be in the trailing slice!
17391739
let ts_len = self.len() % ts;
1740-
return (us_len, ts_len);
1740+
(us_len, ts_len)
17411741
}
17421742

17431743
/// Transmute the slice to a slice of another type, ensuring aligment of the types is
@@ -1782,13 +1782,13 @@ impl<T> [T] {
17821782
let ptr = self.as_ptr();
17831783
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
17841784
if offset > self.len() {
1785-
return (self, &[], &[]);
1785+
(self, &[], &[])
17861786
} else {
17871787
let (left, rest) = self.split_at(offset);
17881788
let (us_len, ts_len) = rest.align_to_offsets::<U>();
1789-
return (left,
1790-
from_raw_parts(rest.as_ptr() as *const U, us_len),
1791-
from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
1789+
(left,
1790+
from_raw_parts(rest.as_ptr() as *const U, us_len),
1791+
from_raw_parts(rest.as_ptr().offset((rest.len() - ts_len) as isize), ts_len))
17921792
}
17931793
}
17941794

@@ -1834,14 +1834,14 @@ impl<T> [T] {
18341834
let ptr = self.as_ptr();
18351835
let offset = ::ptr::align_offset(ptr, ::mem::align_of::<U>());
18361836
if offset > self.len() {
1837-
return (self, &mut [], &mut []);
1837+
(self, &mut [], &mut [])
18381838
} else {
18391839
let (left, rest) = self.split_at_mut(offset);
18401840
let (us_len, ts_len) = rest.align_to_offsets::<U>();
18411841
let mut_ptr = rest.as_mut_ptr();
1842-
return (left,
1843-
from_raw_parts_mut(mut_ptr as *mut U, us_len),
1844-
from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
1842+
(left,
1843+
from_raw_parts_mut(mut_ptr as *mut U, us_len),
1844+
from_raw_parts_mut(mut_ptr.offset((rest.len() - ts_len) as isize), ts_len))
18451845
}
18461846
}
18471847
}

src/libcore/str/lossy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
146146
broken: &[],
147147
};
148148
self.source = &[];
149-
return Some(r);
149+
Some(r)
150150
}
151151
}
152152

src/libcore/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [
15671567
#[unstable(feature = "str_internals", issue = "0")]
15681568
#[inline]
15691569
pub fn utf8_char_width(b: u8) -> usize {
1570-
return UTF8_CHAR_WIDTH[b as usize] as usize;
1570+
UTF8_CHAR_WIDTH[b as usize] as usize
15711571
}
15721572

15731573
/// Mask of the value bits of a continuation byte.

src/tools/remote-test-server/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
267267
t!(io::copy(&mut io.take(amt),
268268
&mut t!(File::create(&dst))));
269269
t!(fs::set_permissions(&dst, Permissions::from_mode(0o755)));
270-
return dst
270+
dst
271271
}
272272

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

0 commit comments

Comments
 (0)