diff --git a/Cargo.lock b/Cargo.lock index 8405e32f7..d919ed94b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "parity" version = "1.4.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (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)", @@ -133,15 +133,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clippy" -version = "0.0.80" +version = "0.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clippy_lints 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy_lints 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clippy_lints" -version = "0.0.80" +version = "0.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -245,7 +245,7 @@ version = "1.4.0" dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (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.4.0", @@ -274,7 +274,7 @@ dependencies = [ name = "ethcore-dapps" version = "1.4.0" dependencies = [ - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.4.0", "ethcore-util 1.4.0", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", @@ -408,7 +408,7 @@ dependencies = [ name = "ethcore-rpc" version = "1.4.0" dependencies = [ - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.4.0", "ethcore 1.4.0", "ethcore-devtools 1.4.0", @@ -434,7 +434,7 @@ dependencies = [ name = "ethcore-signer" version = "1.4.0" dependencies = [ - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-io 1.4.0", "ethcore-rpc 1.4.0", @@ -454,7 +454,7 @@ dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 0.1.0", - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (git+https://github.com/ethcore/elastic-array)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)", @@ -525,7 +525,7 @@ dependencies = [ name = "ethsync" version = "1.4.0" dependencies = [ - "clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.82 (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.4.0", "ethcore-io 1.4.0", @@ -1601,8 +1601,8 @@ dependencies = [ "checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27" "checksum bytes 0.4.0-dev (git+https://github.com/carllerche/bytes)" = "" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" -"checksum clippy 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "e96469b413984c78285727f94f9c626a1f2006cecdcf813b5d6893c0c85df42f" -"checksum clippy_lints 0.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "f11938c4b10c556903bb1c1e717eb038658324bf7197e4cfc159a16417327345" +"checksum clippy 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "8be61845840f25e9abc06b930d1211c3207f3eb5db92bc001b0510b7e4f361aa" +"checksum clippy_lints 0.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "5de435cbb0abacae719e2424a5702afcdf6b51d99b4d52ed5de86094a30e0a80" "checksum cookie 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90266f45846f14a1e986c77d1e9c2626b8c342ed806fe60241ec38cc8697b245" "checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" "checksum ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)" = "" diff --git a/Cargo.toml b/Cargo.toml index 907e77792..6529bcce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ ethcore-ipc-hypervisor = { path = "ipc/hypervisor" } ethcore-logger = { path = "logger" } json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } ethcore-dapps = { path = "dapps", optional = true } -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} [target.'cfg(windows)'.dependencies] winapi = "0.2" diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index 9a9f02e03..13b524f73 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -27,7 +27,7 @@ parity-dapps-status = { git = "https://github.com/ethcore/parity-ui.git", versio parity-dapps-home = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4" } parity-dapps-wallet = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4", optional = true } mime_guess = { version = "1.6.1" } -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/db/Cargo.toml b/db/Cargo.toml index 0cba4f5f6..edbbbaad1 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -12,7 +12,7 @@ syntex = "*" ethcore-ipc-codegen = { path = "../ipc/codegen" } [dependencies] -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} ethcore-devtools = { path = "../devtools" } ethcore-ipc = { path = "../ipc/rpc" } rocksdb = { git = "https://github.com/ethcore/rust-rocksdb" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 0fa55bf1c..46496ffa0 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -25,7 +25,7 @@ semver = "0.2" bit-set = "0.4" time = "0.1" evmjit = { path = "../evmjit", optional = true } -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} ethash = { path = "../ethash" } ethcore-util = { path = "../util" } ethcore-io = { path = "../util/io" } diff --git a/ethcore/src/account_provider.rs b/ethcore/src/account_provider.rs index 56e5451ed..c2379d09e 100644 --- a/ethcore/src/account_provider.rs +++ b/ethcore/src/account_provider.rs @@ -117,8 +117,8 @@ impl AddressBook { pub fn set_name(&mut self, a: Address, name: String) { let mut x = self.cache.get(&a) - .map(|a| a.clone()) - .unwrap_or(AccountMeta {name: Default::default(), meta: "{}".to_owned(), uuid: None}); + .cloned() + .unwrap_or_else(|| AccountMeta {name: Default::default(), meta: "{}".to_owned(), uuid: None}); x.name = name; self.cache.insert(a, x); self.save(); @@ -126,8 +126,8 @@ impl AddressBook { pub fn set_meta(&mut self, a: Address, meta: String) { let mut x = self.cache.get(&a) - .map(|a| a.clone()) - .unwrap_or(AccountMeta {name: "Anonymous".to_owned(), meta: Default::default(), uuid: None}); + .cloned() + .unwrap_or_else(|| AccountMeta {name: "Anonymous".to_owned(), meta: Default::default(), uuid: None}); x.meta = meta; self.cache.insert(a, x); self.save(); @@ -231,7 +231,7 @@ impl AccountProvider { pub fn accounts_info(&self) -> Result, Error> { let r: HashMap = try!(self.sstore.accounts()) .into_iter() - .map(|a| (a.clone(), self.account_meta(a).unwrap_or_else(|_| Default::default()))) + .map(|a| (a.clone(), self.account_meta(a).ok().unwrap_or_default())) .collect(); Ok(r) } diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index e87e5e450..3591fee05 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -352,11 +352,11 @@ impl<'x> OpenBlock<'x> { let unclosed_state = s.block.state.clone(); s.engine.on_close_block(&mut s.block); - s.block.base.header.transactions_root = ordered_trie_root(s.block.base.transactions.iter().map(|ref e| e.rlp_bytes().to_vec()).collect()); + s.block.base.header.transactions_root = ordered_trie_root(s.block.base.transactions.iter().map(|e| e.rlp_bytes().to_vec()).collect()); let uncle_bytes = s.block.base.uncles.iter().fold(RlpStream::new_list(s.block.base.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); s.block.base.header.uncles_hash = uncle_bytes.sha3(); s.block.base.header.state_root = s.block.state.root().clone(); - s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect()); + s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()).collect()); s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); //TODO: use |= operator s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used); s.block.base.header.note_dirty(); @@ -375,14 +375,14 @@ impl<'x> OpenBlock<'x> { s.engine.on_close_block(&mut s.block); if s.block.base.header.transactions_root.is_zero() || s.block.base.header.transactions_root == SHA3_NULL_RLP { - s.block.base.header.transactions_root = ordered_trie_root(s.block.base.transactions.iter().map(|ref e| e.rlp_bytes().to_vec()).collect()); + s.block.base.header.transactions_root = ordered_trie_root(s.block.base.transactions.iter().map(|e| e.rlp_bytes().to_vec()).collect()); } let uncle_bytes = s.block.base.uncles.iter().fold(RlpStream::new_list(s.block.base.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); if s.block.base.header.uncles_hash.is_zero() { s.block.base.header.uncles_hash = uncle_bytes.sha3(); } if s.block.base.header.receipts_root.is_zero() || s.block.base.header.receipts_root == SHA3_NULL_RLP { - s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect()); + s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()).collect()); } s.block.base.header.state_root = s.block.state.root().clone(); s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); //TODO: use |= operator diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 6879ff551..5c9d2c5fe 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -28,6 +28,8 @@ #![cfg_attr(feature="dev", allow(clone_on_copy))] // Complains on Box when implementing From> #![cfg_attr(feature="dev", allow(boxed_local))] +// Complains about nested modules with same name as parent +#![cfg_attr(feature="dev", allow(module_inception))] // TODO [todr] a lot of warnings to be fixed #![cfg_attr(feature="dev", allow(assign_op_pattern))] diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index f4bc39416..c7c1ef370 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -376,7 +376,7 @@ impl Miner { (work, is_new) }; if is_new { - work.map(|(pow_hash, difficulty, number)| self.work_poster.as_ref().map(|ref p| p.notify(pow_hash, difficulty, number))); + work.map(|(pow_hash, difficulty, number)| self.work_poster.as_ref().map(|p| p.notify(pow_hash, difficulty, number))); } } diff --git a/ethcore/src/state.rs b/ethcore/src/state.rs index 612e5fe3d..e39824788 100644 --- a/ethcore/src/state.rs +++ b/ethcore/src/state.rs @@ -320,7 +320,7 @@ impl State { } fn query_pod(&mut self, query: &PodState) { - for (ref address, ref pod_account) in query.get() { + for (address, pod_account) in query.get() { self.ensure_cached(address, true, |a| { if a.is_some() { for key in pod_account.storage.keys() { diff --git a/json/Cargo.toml b/json/Cargo.toml index e29d0d6ac..cd26b3fa3 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.80", optional = true} +clippy = { version = "0.0.82", optional = true} [build-dependencies] serde_codegen = { version = "0.7.0", optional = true } diff --git a/parity/configuration.rs b/parity/configuration.rs index ccf1386f3..908dcb954 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -390,7 +390,7 @@ impl Configuration { fn extra_data(&self) -> Result { match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) { - Some(ref x) if x.len() <= 32 => Ok(x.as_bytes().to_owned()), + Some(x) if x.len() <= 32 => Ok(x.as_bytes().to_owned()), None => Ok(version_data()), Some(_) => Err("Extra data must be at most 32 characters".into()), } diff --git a/parity/presale.rs b/parity/presale.rs index 51d9cd37f..098832428 100644 --- a/parity/presale.rs +++ b/parity/presale.rs @@ -38,6 +38,6 @@ pub fn execute(cmd: ImportWallet) -> Result { let acc_provider = AccountProvider::new(secret_store); let wallet = try!(PresaleWallet::open(cmd.wallet_path).map_err(|_| "Unable to open presale wallet.")); let kp = try!(wallet.decrypt(&password).map_err(|_| "Invalid password.")); - let address = acc_provider.insert_account(kp.secret().clone(), &password).unwrap(); + let address = acc_provider.insert_account(*kp.secret(), &password).unwrap(); Ok(format!("{:?}", address)) } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index e4d6e1061..8a3df0623 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -25,7 +25,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.80", optional = true} +clippy = { version = "0.0.82", optional = true} json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } ethcore-ipc = { path = "../ipc/rpc" } diff --git a/signer/Cargo.toml b/signer/Cargo.toml index a0ef89dbc..ac9496421 100644 --- a/signer/Cargo.toml +++ b/signer/Cargo.toml @@ -21,7 +21,7 @@ ethcore-io = { path = "../util/io" } ethcore-rpc = { path = "../rpc" } parity-dapps-signer = { git = "https://github.com/ethcore/parity-ui.git", version = "1.4", optional = true} -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} [features] dev = ["clippy"] diff --git a/sync/Cargo.toml b/sync/Cargo.toml index 3c296cd8e..2b3ce16e2 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -16,7 +16,7 @@ ethcore-util = { path = "../util" } ethcore-network = { path = "../util/network" } ethcore-io = { path = "../util/io" } ethcore = { path = "../ethcore" } -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} log = "0.3" env_logger = "0.3" time = "0.1.34" diff --git a/util/Cargo.toml b/util/Cargo.toml index 04c05ca63..13d8229eb 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -22,7 +22,7 @@ elastic-array = { git = "https://github.com/ethcore/elastic-array" } heapsize = { version = "0.3", features = ["unstable"] } itertools = "0.4" sha3 = { path = "sha3" } -clippy = { version = "0.0.80", optional = true} +clippy = { version = "0.0.82", optional = true} ethcore-devtools = { path = "../devtools" } libc = "0.2.7" vergen = "0.1" diff --git a/util/src/journaldb/overlayrecentdb.rs b/util/src/journaldb/overlayrecentdb.rs index 5143b9999..20ededcc9 100644 --- a/util/src/journaldb/overlayrecentdb.rs +++ b/util/src/journaldb/overlayrecentdb.rs @@ -218,7 +218,7 @@ impl JournalDB for OverlayRecentDB { let journal_overlay = self.journal_overlay.read(); let key = to_short_key(key); journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec()) - .or_else(|| journal_overlay.pending_overlay.get(&key).map(|v| v.clone())) + .or_else(|| journal_overlay.pending_overlay.get(&key).cloned()) .or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.to_vec())) } @@ -365,7 +365,7 @@ impl HashDB for OverlayRecentDB { let journal_overlay = self.journal_overlay.read(); let key = to_short_key(key); journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec()) - .or_else(|| journal_overlay.pending_overlay.get(&key).map(|v| v.clone())) + .or_else(|| journal_overlay.pending_overlay.get(&key).cloned()) }; match v { Some(x) => { diff --git a/util/src/lib.rs b/util/src/lib.rs index e6de4f977..91c4e7d50 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -27,6 +27,8 @@ #![cfg_attr(feature="dev", allow(match_same_arms))] // Keeps consistency (all lines with `.clone()`). #![cfg_attr(feature="dev", allow(clone_on_copy))] +// Some false positives when doing pattern matching. +#![cfg_attr(feature="dev", allow(needless_borrow))] // TODO [todr] a lot of warnings to be fixed #![cfg_attr(feature="dev", allow(assign_op_pattern))] diff --git a/util/src/trie/node.rs b/util/src/trie/node.rs index e91e243f7..8e1c55c73 100644 --- a/util/src/trie/node.rs +++ b/util/src/trie/node.rs @@ -73,7 +73,7 @@ impl<'a> Node<'a> { stream.append(value); stream.out() }, - Node::Extension(ref slice, ref raw_rlp) => { + Node::Extension(ref slice, raw_rlp) => { let mut stream = RlpStream::new_list(2); stream.append(&slice.encoded(false)); stream.append_raw(raw_rlp, 1); @@ -108,7 +108,7 @@ impl<'a> Node<'a> { stream.append(&slice.encoded(true)); stream.append(value); }, - Node::Extension(ref slice, ref raw_rlp) => { + Node::Extension(ref slice, raw_rlp) => { stream.begin_list(2); stream.append(&slice.encoded(false)); stream.append_raw(raw_rlp, 1); diff --git a/util/src/trie/triedb.rs b/util/src/trie/triedb.rs index ec0d9a59f..33f2cc4fc 100644 --- a/util/src/trie/triedb.rs +++ b/util/src/trie/triedb.rs @@ -153,7 +153,7 @@ impl<'db> TrieDB<'db> { fn fmt_all(&self, node: Node, f: &mut fmt::Formatter, deepness: usize) -> fmt::Result { match node { Node::Leaf(slice, value) => try!(writeln!(f, "'{:?}: {:?}.", slice, value.pretty())), - Node::Extension(ref slice, ref item) => { + Node::Extension(ref slice, item) => { try!(write!(f, "'{:?} ", slice)); if let Ok(node) = self.get_node(item) { try!(self.fmt_all(node, f, deepness)); @@ -203,8 +203,8 @@ impl<'db> TrieDB<'db> { where 'db: 'key { match Node::decoded(node) { - Node::Leaf(ref slice, ref value) if key == slice => Ok(Some(value)), - Node::Extension(ref slice, ref item) if key.starts_with(slice) => { + Node::Leaf(ref slice, value) if key == slice => Ok(Some(value)), + Node::Extension(ref slice, item) if key.starts_with(slice) => { let data = try!(self.get_raw_or_lookup(item)); self.get_from_node(data, &key.mid(slice.len())) }, diff --git a/util/src/trie/triedbmut.rs b/util/src/trie/triedbmut.rs index d560a0ecf..ca5fb015f 100644 --- a/util/src/trie/triedbmut.rs +++ b/util/src/trie/triedbmut.rs @@ -419,8 +419,8 @@ impl<'a> TrieDBMut<'a> { where 'x: 'key { match RlpNode::decoded(node) { - RlpNode::Leaf(ref slice, ref value) if &key == slice => Ok(Some(value)), - RlpNode::Extension(ref slice, ref item) if key.starts_with(slice) => { + RlpNode::Leaf(ref slice, value) if &key == slice => Ok(Some(value)), + RlpNode::Extension(ref slice, item) if key.starts_with(slice) => { self.get_from_db_node(try!(self.get_raw_or_lookup(item)), key.mid(slice.len())) }, RlpNode::Branch(ref nodes, value) => match key.is_empty() {