Skip to content

Commit

Permalink
Make compiler/linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Sword-Smith committed May 7, 2024
1 parent e5f884f commit 3de0e42
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 26 deletions.
4 changes: 4 additions & 0 deletions src/bin/dashboard_src/receive_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ impl Widget for ReceiveScreen {
let width = max(0, inner.width as isize - 2) as usize;
if width > 0 {
let mut address_lines = vec![];

// TODO: Not sure how to handle this linting problem, as clippy suggestion doesn't work.
#[allow(clippy::assigning_clones)]
while address.len() > width {
let (line, remainder) = address.split_at(width);
address_lines.push(line.to_owned());

address = remainder.to_owned();
}
address_lines.push(address);
Expand Down
5 changes: 4 additions & 1 deletion src/bin/dashboard_src/send_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl SendScreen {
}
DashboardEvent::ConsoleMode(ConsoleIO::InputSupplied(string)) => {
if let Ok(mut own_focus) = self.focus.try_lock() {
self.address = string.trim().to_owned();
string.trim().clone_into(&mut self.address);
*own_focus = SendScreenWidget::Amount;
escalate_event = Some(DashboardEvent::RefreshScreen);
} else {
Expand Down Expand Up @@ -350,6 +350,9 @@ impl Widget for SendScreen {
self.address.clone()
};
let mut address_lines = vec![];

// TODO: Not sure how to handle this linting problem, as clippy suggestion doesn't work.
#[allow(clippy::assigning_clones)]
while address.len() > width {
let (line, remainder) = address.split_at(width);
address_lines.push(line.to_owned());
Expand Down
4 changes: 2 additions & 2 deletions src/connect_to_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ mod connect_tests {
let mut own_handshake = state.get_own_handshakedata().await;

// Set reported versions to something incompatible
own_handshake.version = "0.0.3".to_owned();
other_handshake.version = "0.0.0".to_owned();
"0.0.3".clone_into(&mut own_handshake.version);
"0.0.0".clone_into(&mut other_handshake.version);

let peer_address = get_dummy_socket_address(55);
let connection_status = check_if_connection_is_allowed(
Expand Down
2 changes: 0 additions & 2 deletions src/database/storage/storage_vec/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ pub trait StorageVecStream<T: Send>: StorageVecBase<T> {

pub trait StorageVec<T: Send>: StorageVecBase<T> + StorageVecStream<T> {}

pub(in super::super) trait StorageVecIterMut<T: Send>: StorageVec<T> {}

#[cfg(test)]
pub(in super::super) mod tests {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,9 @@ impl RemovalRecordsIntegrityWitness {
working_indices.dedup();
for wi in working_indices {
let wi_odd = wi | 1;
if nodes.get(&wi_odd).is_none() {
nodes.insert(wi_odd, rng.gen::<Digest>());
}
nodes.entry(wi_odd).or_insert_with(|| rng.gen::<Digest>());
let wi_even = wi_odd ^ 1;
if nodes.get(&wi_even).is_none() {
nodes.insert(wi_even, rng.gen::<Digest>());
}
nodes.entry(wi_even).or_insert_with(|| rng.gen::<Digest>());
let hash = Hash::hash_pair(nodes[&wi_even], nodes[&wi_odd]);
nodes.insert(wi >> 1, hash);
}
Expand Down
3 changes: 2 additions & 1 deletion src/models/state/archival_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,8 @@ mod archival_state_tests {

#[traced_test]
#[tokio::test]
// Added due to clippy warning produced by `traced_test` test framework.
#[allow(clippy::needless_return)]
async fn get_tip_block_test() -> Result<()> {
for network in [
Network::Alpha,
Expand Down Expand Up @@ -1910,7 +1912,6 @@ mod archival_state_tests {
assert_eq!(mock_block_1, archival_state.get_tip_parent().await.unwrap());
}

//
Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion src/models/state/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,11 @@ mod wallet_tests {
#[traced_test]
#[tokio::test]
async fn wallet_state_maintanence_multiple_inputs_outputs_test() -> Result<()> {
let mut rng = thread_rng();
// An archival state is needed for how we currently add inputs to a transaction.
// So it's just used to generate test data, not in any of the functions that are
// actually tested.

let mut rng = thread_rng();
let network = Network::RegTest;
let own_wallet_secret = WalletSecret::new_random();
let mut own_wallet_state = mock_genesis_wallet_state(own_wallet_secret, network).await;
Expand Down
6 changes: 3 additions & 3 deletions src/models/state/wallet/wallet_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ impl WalletState {
// If output UTXO belongs to us, add it to the list of monitored UTXOs and
// add its membership proof to the list of managed membership proofs.
if addition_record_to_utxo_info.contains_key(addition_record) {
let utxo = addition_record_to_utxo_info[&addition_record].0.clone();
let sender_randomness = addition_record_to_utxo_info[&addition_record].1;
let receiver_preimage = addition_record_to_utxo_info[&addition_record].2;
let utxo = addition_record_to_utxo_info[addition_record].0.clone();
let sender_randomness = addition_record_to_utxo_info[addition_record].1;
let receiver_preimage = addition_record_to_utxo_info[addition_record].2;
info!(
"Received UTXO in block {}, height {}: value = {}",
new_block.hash(),
Expand Down
5 changes: 2 additions & 3 deletions src/tests/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rand::SeedableRng;
use std::path::Path;
use std::path::PathBuf;
use std::time::SystemTime;
use std::{collections::HashMap, env, net::SocketAddr, pin::Pin, str::FromStr, sync::Arc};
use std::{collections::HashMap, env, net::SocketAddr, pin::Pin, str::FromStr};
use tasm_lib::twenty_first::util_types::mmr::mmr_accumulator::MmrAccumulator;
use tokio::sync::{broadcast, mpsc};
use tokio_serde::{formats::SymmetricalBincode, Serializer};
Expand Down Expand Up @@ -63,7 +63,6 @@ use crate::models::database::BlockIndexKey;
use crate::models::database::BlockIndexValue;
use crate::models::database::PeerDatabases;
use crate::models::peer::{HandshakeData, PeerInfo, PeerMessage, PeerStanding};
use crate::models::shared::LatestBlockInfo;
use crate::models::state::archival_state::ArchivalState;
use crate::models::state::blockchain_state::{BlockchainArchivalState, BlockchainState};
use crate::models::state::light_state::LightState;
Expand All @@ -72,8 +71,8 @@ use crate::models::state::networking_state::NetworkingState;
use crate::models::state::wallet::address::generation_address;
use crate::models::state::wallet::wallet_state::WalletState;
use crate::models::state::wallet::WalletSecret;
use crate::models::state::GlobalStateLock;
use crate::models::state::UtxoReceiverData;
use crate::models::state::{GlobalState, GlobalStateLock};
use crate::util_types::mutator_set::addition_record::pseudorandom_addition_record;
use crate::util_types::mutator_set::addition_record::AdditionRecord;
use crate::util_types::mutator_set::chunk_dictionary::pseudorandom_chunk_dictionary;
Expand Down
2 changes: 1 addition & 1 deletion src/util_types/mutator_set/mutator_set_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl MutatorSetAccumulator {
for mp in preserved_membership_proofs.iter_mut() {
for (chunk_index, (_, chunk)) in mp.target_chunks.dictionary.iter_mut() {
if mutation_data_preimage.contains_key(chunk_index) {
*chunk = mutation_data_preimage[chunk_index].0.to_owned();
mutation_data_preimage[chunk_index].0.clone_into(chunk);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/util_types/test_shared/mutator_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,9 @@ pub fn pseudorandom_merkle_root_with_authentication_paths<H: AlgebraicHasher>(
working_indices.dedup();
for wi in working_indices {
let wi_odd = wi | 1;
if nodes.get(&wi_odd).is_none() {
nodes.insert(wi_odd, rng.gen::<Digest>());
}
nodes.entry(wi_odd).or_insert_with(|| rng.gen::<Digest>());
let wi_even = wi_odd ^ 1;
if nodes.get(&wi_even).is_none() {
nodes.insert(wi_even, rng.gen::<Digest>());
}
nodes.entry(wi_even).or_insert_with(|| rng.gen::<Digest>());
let hash = H::hash_pair(nodes[&wi_even], nodes[&wi_odd]);
nodes.insert(wi >> 1, hash);
}
Expand Down

0 comments on commit 3de0e42

Please sign in to comment.