From ae2deaaf72b5418b56c35d6ba84239841d2055e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 3 Jun 2016 11:15:38 +0200 Subject: [PATCH 1/2] Bumping clippy version --- Cargo.lock | 31 +++++++++++++++++++++++-------- Cargo.toml | 2 +- dapps/Cargo.toml | 2 +- ethcore/Cargo.toml | 2 +- json/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- signer/Cargo.toml | 2 +- sync/Cargo.toml | 2 +- util/Cargo.toml | 2 +- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 723bca872..30cc49392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "parity" version = "1.2.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,11 +130,26 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.69" +version = "0.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clippy_lints 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", + "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clippy_lints" +version = "0.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -241,7 +256,7 @@ name = "ethcore" version = "1.2.0" dependencies = [ "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.2.0", @@ -265,7 +280,7 @@ dependencies = [ name = "ethcore-dapps" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)", @@ -328,7 +343,7 @@ dependencies = [ name = "ethcore-rpc" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.2.0", "ethcore 1.2.0", "ethcore-devtools 1.2.0", @@ -351,7 +366,7 @@ dependencies = [ name = "ethcore-signer" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", "ethcore-util 1.2.0", @@ -368,7 +383,7 @@ dependencies = [ "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 0.1.0", "chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -413,7 +428,7 @@ dependencies = [ name = "ethsync" version = "1.2.0" dependencies = [ - "clippy 0.0.69 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.2.0", "ethcore-util 1.2.0", diff --git a/Cargo.toml b/Cargo.toml index ce8823bd2..81deea136 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ daemonize = "0.2" num_cpus = "0.2" number_prefix = "0.2" rpassword = "0.2.1" -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} ethcore = { path = "ethcore" } ethcore-util = { path = "util" } ethsync = { path = "sync" } diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index 219904b4c..774c49de0 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -27,7 +27,7 @@ parity-dapps-builtins = { git = "https://github.com/ethcore/parity-dapps-builtin parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs.git", version = "0.5.0", optional = true } parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.3.0", optional = true } parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.2.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 1de24ee32..d558c902d 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -22,7 +22,7 @@ ethcore-util = { path = "../util" } evmjit = { path = "../evmjit", optional = true } ethash = { path = "../ethash" } num_cpus = "0.2" -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} crossbeam = "0.2.9" lazy_static = "0.1" ethcore-devtools = { path = "../devtools" } diff --git a/json/Cargo.toml b/json/Cargo.toml index 9c024c633..21327d284 100644 --- a/json/Cargo.toml +++ b/json/Cargo.toml @@ -10,7 +10,7 @@ rustc-serialize = "0.3" serde = "0.7.0" serde_json = "0.7.0" serde_macros = { version = "0.7.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 2dbefd7f4..ffc0272a0 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" } rustc-serialize = "0.3" transient-hashmap = "0.1" serde_macros = { version = "0.7.0", optional = true } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } [build-dependencies] diff --git a/signer/Cargo.toml b/signer/Cargo.toml index 170c9320e..2efc4bb9c 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -18,7 +18,7 @@ ws = "0.4.7" ethcore-util = { path = "../util" } ethcore-rpc = { path = "../rpc" } -clippy = { version = "0.0.69", optional = true} +clippy = { version = "0.0.71", optional = true} [features] dev = ["clippy"] diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 1b80e23fc..8c5b4c926 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Ethcore Date: Fri, 3 Jun 2016 11:36:30 +0200 Subject: [PATCH 2/2] Fixing warnings --- ethcore/src/evm/interpreter.rs | 1 - ethcore/src/executive.rs | 14 ++++++------ ethcore/src/trace/executive_tracer.rs | 6 ++--- ethcore/src/trace/mod.rs | 2 +- ethcore/src/trace/noop_tracer.rs | 2 +- parity/hypervisor/service.rs.in | 1 - sync/src/chain.rs | 19 +++++++-------- sync/src/lib.rs | 1 + util/src/hash.rs | 20 ++++++++-------- util/src/network/discovery.rs | 9 ++++---- util/src/network/host.rs | 33 ++++++++++++--------------- 11 files changed, 53 insertions(+), 55 deletions(-) diff --git a/ethcore/src/evm/interpreter.rs b/ethcore/src/evm/interpreter.rs index 1514b3e2e..5b97b66af 100644 --- a/ethcore/src/evm/interpreter.rs +++ b/ethcore/src/evm/interpreter.rs @@ -17,7 +17,6 @@ ///! Rust VM implementation use common::*; -use trace::VMTracer; use super::instructions as instructions; use super::instructions::{Instruction, get_info}; use std::marker::Copy; diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 43864ee9e..f7615be09 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -81,14 +81,14 @@ impl<'a> Executive<'a> { } /// Creates `Externalities` from `Executive`. - pub fn as_externalities<'_, T, V>( - &'_ mut self, + pub fn as_externalities<'any, T, V>( + &'any mut self, origin_info: OriginInfo, - substate: &'_ mut Substate, - output: OutputPolicy<'_, '_>, - tracer: &'_ mut T, - vm_tracer: &'_ mut V - ) -> Externalities<'_, T, V> where T: Tracer, V: VMTracer { + substate: &'any mut Substate, + output: OutputPolicy<'any, 'any>, + tracer: &'any mut T, + vm_tracer: &'any mut V + ) -> Externalities<'any, T, V> where T: Tracer, V: VMTracer { Externalities::new(self.state, self.info, self.engine, self.vm_factory, self.depth, origin_info, substate, output, tracer, vm_tracer) } diff --git a/ethcore/src/trace/executive_tracer.rs b/ethcore/src/trace/executive_tracer.rs index a1a13cf43..ff7c6a62f 100644 --- a/ethcore/src/trace/executive_tracer.rs +++ b/ethcore/src/trace/executive_tracer.rs @@ -117,7 +117,7 @@ impl VMTracer for ExecutiveVMTracer { self.data.operations.push(VMOperation { pc: pc, instruction: instruction, - gas_cost: gas_cost.clone(), + gas_cost: gas_cost.clone(), executed: None, }); true @@ -133,10 +133,10 @@ impl VMTracer for ExecutiveVMTracer { self.data.operations.last_mut().expect("trace_executed is always called after a trace_prepare_execute").executed = Some(ex); } - fn prepare_subtrace(&self, code: &Bytes) -> Self { + fn prepare_subtrace(&self, code: &[u8]) -> Self { ExecutiveVMTracer { data: VMTrace { parent_step: self.data.operations.len(), - code: code.clone(), + code: code.to_vec(), operations: vec![], subs: vec![], }} diff --git a/ethcore/src/trace/mod.rs b/ethcore/src/trace/mod.rs index 53c062137..8f6c0b3f6 100644 --- a/ethcore/src/trace/mod.rs +++ b/ethcore/src/trace/mod.rs @@ -98,7 +98,7 @@ pub trait VMTracer: Send { fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} /// Spawn subtracer which will be used to trace deeper levels of execution. - fn prepare_subtrace(&self, code: &Bytes) -> Self where Self: Sized; + fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized; /// Spawn subtracer which will be used to trace deeper levels of execution. fn done_subtrace(&mut self, sub: Self) where Self: Sized; diff --git a/ethcore/src/trace/noop_tracer.rs b/ethcore/src/trace/noop_tracer.rs index ed0231b79..b6e6ca9fd 100644 --- a/ethcore/src/trace/noop_tracer.rs +++ b/ethcore/src/trace/noop_tracer.rs @@ -75,7 +75,7 @@ impl VMTracer for NoopVMTracer { fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem_diff: Option<(usize, &[u8])>, _store_diff: Option<(U256, U256)>) {} /// Spawn subtracer which will be used to trace deeper levels of execution. - fn prepare_subtrace(&self, _code: &Bytes) -> Self { NoopVMTracer } + fn prepare_subtrace(&self, _code: &[u8]) -> Self { NoopVMTracer } /// Spawn subtracer which will be used to trace deeper levels of execution. fn done_subtrace(&mut self, _sub: Self) {} diff --git a/parity/hypervisor/service.rs.in b/parity/hypervisor/service.rs.in index 12c39d90a..134194603 100644 --- a/parity/hypervisor/service.rs.in +++ b/parity/hypervisor/service.rs.in @@ -15,7 +15,6 @@ // along with Parity. If not, see . use std::sync::{RwLock,Arc}; -use std::ops::*; use ipc::IpcConfig; use std::collections::HashMap; use std::mem; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 47c035daa..277be7fea 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -918,7 +918,7 @@ impl ChainSync { let skip: usize = try!(r.val_at(2)); let reverse: bool = try!(r.val_at(3)); let last = io.chain().chain_info().best_block_number; - let mut number = if try!(r.at(0)).size() == 32 { + let number = if try!(r.at(0)).size() == 32 { // id is a hash let hash: H256 = try!(r.val_at(0)); trace!(target: "sync", "-> GetBlockHeaders (hash: {}, max: {}, skip: {}, reverse:{})", hash, max_headers, skip, reverse); @@ -931,11 +931,11 @@ impl ChainSync { try!(r.val_at(0)) }; - if reverse { - number = min(last, number); + let mut number = if reverse { + min(last, number) } else { - number = max(0, number); - } + max(0, number) + }; let max_count = min(MAX_HEADERS_TO_SEND, max_headers); let mut count = 0; let mut data = Bytes::new(); @@ -1188,11 +1188,12 @@ impl ChainSync { let mut sent = 0; let last_parent = HeaderView::new(&io.chain().block_header(BlockID::Hash(chain_info.best_block_hash.clone())).unwrap()).parent_hash(); for (peer_id, peer_number) in lucky_peers { - let mut peer_best = self.peers.get(&peer_id).unwrap().latest_hash.clone(); - if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber { + let peer_best = if chain_info.best_block_number - peer_number > MAX_PEER_LAG_PROPAGATION as BlockNumber { // If we think peer is too far behind just send one latest hash - peer_best = last_parent.clone(); - } + last_parent.clone() + } else { + self.peers.get(&peer_id).unwrap().latest_hash.clone() + }; sent += match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &chain_info.best_block_hash) { Some(rlp) => { { diff --git a/sync/src/lib.rs b/sync/src/lib.rs index 9f69bb7da..9c7da71ab 100644 --- a/sync/src/lib.rs +++ b/sync/src/lib.rs @@ -162,6 +162,7 @@ impl NetworkProtocolHandler for EthSync { self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref())); } + #[cfg_attr(feature="dev", allow(single_match))] fn message(&self, io: &NetworkContext, message: &SyncMessage) { match *message { SyncMessage::NewChainBlocks { ref imported, ref invalid, ref enacted, ref retracted } => { diff --git a/util/src/hash.rs b/util/src/hash.rs index 1a16cefa4..acb4c5cc5 100644 --- a/util/src/hash.rs +++ b/util/src/hash.rs @@ -501,8 +501,8 @@ macro_rules! impl_hash { } } - impl<'_> From<&'_ str> for $from { - fn from(s: &'_ str) -> $from { + impl<'a> From<&'a str> for $from { + fn from(s: &'a str) -> $from { use std::str::FromStr; if s.len() % 2 == 1 { $from::from_str(&("0".to_owned() + &(clean_0x(s).to_owned()))[..]).unwrap_or_else(|_| $from::new()) @@ -524,8 +524,8 @@ impl From for H256 { } } -impl<'_> From<&'_ U256> for H256 { - fn from(value: &'_ U256) -> H256 { +impl<'a> From<&'a U256> for H256 { + fn from(value: &'a U256) -> H256 { unsafe { let mut ret: H256 = ::std::mem::uninitialized(); value.to_raw_bytes(&mut ret); @@ -540,8 +540,8 @@ impl From for U256 { } } -impl<'_> From<&'_ H256> for U256 { - fn from(value: &'_ H256) -> U256 { +impl<'a> From<&'a H256> for U256 { + fn from(value: &'a H256) -> U256 { U256::from(value.bytes()) } } @@ -566,8 +566,8 @@ impl From for H64 { } } /* -impl<'_> From<&'_ H256> for Address { - fn from(value: &'_ H256) -> Address { +impl<'a> From<&'a H256> for Address { + fn from(value: &'a H256) -> Address { unsafe { let mut ret: Address = ::std::mem::uninitialized(); ::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20); @@ -586,8 +586,8 @@ impl From
for H256 { } } -impl<'_> From<&'_ Address> for H256 { - fn from(value: &'_ Address) -> H256 { +impl<'a> From<&'a Address> for H256 { + fn from(value: &'a Address) -> H256 { unsafe { let mut ret = H256::new(); ::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20); diff --git a/util/src/network/discovery.rs b/util/src/network/discovery.rs index d65309246..b67110538 100644 --- a/util/src/network/discovery.rs +++ b/util/src/network/discovery.rs @@ -494,10 +494,11 @@ impl Discovery { } pub fn update_registration(&self, event_loop: &mut EventLoop) -> Result<(), NetworkError> { - let mut registration = EventSet::readable(); - if !self.send_queue.is_empty() { - registration = registration | EventSet::writable(); - } + let registration = if !self.send_queue.is_empty() { + EventSet::readable() | EventSet::writable() + } else { + EventSet::readable() + }; event_loop.reregister(&self.udp_socket, Token(self.token), registration, PollOpt::edge()).expect("Error reregistering UDP socket"); Ok(()) } diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 92a912a40..fe139e383 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -712,28 +712,25 @@ impl Host where Message: Send + Sync + Clone { let mut failure_id = None; let mut deregister = false; let mut expired_session = None; - match token { - FIRST_SESSION ... LAST_SESSION => { - let sessions = self.sessions.write().unwrap(); - if let Some(session) = sessions.get(token).cloned() { - expired_session = Some(session.clone()); - let mut s = session.lock().unwrap(); - if !s.expired() { - if s.is_ready() { - for (p, _) in self.handlers.read().unwrap().iter() { - if s.have_capability(p) { - self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst); - to_disconnect.push(p); - } + if let FIRST_SESSION ... LAST_SESSION = token { + let sessions = self.sessions.write().unwrap(); + if let Some(session) = sessions.get(token).cloned() { + expired_session = Some(session.clone()); + let mut s = session.lock().unwrap(); + if !s.expired() { + if s.is_ready() { + for (p, _) in self.handlers.read().unwrap().iter() { + if s.have_capability(p) { + self.num_sessions.fetch_sub(1, AtomicOrdering::SeqCst); + to_disconnect.push(p); } } - s.set_expired(); - failure_id = s.id().cloned(); } - deregister = remote || s.done(); + s.set_expired(); + failure_id = s.id().cloned(); } - }, - _ => {}, + deregister = remote || s.done(); + } } if let Some(id) = failure_id { if remote {