Skip to content

Commit

Permalink
Some clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Aug 29, 2020
1 parent b9bdabb commit df2f7d7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ impl Client {
/// any number of times.
pub unsafe fn from_env() -> Option<Client> {
let var = match env::var("CARGO_MAKEFLAGS")
.or(env::var("MAKEFLAGS"))
.or(env::var("MFLAGS"))
.or_else(|_| env::var("MAKEFLAGS"))
.or_else(|_| env::var("MFLAGS"))
{
Ok(s) => s,
Err(_) => return None,
Expand Down Expand Up @@ -268,7 +268,7 @@ impl Client {
let data = self.inner.acquire()?;
Ok(Acquired {
client: self.inner.clone(),
data: data,
data,
disabled: false,
})
}
Expand Down
6 changes: 2 additions & 4 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Client {
// I don't think the character written here matters, but I could be
// wrong!
for _ in 0..limit {
(&client.write).write(&[b'|'])?;
(&client.write).write_all(&[b'|'])?;
}
Ok(client)
}
Expand Down Expand Up @@ -299,9 +299,7 @@ impl Helper {
}

fn is_valid_fd(fd: c_int) -> bool {
unsafe {
return libc::fcntl(fd, libc::F_GETFD) != -1;
}
unsafe { libc::fcntl(fd, libc::F_GETFD) != -1 }
}

fn set_cloexec(fd: c_int, set: bool) -> io::Result<()> {
Expand Down
8 changes: 4 additions & 4 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TESTS: &[Test] = &[
Test {
name: "no j args",
make_args: &[],
rule: &|me| format!("{}", me),
rule: &|me| me.to_string(),
f: &|| {
assert!(unsafe { Client::from_env().is_none() });
},
Expand Down Expand Up @@ -124,7 +124,7 @@ fn main() {

let me = t!(env::current_exe());
let me = me.to_str().unwrap();
let filter = env::args().skip(1).next();
let filter = env::args().nth(1);

let mut core = t!(Core::new());

Expand All @@ -146,7 +146,7 @@ all:
(test.rule)(me)
);
t!(t!(File::create(td.path().join("Makefile"))).write_all(makefile.as_bytes()));
let prog = env::var("MAKE").unwrap_or("make".to_string());
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
let mut cmd = Command::new(prog);
cmd.args(test.make_args);
cmd.current_dir(td.path());
Expand Down Expand Up @@ -174,7 +174,7 @@ all:
Ok(())
})));

if failures.len() == 0 {
if failures.is_empty() {
println!("\ntest result: ok\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn helper_smoke() {
drop(client.clone().into_helper_thread(|_| ()).unwrap());
drop(client.clone().into_helper_thread(|_| ()).unwrap());
drop(client.clone().into_helper_thread(|_| ()).unwrap());
drop(client.clone().into_helper_thread(|_| ()).unwrap());
drop(client.into_helper_thread(|_| ()).unwrap());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/make-as-a-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() {
let c = t!(Client::new(1));
let td = TempDir::new("foo").unwrap();

let prog = env::var("MAKE").unwrap_or("make".to_string());
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());

let me = t!(env::current_exe());
let me = me.to_str().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn make_as_a_single_thread_client() {
let c = t!(Client::new(1));
let td = TempDir::new("foo").unwrap();

let prog = env::var("MAKE").unwrap_or("make".to_string());
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
let mut cmd = Command::new(prog);
cmd.current_dir(td.path());

Expand Down Expand Up @@ -115,7 +115,7 @@ fn make_as_a_multi_thread_client() {
let c = t!(Client::new(1));
let td = TempDir::new("foo").unwrap();

let prog = env::var("MAKE").unwrap_or("make".to_string());
let prog = env::var("MAKE").unwrap_or_else(|_| "make".to_string());
let mut cmd = Command::new(prog);
cmd.current_dir(td.path());

Expand Down

0 comments on commit df2f7d7

Please sign in to comment.