diff --git a/nix/sources.json b/nix/sources.json index 09cd48e070..b9421880c3 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -6,10 +6,10 @@ "homepage": "https://rustsec.org", "owner": "RustSec", "repo": "advisory-db", - "rev": "92e5c88a735b5deb50f6c60880e4447da236a591", - "sha256": "1cw2dpj9hb4b52g14vzymahsjikcg0p6d7vm711nspx17w3xgr79", + "rev": "ac125ee29a3b934fc00f52bf56031dc837e9384d", + "sha256": "1mpark5dc64zr3qn564z2idvz44izjpkyihkdgbnwf0ibhv25wpk", "type": "tarball", - "url": "https://github.com/RustSec/advisory-db/archive/92e5c88a735b5deb50f6c60880e4447da236a591.tar.gz", + "url": "https://github.com/RustSec/advisory-db/archive/ac125ee29a3b934fc00f52bf56031dc837e9384d.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "agent-js-monorepo": { @@ -34,7 +34,7 @@ "common": { "branch": "master", "repo": "ssh://git@github.com/dfinity-lab/common", - "rev": "4b93b09b796fbb62f3c4789e7527a0765eae0cdb", + "rev": "4a65b8341dd4cff0059947b7f2254d09219a90db", "type": "git" }, "dfinity": { diff --git a/src/dfx/src/commands/new.rs b/src/dfx/src/commands/new.rs index cfacdabfea..e24083aad4 100644 --- a/src/dfx/src/commands/new.rs +++ b/src/dfx/src/commands/new.rs @@ -189,8 +189,7 @@ fn write_files_from_entries( } let mut s = String::new(); - file.read_to_string(&mut s) - .or_else(|e| Err(DfxError::Io(e)))?; + file.read_to_string(&mut s).map_err(DfxError::Io)?; // Perform replacements. variables.iter().for_each(|(name, value)| { @@ -292,11 +291,8 @@ fn scaffold_frontend_code( "dist/".to_owned() + project_name_str + "_assets/", )); - let pretty = serde_json::to_string_pretty(&config_json).or_else(|e| { - Err(DfxError::InvalidData(format!( - "Failed to serialize dfx.json: {}", - e - ))) + let pretty = serde_json::to_string_pretty(&config_json).map_err(|e| { + DfxError::InvalidData(format!("Failed to serialize dfx.json: {}", e)) })?; std::fs::write(&dfx_path, pretty)?; diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index d9579b0da7..171f7d713a 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -263,11 +263,11 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { // terminates all sibling processes if a process returns an error, // which we lack. We consider this a fine trade-off for now. - rcv_wait.recv().or_else(|e| { - Err(DfxError::RuntimeError(Error::new( + rcv_wait.recv().map_err(|e| { + DfxError::RuntimeError(Error::new( ErrorKind::Other, format!("Failed while waiting for the manager -- {:?}", e), - ))) + )) })?; // Signal the client to stop. Right now we have little control diff --git a/src/dfx/src/config/cache.rs b/src/dfx/src/config/cache.rs index f346175616..be92b3c137 100644 --- a/src/dfx/src/config/cache.rs +++ b/src/dfx/src/config/cache.rs @@ -13,10 +13,6 @@ use std::process::ExitStatus; // POSIX permissions for files in the cache. const EXEC_READ_USER_ONLY_PERMISSION: u32 = 0o500; -#[cfg(test)] -use mockall::automock; - -#[cfg_attr(test, automock)] pub trait Cache { fn version_str(&self) -> String; fn is_installed(&self) -> DfxResult; @@ -108,7 +104,7 @@ pub fn get_bin_cache(v: &str) -> DfxResult { } pub fn is_version_installed(v: &str) -> DfxResult { - get_bin_cache(v).and_then(|c| Ok(c.is_dir())) + get_bin_cache(v).map(|c| c.is_dir()) } pub fn delete_version(v: &str) -> DfxResult { diff --git a/src/dfx/src/config/dfinity.rs b/src/dfx/src/config/dfinity.rs index 1c8c57daf7..847ec7b819 100644 --- a/src/dfx/src/config/dfinity.rs +++ b/src/dfx/src/config/dfinity.rs @@ -393,12 +393,8 @@ impl Config { } pub fn save(&self) -> DfxResult { - let json_pretty = serde_json::to_string_pretty(&self.json).or_else(|e| { - Err(DfxError::InvalidData(format!( - "Failed to serialize dfx.json: {}", - e - ))) - })?; + let json_pretty = serde_json::to_string_pretty(&self.json) + .map_err(|e| DfxError::InvalidData(format!("Failed to serialize dfx.json: {}", e)))?; std::fs::write(&self.path, json_pretty)?; Ok(()) } diff --git a/src/dfx/src/lib/environment.rs b/src/dfx/src/lib/environment.rs index 5a80d64bd6..a5b03a2757 100644 --- a/src/dfx/src/lib/environment.rs +++ b/src/dfx/src/lib/environment.rs @@ -15,10 +15,6 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use std::time::Duration; -#[cfg(test)] -use mockall::automock; - -#[cfg_attr(test, automock)] pub trait Environment { fn get_cache(&self) -> Arc; fn get_config(&self) -> Option>; diff --git a/src/dfx/src/lib/proxy.rs b/src/dfx/src/lib/proxy.rs index 4eab5d939a..4ec2ced0f9 100644 --- a/src/dfx/src/lib/proxy.rs +++ b/src/dfx/src/lib/proxy.rs @@ -59,11 +59,11 @@ impl Proxy { handler .receiver .try_recv() - .or_else(|e| { - Err(Error::new( + .map_err(|e| { + Error::new( ErrorKind::Other, format!("Failed to shutdown proxy -- {:?}", e), - )) + ) })? .stop(true) .await; diff --git a/src/dfx/src/lib/proxy_process.rs b/src/dfx/src/lib/proxy_process.rs index 60ed331200..dee4d059ae 100644 --- a/src/dfx/src/lib/proxy_process.rs +++ b/src/dfx/src/lib/proxy_process.rs @@ -89,7 +89,7 @@ pub fn spawn_and_update_proxy( }); // Stop watching. let _ = hotwatch; - let proxy = proxy.set_client_api_port(port.clone()); + let proxy = proxy.set_client_api_port(port); b.set_message(format!("Replica bound at {}", port).as_str()); block_on(proxy.restart( proxy_supervisor.inform_parent.clone(),