From 728eea0f5c20070af7cb4c3eb082d698f2cb5abd Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Fri, 17 Jul 2020 16:37:22 -0700 Subject: [PATCH] upgrade to Rust 1.45.0 (#10396) ### Problem Keep up with Rust releases. ### Solution Upgrade to Rust v1.45.0. Clippy-related changes: - `impl FnMut(...) -> ()`. Drop the () as extraneous. - `Result.and_then(|x| Ok(y))` -> `Result.map(|x| y)` - `Result.and_then(|x| Err(y))` -> `Result.map_err(|x| y)` - `clippy::identity_conversion` renamed to `clippy::useless_conversion` Other changes: - Bump type length limit in `src/rust/engine/process_executor/src/main.rs` due to compile error. ### Result Code compiles. Tests pass. --- rust-toolchain | 2 +- src/rust/engine/graph/src/lib.rs | 4 ++-- src/rust/engine/nailgun/src/lib.rs | 2 +- src/rust/engine/process_execution/src/local.rs | 10 ++++------ .../process_execution/src/nailgun/nailgun_pool.rs | 10 +++++----- src/rust/engine/process_executor/src/main.rs | 2 +- src/rust/engine/sharded_lmdb/src/lib.rs | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index d724e439030..50aceaa7b71 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.44.1 +1.45.0 diff --git a/src/rust/engine/graph/src/lib.rs b/src/rust/engine/graph/src/lib.rs index 8c8b5cf8d03..1e87e5b96c7 100644 --- a/src/rust/engine/graph/src/lib.rs +++ b/src/rust/engine/graph/src/lib.rs @@ -947,7 +947,7 @@ impl Graph { &self, roots: &[N], context: &N::Context, - mut f: impl FnMut(&N, N::Item) -> (), + mut f: impl FnMut(&N, N::Item), ) { let inner = self.inner.lock(); for (n, v) in inner.live_reachable(roots, context) { @@ -955,7 +955,7 @@ impl Graph { } } - pub fn visit_live(&self, context: &N::Context, mut f: impl FnMut(&N, N::Item) -> ()) { + pub fn visit_live(&self, context: &N::Context, mut f: impl FnMut(&N, N::Item)) { let inner = self.inner.lock(); for (n, v) in inner.live(context) { f(n, v); diff --git a/src/rust/engine/nailgun/src/lib.rs b/src/rust/engine/nailgun/src/lib.rs index 375b642c0b1..df8c9d32d19 100644 --- a/src/rust/engine/nailgun/src/lib.rs +++ b/src/rust/engine/nailgun/src/lib.rs @@ -196,7 +196,7 @@ impl Server { self .exited_receiver .await - .or_else(|_| Err("Server exited uncleanly.".to_owned()))? + .map_err(|_| "Server exited uncleanly.".to_owned())? } } diff --git a/src/rust/engine/process_execution/src/local.rs b/src/rust/engine/process_execution/src/local.rs index 0fec3151912..fbce531dad2 100644 --- a/src/rust/engine/process_execution/src/local.rs +++ b/src/rust/engine/process_execution/src/local.rs @@ -174,7 +174,7 @@ impl StreamedHermeticCommand { .stderr(Stdio::piped()) .spawn() .map_err(|e| format!("Error launching process: {:?}", e)) - .and_then(|mut child| { + .map(|mut child| { debug!("spawned local process as {} for {:?}", child.id(), req); let stdout_stream = FramedRead::new(child.stdout.take().unwrap(), BytesCodec::new()) .map_ok(|bytes| ChildOutput::Stdout(bytes.into())) @@ -194,11 +194,9 @@ impl StreamedHermeticCommand { }) .boxed(); - Ok( - futures::stream::select_all(vec![stdout_stream, stderr_stream, exit_stream]) - .map_err(|e| format!("Failed to consume process outputs: {:?}", e)) - .boxed(), - ) + futures::stream::select_all(vec![stdout_stream, stderr_stream, exit_stream]) + .map_err(|e| format!("Failed to consume process outputs: {:?}", e)) + .boxed() }) } } diff --git a/src/rust/engine/process_execution/src/nailgun/nailgun_pool.rs b/src/rust/engine/process_execution/src/nailgun/nailgun_pool.rs index 816cae6b17f..4532563324b 100644 --- a/src/rust/engine/process_execution/src/nailgun/nailgun_pool.rs +++ b/src/rust/engine/process_execution/src/nailgun/nailgun_pool.rs @@ -242,10 +242,10 @@ impl NailgunPool { nailgun_server_fingerprint, build_id, ) - .and_then(move |process| { + .map(move |process| { let port = process.port; processes.insert(name.clone(), process); - Ok(port) + port }) } } @@ -316,19 +316,19 @@ impl NailgunProcess { let port = read_port(&mut child); port.map(|port| (child, port)) }) - .and_then(|(child, port)| { + .map(|(child, port)| { debug!( "Created nailgun server process with pid {} and port {}", child.id(), port ); - Ok(NailgunProcess { + NailgunProcess { port, fingerprint: nailgun_server_fingerprint, name, handle: Arc::new(Mutex::new(child)), build_id, - }) + } }) } } diff --git a/src/rust/engine/process_executor/src/main.rs b/src/rust/engine/process_executor/src/main.rs index a11381ae8f1..acbe81192b8 100644 --- a/src/rust/engine/process_executor/src/main.rs +++ b/src/rust/engine/process_executor/src/main.rs @@ -26,7 +26,7 @@ #![allow(clippy::new_without_default, clippy::new_ret_no_self)] // Arc can be more clear than needing to grok Orderings: #![allow(clippy::mutex_atomic)] -#![type_length_limit = "1076739"] +#![type_length_limit = "1076744"] use std::collections::{BTreeMap, BTreeSet}; use std::convert::TryFrom; diff --git a/src/rust/engine/sharded_lmdb/src/lib.rs b/src/rust/engine/sharded_lmdb/src/lib.rs index 2dc37089d9f..f0bac96a280 100644 --- a/src/rust/engine/sharded_lmdb/src/lib.rs +++ b/src/rust/engine/sharded_lmdb/src/lib.rs @@ -375,7 +375,7 @@ impl ShardedLmdb { .await } - #[allow(clippy::identity_conversion)] // False positive: https://github.com/rust-lang/rust-clippy/issues/3913 + #[allow(clippy::useless_conversion)] // False positive: https://github.com/rust-lang/rust-clippy/issues/3913 pub fn compact(&self) -> Result<(), String> { for (env, old_dir, _) in ShardedLmdb::envs(&self.root_path, self.max_size)? { let new_dir = TempDir::new_in(old_dir.parent().unwrap()).expect("TODO");