Skip to content

Commit

Permalink
Fix clippy warnings with new version of clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Mar 10, 2021
1 parent 915e977 commit 87e92b0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn get_file_mode(file: &fs::File) -> Result<Option<u32>> {
}

#[cfg(windows)]
#[allow(clippy::unnecessary_wraps)]
fn get_file_mode(_file: &fs::File) -> Result<Option<u32>> {
Ok(None)
}
Expand All @@ -61,6 +62,7 @@ fn set_file_mode(path: &Path, mode: u32) -> Result<()> {
}

#[cfg(windows)]
#[allow(clippy::unnecessary_wraps)]
fn set_file_mode(_path: &Path, _mode: u32) -> Result<()> {
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions src/cache/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl GCSCredentialProvider {
RWMode::ReadWrite => "https://www.googleapis.com/auth/devstorage.read_write",
};

Ok(encode(
encode(
&Header {
typ: "JWT",
alg: "RS256",
Expand All @@ -362,7 +362,6 @@ impl GCSCredentialProvider {
},
&sa_key.private_key,
)
.unwrap())
}

fn request_new_token(
Expand Down
9 changes: 4 additions & 5 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,24 @@ fn run_server_process() -> Result<ServerStartup> {
}

#[cfg(not(windows))]
fn redirect_stderr(f: File) -> Result<()> {
fn redirect_stderr(f: File) {
use libc::dup2;
use std::os::unix::io::IntoRawFd;
// Ignore errors here.
unsafe {
dup2(f.into_raw_fd(), 2);
}
Ok(())
}

#[cfg(windows)]
fn redirect_stderr(f: File) -> Result<()> {
fn redirect_stderr(f: File) {
use std::os::windows::io::IntoRawHandle;
use winapi::um::processenv::SetStdHandle;
use winapi::um::winbase::STD_ERROR_HANDLE;
// Ignore errors here.
unsafe {
SetStdHandle(STD_ERROR_HANDLE, f.into_raw_handle());
}
Ok(())
}

/// If `SCCACHE_ERROR_LOG` is set, redirect stderr to it.
Expand All @@ -141,7 +139,8 @@ fn redirect_error_log() -> Result<()> {
_ => return Ok(()),
};
let f = OpenOptions::new().create(true).append(true).open(name)?;
redirect_stderr(f)
redirect_stderr(f);
Ok(())
}

/// Re-execute the current executable as a background server.
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}
assert_eq!(exit_status(0), res.status);
assert_eq!(COMPILER_STDOUT, res.stdout.as_slice());
Expand Down Expand Up @@ -1554,7 +1554,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}
assert_eq!(exit_status(0), res.status);
assert_eq!(COMPILER_STDOUT, res.stdout.as_slice());
Expand Down Expand Up @@ -1662,7 +1662,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}

assert_eq!(exit_status(0), res.status);
Expand Down Expand Up @@ -1744,7 +1744,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}
assert_eq!(exit_status(0), res.status);
assert_eq!(COMPILER_STDOUT, res.stdout.as_slice());
Expand All @@ -1771,7 +1771,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}
assert_eq!(exit_status(0), res.status);
assert_eq!(COMPILER_STDOUT, res.stdout.as_slice());
Expand Down Expand Up @@ -1932,7 +1932,7 @@ LLVM version: 6.0",
// wait on cache write future so we don't race with it!
f.wait().unwrap();
}
_ => assert!(false, "Unexpected compile result: {:?}", cached),
_ => panic!("Unexpected compile result: {:?}", cached),
}
assert_eq!(exit_status(0), res.status);
assert_eq!(COMPILER_STDOUT, res.stdout.as_slice());
Expand Down
1 change: 1 addition & 0 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,7 @@ c:/foo/bar.rs:
.key
}

#[allow(clippy::unnecessary_wraps)]
fn nothing(_path: &Path) -> Result<()> {
Ok(())
}
Expand Down

0 comments on commit 87e92b0

Please sign in to comment.