Fixing clippy warnings

This commit is contained in:
Tomasz Drwięga 2016-05-17 10:32:05 +02:00
parent f7929ffdd4
commit a950b81ee8
21 changed files with 32 additions and 44 deletions

View File

@ -342,7 +342,6 @@ mod tests {
#[test]
fn new_account() {
use rustc_serialize::hex::ToHex;
let a = Account::new(U256::from(69u8), U256::from(0u8), HashMap::new(), Bytes::new());
assert_eq!(a.rlp().to_hex(), "f8448045a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
@ -354,7 +353,6 @@ mod tests {
#[test]
fn create_account() {
use rustc_serialize::hex::ToHex;
let a = Account::new(U256::from(69u8), U256::from(0u8), HashMap::new(), Bytes::new());
assert_eq!(a.rlp().to_hex(), "f8448045a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");

View File

@ -200,7 +200,6 @@ mod tests {
use super::*;
use common::*;
use block::*;
use engine::*;
use tests::helpers::*;
use util::keys::{TestAccountProvider, TestAccount};

View File

@ -299,7 +299,6 @@ mod tests {
use common::*;
use block::*;
use engine::*;
use tests::helpers::*;
use super::super::new_morden;

View File

@ -51,7 +51,6 @@ pub fn new_morden() -> Spec { Spec::load(include_bytes!("../../res/ethereum/mord
mod tests {
use common::*;
use state::*;
use engine::*;
use super::*;
use tests::helpers::*;

View File

@ -358,8 +358,6 @@ mod tests {
use super::*;
use util::common::*;
use util::trie::*;
use util::rlp::*;
use account::*;
use tests::helpers::*;
use devtools::*;

View File

@ -22,7 +22,7 @@ use std::sync::{RwLock, Arc};
use std::path::Path;
use bloomchain::{Number, Config as BloomConfig};
use bloomchain::group::{BloomGroupDatabase, BloomGroupChain, GroupPosition, BloomGroup};
use util::{FixedHash, H256, H264, Database, DBTransaction};
use util::{H256, H264, Database, DBTransaction};
use header::BlockNumber;
use trace::{BlockTraces, LocalizedTrace, Config, Switch, Filter, Database as TraceDatabase, ImportRequest,
DatabaseExtras};

View File

@ -19,7 +19,6 @@
use util::hash::H256;
use header::BlockNumber;
use ipc::binary::BinaryConvertError;
use ipc::binary::BinaryConvertable;
use std::mem;
use std::collections::VecDeque;

View File

@ -33,7 +33,6 @@ use syntax::ast::{
use syntax::ast;
use syntax::codemap::Span;
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::ext::build::AstBuilder;
use syntax::ptr::P;
pub struct Error;

View File

@ -252,14 +252,14 @@ fn binary_expr_struct(
map_stmts.push(quote_stmt!(cx, map[$field_index] = total;).unwrap());
if ::syntax::print::pprust::ty_to_string(&codegen::strip_ptr(&field.ty)) == "u8" {
map_stmts.push(quote_stmt!(cx, total = total + 1;).unwrap());
map_stmts.push(quote_stmt!(cx, total += 1;).unwrap());
}
else {
map_stmts.push(quote_stmt!(cx, let size = match $field_type_ident_qualified::len_params() {
0 => mem::size_of::<$field_type_ident>(),
_ => length_stack.pop_front().unwrap(),
}).unwrap());
map_stmts.push(quote_stmt!(cx, total = total + size;).unwrap());
map_stmts.push(quote_stmt!(cx, total += size;).unwrap());
}
};

View File

@ -535,12 +535,12 @@ impl TransactionQueue {
/// Update height of all transactions in future transactions set.
fn update_future(&mut self, sender: &Address, current_nonce: U256) {
// We need to drain all transactions for current sender from future and reinsert them with updated height
let all_nonces_from_sender = match self.future.by_address.row(&sender) {
let all_nonces_from_sender = match self.future.by_address.row(sender) {
Some(row_map) => row_map.keys().cloned().collect::<Vec<U256>>(),
None => vec![],
};
for k in all_nonces_from_sender {
let order = self.future.drop(&sender, &k).unwrap();
let order = self.future.drop(sender, &k).unwrap();
if k >= current_nonce {
self.future.insert(*sender, k, order.update_height(k, current_nonce));
} else {
@ -554,14 +554,14 @@ impl TransactionQueue {
/// Drop all transactions from given sender from `current`.
/// Either moves them to `future` or removes them from queue completely.
fn move_all_to_future(&mut self, sender: &Address, current_nonce: U256) {
let all_nonces_from_sender = match self.current.by_address.row(&sender) {
let all_nonces_from_sender = match self.current.by_address.row(sender) {
Some(row_map) => row_map.keys().cloned().collect::<Vec<U256>>(),
None => vec![],
};
for k in all_nonces_from_sender {
// Goes to future or is removed
let order = self.current.drop(&sender, &k).unwrap();
let order = self.current.drop(sender, &k).unwrap();
if k >= current_nonce {
self.future.insert(*sender, k, order.update_height(k, current_nonce));
} else {
@ -803,7 +803,7 @@ mod test {
fn new_tx() -> SignedTransaction {
let keypair = KeyPair::create().unwrap();
new_unsigned_tx(U256::from(123)).sign(&keypair.secret())
new_unsigned_tx(U256::from(123)).sign(keypair.secret())
}
@ -1173,9 +1173,9 @@ mod test {
let mut txq = TransactionQueue::new();
let kp = KeyPair::create().unwrap();
let secret = kp.secret();
let tx = new_unsigned_tx(U256::from(123)).sign(&secret);
let tx1 = new_unsigned_tx(U256::from(124)).sign(&secret);
let tx2 = new_unsigned_tx(U256::from(125)).sign(&secret);
let tx = new_unsigned_tx(U256::from(123)).sign(secret);
let tx1 = new_unsigned_tx(U256::from(124)).sign(secret);
let tx2 = new_unsigned_tx(U256::from(125)).sign(secret);
txq.add(tx, &default_nonce, TransactionOrigin::External).unwrap();
assert_eq!(txq.status().pending, 1);
@ -1403,11 +1403,11 @@ mod test {
// given
let mut txq = TransactionQueue::new();
let keypair = KeyPair::create().unwrap();
let tx = new_unsigned_tx(U256::from(123)).sign(&keypair.secret());
let tx = new_unsigned_tx(U256::from(123)).sign(keypair.secret());
let tx2 = {
let mut tx2 = tx.deref().clone();
tx2.gas_price = U256::from(200);
tx2.sign(&keypair.secret())
tx2.sign(keypair.secret())
};
// when
@ -1426,16 +1426,16 @@ mod test {
// given
let mut txq = TransactionQueue::new();
let keypair = KeyPair::create().unwrap();
let tx0 = new_unsigned_tx(U256::from(123)).sign(&keypair.secret());
let tx0 = new_unsigned_tx(U256::from(123)).sign(keypair.secret());
let tx1 = {
let mut tx1 = tx0.deref().clone();
tx1.nonce = U256::from(124);
tx1.sign(&keypair.secret())
tx1.sign(keypair.secret())
};
let tx2 = {
let mut tx2 = tx1.deref().clone();
tx2.gas_price = U256::from(200);
tx2.sign(&keypair.secret())
tx2.sign(keypair.secret())
};
// when

View File

@ -171,7 +171,7 @@ impl Configuration {
let (listen, public) = self.net_addresses();
ret.listen_address = listen;
ret.public_address = public;
ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).unwrap_or_else(|_| s.sha3()));
ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(s).unwrap_or_else(|_| s.sha3()));
ret.discovery_enabled = !self.args.flag_no_discovery && !self.args.flag_nodiscover;
ret.ideal_peers = self.max_peers();
let mut net_path = PathBuf::from(&self.path());
@ -185,7 +185,7 @@ impl Configuration {
let mut latest_era = None;
let jdb_types = [journaldb::Algorithm::Archive, journaldb::Algorithm::EarlyMerge, journaldb::Algorithm::OverlayRecent, journaldb::Algorithm::RefCounted];
for i in jdb_types.into_iter() {
let db = journaldb::new(&append_path(&get_db_path(&Path::new(&self.path()), *i, spec.genesis_header().hash()), "state"), *i);
let db = journaldb::new(&append_path(&get_db_path(Path::new(&self.path()), *i, spec.genesis_header().hash()), "state"), *i);
trace!(target: "parity", "Looking for best DB: {} at {:?}", i, db.latest_era());
match (latest_era, db.latest_era()) {
(Some(best), Some(this)) if best >= this => {}
@ -251,7 +251,7 @@ impl Configuration {
let account_service = AccountService::with_security(Path::new(&self.keys_path()), self.keys_iterations());
if let Some(ref unlocks) = self.args.flag_unlock {
for d in unlocks.split(',') {
let a = Address::from_str(clean_0x(&d)).unwrap_or_else(|_| {
let a = Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d)
});
if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() {
@ -302,7 +302,7 @@ impl Configuration {
pub fn directories(&self) -> Directories {
let db_path = Configuration::replace_home(
&self.args.flag_datadir.as_ref().unwrap_or(&self.args.flag_db_path));
self.args.flag_datadir.as_ref().unwrap_or(&self.args.flag_db_path));
::std::fs::create_dir_all(&db_path).unwrap_or_else(|e| die_with_io_error("main", e));
let keys_path = Configuration::replace_home(&self.args.flag_keys_path);

View File

@ -18,7 +18,6 @@ use std::sync::{RwLock,Arc};
use std::ops::*;
use ipc::IpcConfig;
use std::collections::HashMap;
use ipc::BinaryConvertable;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;

View File

@ -138,7 +138,7 @@ fn execute_client(conf: Configuration) {
// Build client
let mut service = ClientService::start(
client_config, spec, net_settings, &Path::new(&conf.path())
client_config, spec, net_settings, Path::new(&conf.path())
).unwrap_or_else(|e| die_with_error("Client", e));
panic_handler.forward_from(&service);

View File

@ -37,7 +37,7 @@ impl PriceInfo {
.and_then(|json| json.find_path(&["result", "ethusd"])
.and_then(|obj| match *obj {
Json::String(ref s) => Some(PriceInfo {
ethusd: FromStr::from_str(&s).unwrap()
ethusd: FromStr::from_str(s).unwrap()
}),
_ => None
}))

View File

@ -31,7 +31,7 @@ pub fn setup_log(init: &Option<String>) -> Arc<RotatingLogger> {
if env::var("RUST_LOG").is_ok() {
let lvl = &env::var("RUST_LOG").unwrap();
levels.push_str(&lvl);
levels.push_str(lvl);
levels.push_str(",");
builder.parse(lvl);
}

View File

@ -87,7 +87,7 @@ fn upgrade_from_version(previous_version: &Version) -> Result<usize, Error> {
if upgrade_key.is_applicable(previous_version, &current_version) {
let upgrade_script = upgrades[upgrade_key];
try!(upgrade_script());
count = count + 1;
count += 1;
}
}
Ok(count)

View File

@ -791,8 +791,8 @@ impl ChainSync {
self.downloading_hashes.remove(&hash);
}
for b in &peer.asking_blocks {
self.downloading_headers.remove(&b);
self.downloading_bodies.remove(&b);
self.downloading_headers.remove(b);
self.downloading_bodies.remove(b);
}
peer.asking_blocks.clear();
}
@ -1255,7 +1255,7 @@ impl ChainSync {
self.send_packet(io, peer_id, NEW_BLOCK_PACKET, rlp);
self.peers.get_mut(&peer_id).unwrap().latest_hash = chain_info.best_block_hash.clone();
self.peers.get_mut(&peer_id).unwrap().latest_number = Some(chain_info.best_block_number);
sent = sent + 1;
sent += 1;
}
sent
}
@ -1271,7 +1271,7 @@ impl ChainSync {
// If we think peer is too far behind just send one latest hash
peer_best = last_parent.clone();
}
sent = sent + match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) {
sent += match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) {
Some(rlp) => {
{
let peer = self.peers.get_mut(&peer_id).unwrap();
@ -1668,7 +1668,7 @@ mod tests {
sync.propagate_new_hashes(&chain_info, &mut io);
let data = &io.queue[0].data.clone();
let result = sync.on_peer_new_hashes(&mut io, 0, &UntrustedRlp::new(&data));
let result = sync.on_peer_new_hashes(&mut io, 0, &UntrustedRlp::new(data));
assert!(result.is_ok());
}
@ -1686,7 +1686,7 @@ mod tests {
sync.propagate_blocks(&chain_info, &mut io);
let data = &io.queue[0].data.clone();
let result = sync.on_peer_new_block(&mut io, 0, &UntrustedRlp::new(&data));
let result = sync.on_peer_new_block(&mut io, 0, &UntrustedRlp::new(data));
assert!(result.is_ok());
}

View File

@ -70,7 +70,7 @@ impl<'c, K:'c, V:'c> Iterator for RangeIterator<'c, K, V> where K: Add<Output =
}
match self.collection.get(self.range) {
Some(&(ref k, ref vec)) => {
Some((*k, &vec))
Some((*k, vec))
},
None => None
}

View File

@ -16,7 +16,6 @@
use util::*;
use ethcore::client::{BlockChainClient, BlockId, EachBlockWith};
use io::SyncIo;
use chain::{SyncState};
use super::helpers::*;

View File

@ -147,7 +147,7 @@ impl TestNet {
let mut total_steps = 0;
while !self.done() {
self.sync_step();
total_steps = total_steps + 1;
total_steps += 1;
}
total_steps
}

View File

@ -16,7 +16,6 @@
//! HTTP Redirection hyper handler
use std::io::Write;
use hyper::{header, server, Decoder, Encoder, Next};
use hyper::net::HttpStream;
use hyper::status::StatusCode;