Remove needless returns detected by clippy in libraries · qinheping/verify-rust-std@f9a9560 (original) (raw)

9 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
73 73 fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
74 74 let remaining = self.i1.advance_by(n);
75 75 match remaining {
76 -Ok(()) => return Ok(()),
76 +Ok(()) => Ok(()),
77 77 Err(n) => {
78 78 mem::swap(&mut self.i1, &mut self.i2);
79 79 self.i1.advance_by(n.get())
@@ -144,7 +144,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
144 144
145 145 fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
146 146 match self.i2.advance_back_by(n) {
147 -Ok(()) => return Ok(()),
147 +Ok(()) => Ok(()),
148 148 Err(n) => {
149 149 mem::swap(&mut self.i1, &mut self.i2);
150 150 self.i2.advance_back_by(n.get())
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
64 64
65 65 fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
66 66 match self.i1.advance_by(n) {
67 -Ok(()) => return Ok(()),
67 +Ok(()) => Ok(()),
68 68 Err(remaining) => {
69 69 mem::swap(&mut self.i1, &mut self.i2);
70 70 self.i1.advance_by(remaining.get())
@@ -135,7 +135,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
135 135
136 136 fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
137 137 match self.i2.advance_back_by(n) {
138 -Ok(()) => return Ok(()),
138 +Ok(()) => Ok(()),
139 139 Err(remaining) => {
140 140 mem::swap(&mut self.i1, &mut self.i2);
141 141 self.i2.advance_back_by(remaining.get())
Original file line number Diff line number Diff line change
@@ -208,7 +208,7 @@ const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool {
208 208
209 209 // type layouts don't guarantee a fit, so do a runtime check to see if
210 210 // the allocations happen to match
211 -return src_cap > 0 && src_cap * mem::size_of::<SRC>() != dst_cap * mem::size_of::<DEST>();
211 + src_cap > 0 && src_cap * mem::size_of::<SRC>() != dst_cap * mem::size_of::<DEST>()
212 212 }
213 213
214 214 /// This provides a shorthand for the source type since local type aliases aren't a thing.
Original file line number Diff line number Diff line change
@@ -288,11 +288,11 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> {
288 288
289 289 // Safety: `len` is larger than the array size. Copy a fixed amount here to fully initialize
290 290 // the array.
291 -return unsafe {
291 +unsafe {
292 292 ptr::copy_nonoverlapping(self.ptr.as_ptr(), raw_ary.as_mut_ptr() as *mut T, N);
293 293 self.ptr = self.ptr.add(N);
294 294 Ok(raw_ary.transpose().assume_init())
295 -};
295 +}
296 296 }
297 297
298 298 fn fold<B, F>(mut self, mut accum: B, mut f: F) -> B
Original file line number Diff line number Diff line change
@@ -187,14 +187,14 @@ impl<Dyn: ?Sized> DynMetadata {
187 187 // Consider a reference like `&(i32, dyn Send)`: the vtable will only store the size of the
188 188 // `Send` part!
189 189 // SAFETY: DynMetadata always contains a valid vtable pointer
190 -return unsafe { crate::intrinsics::vtable_size(self.vtable_ptr() as *const ()) };
190 +unsafe { crate::intrinsics::vtable_size(self.vtable_ptr() as *const ()) }
191 191 }
192 192
193 193 /// Returns the alignment of the type associated with this vtable.
194 194 #[inline]
195 195 pub fn align_of(self) -> usize {
196 196 // SAFETY: DynMetadata always contains a valid vtable pointer
197 -return unsafe { crate::intrinsics::vtable_align(self.vtable_ptr() as *const ()) };
197 +unsafe { crate::intrinsics::vtable_align(self.vtable_ptr() as *const ()) }
198 198 }
199 199
200 200 /// Returns the size and alignment together as a `Layout`
Original file line number Diff line number Diff line change
@@ -1814,7 +1814,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option {
1814 1814 }
1815 1815 mask &= !(1 << trailing);
1816 1816 }
1817 -return false;
1817 +false
1818 1818 };
1819 1819
1820 1820 let test_chunk = |idx
@@ -1830,7 +1830,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option {
1830 1830 let both = eq_first.bitand(eq_last);
1831 1831 let mask = both.to_bitmask() as u16;
1832 1832
1833 -return mask;
1833 + mask
1834 1834 };
1835 1835
1836 1836 let mut i = 0;
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ pub(crate) struct PidFd(FileDesc);
13 13
14 14 impl PidFd {
15 15 pub fn kill(&self) -> io::Result<()> {
16 -return cvt(unsafe {
16 +cvt(unsafe {
17 17 libc::syscall(
18 18 libc::SYS_pidfd_send_signal,
19 19 self.0.as_raw_fd(),
@@ -22,15 +22,15 @@ impl PidFd {
22 22 0,
23 23 )
24 24 })
25 -.map(drop);
25 +.map(drop)
26 26 }
27 27
28 28 pub fn wait(&self) -> io::Result<ExitStatus> {
29 29 let mut siginfo: libc::siginfo_t = unsafe { crate::mem::zeroed() };
30 30 cvt(unsafe {
31 31 libc::waitid(libc::P_PIDFD, self.0.as_raw_fd() as u32, &mut siginfo, libc::WEXITED)
32 32 })?;
33 -return Ok(ExitStatus::from_waitid_siginfo(siginfo));
33 +Ok(ExitStatus::from_waitid_siginfo(siginfo))
34 34 }
35 35
36 36 pub fn try_wait(&self) -> io::Result<Option<ExitStatus>> {
@@ -45,9 +45,10 @@ impl PidFd {
45 45 )
46 46 })?;
47 47 if unsafe { siginfo.si_pid() } == 0 {
48 -return Ok(None);
48 +Ok(None)
49 +} else {
50 +Ok(Some(ExitStatus::from_waitid_siginfo(siginfo)))
49 51 }
50 -return Ok(Some(ExitStatus::from_waitid_siginfo(siginfo)));
51 52 }
52 53 }
53 54
Original file line number Diff line number Diff line change
@@ -265,7 +265,7 @@ impl OpenOptions {
265 265 pub fn new() -> OpenOptions {
266 266 let mut base = OpenOptions::default();
267 267 base.dirflags = wasi::LOOKUPFLAGS_SYMLINK_FOLLOW;
268 -return base;
268 + base
269 269 }
270 270
271 271 pub fn read(&mut self, read: bool) {
@@ -382,7 +382,7 @@ impl OpenOptions {
382 382 base |= wasi::RIGHTS_PATH_UNLINK_FILE;
383 383 base |= wasi::RIGHTS_POLL_FD_READWRITE;
384 384
385 -return base;
385 + base
386 386 }
387 387
388 388 fn rights_inheriting(&self) -> wasi::Rights {
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
115 115 let len = mem::size_of_val(&ret);
116 116 wasi::random_get(base, len).expect("random_get failure");
117 117 }
118 -return ret;
118 + ret
119 119 }
120 120
121 121 #[inline]