Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
limemloh committed Mar 22, 2024
1 parent b4f08f8 commit 6b5e6b5
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 30 deletions.
23 changes: 10 additions & 13 deletions concordium-std/src/state_btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ use crate::{
/// [`new_btree_map`](crate::StateBuilder::new_btree_map) method on the
/// [`StateBuilder`](crate::StateBuilder).
///
/// ```
/// ```no_run
/// # use concordium_std::*;
/// # use concordium_std::test_infrastructure::*;
/// # let mut state_builder = TestStateBuilder::new();
/// # let mut state_builder = StateBuilder::open(StateApi::open());
/// /// In an init method:
/// let mut map1 = state_builder.new_btree_map();
/// # map1.insert(0u8, 1u8); // Specifies type of map.
///
/// # let mut host = TestHost::new((), state_builder);
/// # let mut host = ExternHost { state: (), state_builder };
/// /// In a receive method:
/// let mut map2 = host.state_builder().new_btree_map();
/// # map2.insert(0u16, 1u16);
Expand Down Expand Up @@ -330,15 +329,13 @@ impl<const M: usize, K, V> StateBTreeMap<K, V, M> {
/// [`new_btree_set`](crate::StateBuilder::new_btree_set) method on the
/// [`StateBuilder`](crate::StateBuilder).
///
/// ```
/// ```no_run
/// # use concordium_std::*;
/// # use concordium_std::test_infrastructure::*;
/// # let mut state_builder = TestStateBuilder::new();
/// # let mut state_builder = StateBuilder::open(StateApi::open());
/// /// In an init method:
/// let mut map1 = state_builder.new_btree_set();
/// # map1.insert(0u8); // Specifies type of map.
///
/// # let mut host = TestHost::new((), state_builder);
/// # let mut host = ExternHost { state: (), state_builder };
/// /// In a receive method:
/// let mut map2 = host.state_builder().new_btree_set();
/// # map2.insert(0u16);
Expand All @@ -351,8 +348,8 @@ impl<const M: usize, K, V> StateBTreeMap<K, V, M> {
///
/// ```no_run
/// # use concordium_std::*;
/// struct MyState<S: HasStateApi = StateApi> {
/// inner: StateBTreeSet<u64, S>,
/// struct MyState {
/// inner: StateBTreeSet<u64>,
/// }
/// fn incorrect_replace(state_builder: &mut StateBuilder, state: &mut MyState) {
/// // The following is incorrect. The old value of `inner` is not properly deleted.
Expand All @@ -364,8 +361,8 @@ impl<const M: usize, K, V> StateBTreeMap<K, V, M> {
///
/// ```no_run
/// # use concordium_std::*;
/// # struct MyState<S: HasStateApi = StateApi> {
/// # inner: StateBTreeSet<u64, S>
/// # struct MyState {
/// # inner: StateBTreeSet<u64>
/// # }
/// fn correct_replace(state_builder: &mut StateBuilder, state: &mut MyState) {
/// state.inner.clear();
Expand Down
4 changes: 2 additions & 2 deletions concordium-std/tests/state/map-multiple-entries.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `map` as mutable more than once at a time
--> tests/state/map-multiple-entries.rs:12:14
|
11 | let e1 = map.entry(0u8);
| -------------- first mutable borrow occurs here
| --- first mutable borrow occurs here
12 | let e2 = map.entry(1u8);
| ^^^^^^^^^^^^^^ second mutable borrow occurs here
| ^^^ second mutable borrow occurs here
13 | // Use them, so we are certain that their lifetimes overlap.
14 | e1.or_insert(1);
| -- first borrow later used here
4 changes: 2 additions & 2 deletions concordium-std/tests/state/map-multiple-state-ref-mut.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `map` as mutable more than once at a time
--> tests/state/map-multiple-state-ref-mut.rs:14:14
|
13 | let e1 = map.get_mut(&0u8).unwrap();
| ----------------- first mutable borrow occurs here
| --- first mutable borrow occurs here
14 | let e2 = map.get_mut(&1u8).unwrap();
| ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| ^^^ second mutable borrow occurs here
15 | // Use them, so we are certain that their lifetimes overlap.
16 | assert_eq!(*e1, *e2);
| -- first borrow later used here
4 changes: 2 additions & 2 deletions examples/cis2-dynamic-nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<S: HasStateApi> State<S> {
owner: &Address,
state_builder: &mut StateBuilder<S>,
) {
self.tokens.insert(*token_id, TokenMetadataState {
let _ = self.tokens.insert(*token_id, TokenMetadataState {
token_metadata_current_state_counter: 0,
token_metadata_list: mint_param.metadata_url.clone(),
});
Expand Down Expand Up @@ -368,7 +368,7 @@ impl<S: HasStateApi> State<S> {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/cis2-multi-royalties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl State {
royalty: u8,
) {
self.tokens.insert(*token_id);
self.token_details.insert(*token_id, TokenDetails {
let _ = self.token_details.insert(*token_id, TokenDetails {
minter: *owner,
royalty,
});
Expand Down Expand Up @@ -355,7 +355,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}

fn calculate_royalty_payments(
Expand Down
4 changes: 2 additions & 2 deletions examples/cis2-multi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl State {
) -> MetadataUrl {
let token_metadata = self.tokens.get(token_id).map(|x| x.to_owned());
if token_metadata.is_none() {
self.tokens.insert(*token_id, metadata_url.to_owned());
let _ = self.tokens.insert(*token_id, metadata_url.to_owned());
}

let mut owner_state =
Expand Down Expand Up @@ -788,7 +788,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}

/// Grant role to an address.
Expand Down
2 changes: 1 addition & 1 deletion examples/cis2-nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/cis2-wccd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/cis3-nft-sponsored-txs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/credential-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl<S: HasStateApi> State<S> {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/eSealing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl State {

/// Add a new file hash (replaces existing file if present).
fn add_file(&mut self, file_hash: HashSha2256, timestamp: Timestamp, witness: AccountAddress) {
self.files.insert(file_hash, FileState {
let _ = self.files.insert(file_hash, FileState {
timestamp,
witness,
});
Expand Down
2 changes: 1 addition & 1 deletion examples/factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub mod factory {
let state = host.state_mut();
let next_product = state.next_product;
state.next_product = next_product + 1;
state.products.insert(next_product, product_address);
let _ = state.products.insert(next_product, product_address);
// Invoke the initialize entrypoint on the product passing in the index for this
// product.
host.invoke_contract(
Expand Down
2 changes: 1 addition & 1 deletion templates/cis2-nft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl State {
std_id: StandardIdentifierOwned,
implementors: Vec<ContractAddress>,
) {
self.implementors.insert(std_id, implementors);
let _ = self.implementors.insert(std_id, implementors);
}
}

Expand Down

0 comments on commit 6b5e6b5

Please sign in to comment.