From 737e47ed3a0dd136fd07aed70762b0ef016bde6f Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:51:46 -0800 Subject: [PATCH] fix --- .../src/asset_certification/tree.rs | 12 ++++++------ src/dfx-core/src/config/model/network_descriptor.rs | 2 +- src/dfx/src/commands/build.rs | 2 +- src/dfx/src/lib/builders/assets.rs | 2 ++ src/dfx/src/lib/builders/mod.rs | 2 +- src/dfx/src/lib/builders/motoko.rs | 2 ++ src/dfx/src/lib/error/mod.rs | 1 - src/dfx/src/lib/models/canister.rs | 2 ++ .../src/lib/operations/canister/install_canister.rs | 2 +- src/dfx/src/lib/operations/canister/mod.rs | 5 +---- src/dfx/src/main.rs | 3 ++- 11 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs b/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs index d46c4dfec9..22b4af451a 100644 --- a/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs +++ b/src/canisters/frontend/ic-certified-assets/src/asset_certification/tree.rs @@ -36,7 +36,7 @@ impl AsHashTree fo impl NestedTree { #[allow(dead_code)] pub fn get(&self, path: &[K]) -> Option<&V> { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => None, NestedTree::Nested(tree) => tree @@ -53,7 +53,7 @@ impl NestedTree bool { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => false, NestedTree::Nested(tree) => tree @@ -68,7 +68,7 @@ impl NestedTree bool { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(_) => false, NestedTree::Nested(tree) => tree @@ -82,7 +82,7 @@ impl NestedTree { *self = NestedTree::default(); @@ -103,7 +103,7 @@ impl NestedTree {} NestedTree::Nested(tree) => { @@ -116,7 +116,7 @@ impl NestedTree HashTree { - if let Some(key) = path.get(0) { + if let Some(key) = path.first() { match self { NestedTree::Leaf(value) => value.as_hash_tree(), NestedTree::Nested(tree) => { diff --git a/src/dfx-core/src/config/model/network_descriptor.rs b/src/dfx-core/src/config/model/network_descriptor.rs index 73c2e217a8..2565348353 100644 --- a/src/dfx-core/src/config/model/network_descriptor.rs +++ b/src/dfx-core/src/config/model/network_descriptor.rs @@ -85,7 +85,7 @@ impl NetworkDescriptor { let provider_match = { providers.len() == 1 && matches!( - providers.get(0).unwrap().as_str(), + providers.first().unwrap().as_str(), DEFAULT_IC_GATEWAY | DEFAULT_IC_GATEWAY_TRAILING_SLASH ) }; diff --git a/src/dfx/src/commands/build.rs b/src/dfx/src/commands/build.rs index 22d58f3dcf..c8aef8c17c 100644 --- a/src/dfx/src/commands/build.rs +++ b/src/dfx/src/commands/build.rs @@ -112,8 +112,8 @@ fn collect_extra_canisters(env: &AgentEnvironment, config: &Config) -> Vec>() }) .unwrap_or_default() diff --git a/src/dfx/src/lib/builders/assets.rs b/src/dfx/src/lib/builders/assets.rs index 701075a4df..eff29745ac 100644 --- a/src/dfx/src/lib/builders/assets.rs +++ b/src/dfx/src/lib/builders/assets.rs @@ -56,6 +56,8 @@ pub struct AssetsBuilder { _cache: Arc, logger: Logger, } +unsafe impl Send for AssetsBuilder {} +unsafe impl Sync for AssetsBuilder {} impl AssetsBuilder { #[context("Failed to create AssetBuilder.")] diff --git a/src/dfx/src/lib/builders/mod.rs b/src/dfx/src/lib/builders/mod.rs index 88b95e9abc..59846b8a39 100644 --- a/src/dfx/src/lib/builders/mod.rs +++ b/src/dfx/src/lib/builders/mod.rs @@ -328,7 +328,7 @@ pub fn run_command(args: Vec, vars: &[Env<'_>], cwd: &Path) -> DfxResult let canonicalized = dfx_core::fs::canonicalize(&cwd.join(command_name)) .or_else(|_| which::which(command_name)) .map_err(|_| anyhow!("Cannot find command or file {command_name}"))?; - let mut cmd = Command::new(&canonicalized); + let mut cmd = Command::new(canonicalized); cmd.args(arguments) .current_dir(cwd) diff --git a/src/dfx/src/lib/builders/motoko.rs b/src/dfx/src/lib/builders/motoko.rs index 3b3f526d38..6934f0a61e 100644 --- a/src/dfx/src/lib/builders/motoko.rs +++ b/src/dfx/src/lib/builders/motoko.rs @@ -26,6 +26,8 @@ pub struct MotokoBuilder { logger: slog::Logger, cache: Arc, } +unsafe impl Send for MotokoBuilder {} +unsafe impl Sync for MotokoBuilder {} impl MotokoBuilder { #[context("Failed to create MotokoBuilder.")] diff --git a/src/dfx/src/lib/error/mod.rs b/src/dfx/src/lib/error/mod.rs index 576c74fa65..90bd8d984f 100644 --- a/src/dfx/src/lib/error/mod.rs +++ b/src/dfx/src/lib/error/mod.rs @@ -4,7 +4,6 @@ pub mod notify_top_up; pub mod project; pub use build::BuildError; -pub use dfx_core::error::extension::ExtensionError; pub use notify_create_canister::NotifyCreateCanisterError; pub use notify_top_up::NotifyTopUpError; pub use project::ProjectError; diff --git a/src/dfx/src/lib/models/canister.rs b/src/dfx/src/lib/models/canister.rs index 5f435683d9..002445de10 100644 --- a/src/dfx/src/lib/models/canister.rs +++ b/src/dfx/src/lib/models/canister.rs @@ -41,6 +41,8 @@ pub struct Canister { builder: Arc, output: RefCell>, } +unsafe impl Send for Canister {} +unsafe impl Sync for Canister {} impl Canister { /// Create a new canister. diff --git a/src/dfx/src/lib/operations/canister/install_canister.rs b/src/dfx/src/lib/operations/canister/install_canister.rs index 3f94596cec..fe9b034f89 100644 --- a/src/dfx/src/lib/operations/canister/install_canister.rs +++ b/src/dfx/src/lib/operations/canister/install_canister.rs @@ -417,7 +417,7 @@ fn run_post_install_task( let canonicalized = dfx_core::fs::canonicalize(&cwd.join(&words[0])) .or_else(|_| which::which(&words[0])) .map_err(|_| anyhow!("Cannot find command or file {}", &words[0]))?; - let mut command = Command::new(&canonicalized); + let mut command = Command::new(canonicalized); command.args(&words[1..]); let vars = get_and_write_environment_variables(canister, &network.name, pool, dependencies, env_file)?; diff --git a/src/dfx/src/lib/operations/canister/mod.rs b/src/dfx/src/lib/operations/canister/mod.rs index 9e01743f42..a5af1e7ce2 100644 --- a/src/dfx/src/lib/operations/canister/mod.rs +++ b/src/dfx/src/lib/operations/canister/mod.rs @@ -12,17 +12,14 @@ use candid::utils::ArgumentDecoder; use candid::CandidType; use candid::Principal as CanisterId; use candid::Principal; -pub use deploy_canisters::deploy_canisters; -pub use deploy_canisters::DeployMode; use dfx_core::canister::build_wallet_canister; -pub use dfx_core::canister::install_canister_wasm; use dfx_core::identity::CallSender; use fn_error_context::context; use ic_utils::interfaces::management_canister::builders::CanisterSettings; use ic_utils::interfaces::management_canister::{MgmtMethod, StatusCallResult}; use ic_utils::interfaces::ManagementCanister; use ic_utils::Argument; -pub use install_canister::{install_canister, install_wallet}; +pub use install_canister::install_wallet; use std::path::PathBuf; pub mod motoko_playground; diff --git a/src/dfx/src/main.rs b/src/dfx/src/main.rs index 712d2df3f3..24543ad355 100644 --- a/src/dfx/src/main.rs +++ b/src/dfx/src/main.rs @@ -193,7 +193,8 @@ fn main() { let command = cli_opts.command; let result = match EnvironmentImpl::new() { Ok(env) => { - maybe_redirect_dfx(env.get_version()).map_or((), |_| unreachable!()); + #[allow(clippy::let_unit_value)] + let _ = maybe_redirect_dfx(env.get_version()).map_or((), |_| unreachable!()); match EnvironmentImpl::new().map(|env| { env.with_logger(log) .with_identity_override(identity)