]> git.lizzy.rs Git - rust.git/commitdiff
Apply clippy suggestions
authorClemens Wasser <clemens.wasser@gmail.com>
Sat, 9 Oct 2021 16:51:30 +0000 (18:51 +0200)
committerClemens Wasser <clemens.wasser@gmail.com>
Sat, 9 Oct 2021 16:56:01 +0000 (18:56 +0200)
library/std/src/io/buffered/bufreader.rs
library/std/src/sys/windows/fs.rs
library/std/src/sys/windows/stack_overflow.rs
library/std/src/sys_common/backtrace.rs

index 243207a6065449cd4467f6f4fe88f674096c7745..2864e94f60f2c82ca542ac8fa890701bc340a0a9 100644 (file)
@@ -242,14 +242,13 @@ pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> {
                 self.pos = new_pos as usize;
                 return Ok(());
             }
-        } else {
-            if let Some(new_pos) = pos.checked_add(offset as u64) {
-                if new_pos <= self.cap as u64 {
-                    self.pos = new_pos as usize;
-                    return Ok(());
-                }
+        } else if let Some(new_pos) = pos.checked_add(offset as u64) {
+            if new_pos <= self.cap as u64 {
+                self.pos = new_pos as usize;
+                return Ok(());
             }
         }
+
         self.seek(SeekFrom::Current(offset)).map(drop)
     }
 }
index cc137771bb8d41bf79c4dd6efa7717e330901b1d..ad550a823ae90e2596c26614d19c2911bbd953ad 100644 (file)
@@ -558,7 +558,7 @@ fn into_inner(self) -> Handle {
 
 impl FromInner<Handle> for File {
     fn from_inner(handle: Handle) -> File {
-        File { handle: handle }
+        File { handle }
     }
 }
 
@@ -672,7 +672,7 @@ pub fn set_readonly(&mut self, readonly: bool) {
 
 impl FileType {
     fn new(attrs: c::DWORD, reparse_tag: c::DWORD) -> FileType {
-        FileType { attributes: attrs, reparse_tag: reparse_tag }
+        FileType { attributes: attrs, reparse_tag }
     }
     pub fn is_dir(&self) -> bool {
         !self.is_symlink() && self.is_directory()
index 755dc0a6c8b47045a5ce45149d0f1762a454a3bc..18a2a36ad2548e25c0bab340235d2fd41ac81646 100644 (file)
@@ -9,10 +9,10 @@ impl Handler {
     pub unsafe fn new() -> Handler {
         // This API isn't available on XP, so don't panic in that case and just
         // pray it works out ok.
-        if c::SetThreadStackGuarantee(&mut 0x5000) == 0 {
-            if c::GetLastError() as u32 != c::ERROR_CALL_NOT_IMPLEMENTED as u32 {
-                panic!("failed to reserve stack space for exception handling");
-            }
+        if c::SetThreadStackGuarantee(&mut 0x5000) == 0
+            && c::GetLastError() as u32 != c::ERROR_CALL_NOT_IMPLEMENTED as u32
+        {
+            panic!("failed to reserve stack space for exception handling");
         }
         Handler
     }
index e6a099f0e81a0ad141b1f2950e34ed78c8987db4..d5e8f12414ff2d688007a157925030225d107518 100644 (file)
@@ -93,10 +93,8 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
         if stop {
             return false;
         }
-        if !hit {
-            if start {
-                res = bt_fmt.frame().print_raw(frame.ip(), None, None, None);
-            }
+        if !hit && start {
+            res = bt_fmt.frame().print_raw(frame.ip(), None, None, None);
         }
 
         idx += 1;