Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Jan 17, 2024
1 parent 4631af2 commit 737e47e
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> AsHashTree fo
impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K, V> {
#[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
Expand All @@ -53,7 +53,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K,

/// Returns true if there is a leaf at the specified path
pub fn contains_leaf(&self, path: &[K]) -> bool {
if let Some(key) = path.get(0) {
if let Some(key) = path.first() {
match self {
NestedTree::Leaf(_) => false,
NestedTree::Nested(tree) => tree
Expand All @@ -68,7 +68,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K,

/// Returns true if there is a leaf or a subtree at the specified path
pub fn contains_path(&self, path: &[K]) -> bool {
if let Some(key) = path.get(0) {
if let Some(key) = path.first() {
match self {
NestedTree::Leaf(_) => false,
NestedTree::Nested(tree) => tree
Expand All @@ -82,7 +82,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K,
}

pub fn insert(&mut self, path: &[K], value: V) {
if let Some(key) = path.get(0) {
if let Some(key) = path.first() {
match self {
NestedTree::Leaf(_) => {
*self = NestedTree::default();
Expand All @@ -103,7 +103,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K,
}

pub fn delete(&mut self, path: &[K]) {
if let Some(key) = path.get(0) {
if let Some(key) = path.first() {
match self {
NestedTree::Leaf(_) => {}
NestedTree::Nested(tree) => {
Expand All @@ -116,7 +116,7 @@ impl<K: NestedTreeKeyRequirements, V: NestedTreeValueRequirements> NestedTree<K,
}

pub fn witness(&self, path: &[K]) -> 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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/dfx-core/src/config/model/network_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
};
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ fn collect_extra_canisters(env: &AgentEnvironment, config: &Config) -> Vec<Strin
.map(|canisters| {
canisters
.keys()
.cloned()
.filter(|canister| store.get(canister).is_ok())
.cloned()
.collect::<Vec<_>>()
})
.unwrap_or_default()
Expand Down
2 changes: 2 additions & 0 deletions src/dfx/src/lib/builders/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub struct AssetsBuilder {
_cache: Arc<dyn Cache>,
logger: Logger,
}
unsafe impl Send for AssetsBuilder {}
unsafe impl Sync for AssetsBuilder {}

impl AssetsBuilder {
#[context("Failed to create AssetBuilder.")]
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/lib/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pub fn run_command(args: Vec<String>, 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)
Expand Down
2 changes: 2 additions & 0 deletions src/dfx/src/lib/builders/motoko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct MotokoBuilder {
logger: slog::Logger,
cache: Arc<dyn Cache>,
}
unsafe impl Send for MotokoBuilder {}
unsafe impl Sync for MotokoBuilder {}

impl MotokoBuilder {
#[context("Failed to create MotokoBuilder.")]
Expand Down
1 change: 0 additions & 1 deletion src/dfx/src/lib/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/dfx/src/lib/models/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub struct Canister {
builder: Arc<dyn CanisterBuilder>,
output: RefCell<Option<BuildOutput>>,
}
unsafe impl Send for Canister {}
unsafe impl Sync for Canister {}

impl Canister {
/// Create a new canister.
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/lib/operations/canister/install_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
5 changes: 1 addition & 4 deletions src/dfx/src/lib/operations/canister/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/dfx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 737e47e

Please sign in to comment.