From 2b338c3549e9bc1a89a912db81f65ad25d707579 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 2 Jan 2019 19:09:37 -0500 Subject: [PATCH] clippy: if _ then _ ... is an expression --- ofborg/src/bin/builder.rs | 13 ++++++------- ofborg/src/nix.rs | 11 ++++------- ofborg/src/outpathdiff.rs | 10 ++++------ ofborg/src/tasks/githubcommentposter.rs | 11 ++++------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/ofborg/src/bin/builder.rs b/ofborg/src/bin/builder.rs index f18d6d7..29e4c0c 100644 --- a/ofborg/src/bin/builder.rs +++ b/ofborg/src/bin/builder.rs @@ -51,9 +51,8 @@ fn main() { }) .unwrap(); - let queue_name: String; - if cfg.runner.build_all_jobs != Some(true) { - queue_name = channel + let queue_name: String = if cfg.runner.build_all_jobs != Some(true) { + channel .declare_queue(easyamqp::QueueConfig { queue: format!("build-inputs-{}", cfg.nix.system.clone()), passive: false, @@ -63,11 +62,11 @@ fn main() { no_wait: false, arguments: None, }) - .unwrap().queue; + .unwrap().queue } else { warn!("Building all jobs, please don't use this unless you're"); warn!("developing and have Graham's permission!"); - queue_name = channel + channel .declare_queue(easyamqp::QueueConfig { queue: "".to_owned(), passive: false, @@ -77,8 +76,8 @@ fn main() { no_wait: false, arguments: None, }) - .unwrap().queue; - } + .unwrap().queue + }; channel .bind_queue(easyamqp::BindQueueConfig { diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index 7e3679e..d396b7e 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -204,14 +204,11 @@ impl Nix { let stderr = tempfile().expect("Fetching a stderr tempfile"); let mut reader = stderr.try_clone().expect("Cloning stderr to the reader"); - let stdout: Stdio; - - if keep_stdout { - let stdout_fd = stderr.try_clone().expect("Cloning stderr for stdout"); - stdout = Stdio::from(stdout_fd); + let stdout: Stdio = if keep_stdout { + Stdio::from(stderr.try_clone().expect("Cloning stderr for stdout")) } else { - stdout = Stdio::null(); - } + Stdio::null() + }; let status = cmd.stdout(Stdio::from(stdout)) .stderr(Stdio::from(stderr)) diff --git a/ofborg/src/outpathdiff.rs b/ofborg/src/outpathdiff.rs index 41168e1..2e34a05 100644 --- a/ofborg/src/outpathdiff.rs +++ b/ofborg/src/outpathdiff.rs @@ -161,13 +161,11 @@ impl OutPaths { } fn execute(&self) -> Result { - let check_meta: String; - - if self.check_meta { - check_meta = String::from("true"); + let check_meta: String = if self.check_meta { + String::from("true") } else { - check_meta = String::from("false"); - } + String::from("false") + }; self.nix.safely( nix::Operation::QueryPackagesOutputs, diff --git a/ofborg/src/tasks/githubcommentposter.rs b/ofborg/src/tasks/githubcommentposter.rs index cd78ba1..0f0673e 100644 --- a/ofborg/src/tasks/githubcommentposter.rs +++ b/ofborg/src/tasks/githubcommentposter.rs @@ -115,9 +115,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime) -> Chec &skipped)); } - let text: String; - - if !result.output.is_empty() { + let text: String = if !result.output.is_empty() { let mut reply: Vec = vec![]; reply.push("## Partial log".to_owned()); @@ -126,11 +124,10 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime) -> Chec reply.extend(result.output.clone()); reply.push("```".to_owned()); - text = reply.join("\n"); + reply.join("\n") } else { - text = String::from("No partial log is available."); - } - + String::from("No partial log is available.") + }; CheckRunOptions{ name: format!(