Skip to content

Commit

Permalink
Make QuerierWrapper/Deps non-Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Sep 8, 2021
1 parent 8436216 commit 5ec9b4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and this project adheres to
support longer address formats than bech32.
- cosmwasm-std: Make `CustomQuery` a subtrait of `Clone`, i.e. types that
implement `CustomQuery` need to be `Clone`able.
- cosmwasm-std: Remove `Copy` implementation from `QuerierWrapper` and `Deps`
which is not derived for custom non-`Copy` query type `C`. Both types are too
complex to guarantee `Copy` conformance long term, even if they are cheap to
clone right now.

### Removed

Expand Down
8 changes: 4 additions & 4 deletions packages/std/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct DepsMut<'a> {
pub querier: QuerierWrapper<'a>,
}

#[derive(Copy, Clone)]
#[derive(Clone)]
pub struct Deps<'a> {
pub storage: &'a dyn Storage,
pub api: &'a dyn Api,
Expand Down Expand Up @@ -47,15 +47,15 @@ impl<'a> DepsMut<'a> {
Deps {
storage: self.storage,
api: self.api,
querier: self.querier,
querier: self.querier.clone(),
}
}

pub fn branch(&'_ mut self) -> DepsMut<'_> {
DepsMut {
storage: self.storage,
api: self.api,
querier: self.querier,
querier: self.querier.clone(),
}
}
}
Expand All @@ -74,7 +74,7 @@ mod tests {
fn execute2(_deps: DepsMut) {}

fn query(deps: Deps) {
query2(deps);
query2(deps.clone());
query2(deps);
}
fn query2(_deps: Deps) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/std/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub trait Querier {
fn raw_query(&self, bin_request: &[u8]) -> QuerierResult;
}

#[derive(Copy, Clone)]
#[derive(Clone)]
pub struct QuerierWrapper<'a>(&'a dyn Querier);

/// This allows us to use self.raw_query to access the querier.
Expand Down

0 comments on commit 5ec9b4e

Please sign in to comment.