Merge pull request #435 from ethcore/clippy_warnings
Fixing clippy warnings
This commit is contained in:
commit
d62d78a0fc
@ -24,6 +24,7 @@ pub type LogBloom = H2048;
|
|||||||
/// Constant 2048-bit datum for 0. Often used as a default.
|
/// Constant 2048-bit datum for 0. Often used as a default.
|
||||||
pub static ZERO_LOGBLOOM: LogBloom = H2048([0x00; 256]);
|
pub static ZERO_LOGBLOOM: LogBloom = H2048([0x00; 256]);
|
||||||
|
|
||||||
|
#[allow(enum_variant_names)]
|
||||||
/// Semantic boolean for when a seal/signature is included.
|
/// Semantic boolean for when a seal/signature is included.
|
||||||
pub enum Seal {
|
pub enum Seal {
|
||||||
/// The seal/signature is included.
|
/// The seal/signature is included.
|
||||||
|
@ -87,6 +87,7 @@ struct QueueSignal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl QueueSignal {
|
impl QueueSignal {
|
||||||
|
#[allow(bool_comparison)]
|
||||||
fn set(&self) {
|
fn set(&self) {
|
||||||
if self.signalled.compare_and_swap(false, true, AtomicOrdering::Relaxed) == false {
|
if self.signalled.compare_and_swap(false, true, AtomicOrdering::Relaxed) == false {
|
||||||
self.message_channel.send(UserMessage(SyncMessage::BlockVerified)).expect("Error sending BlockVerified message");
|
self.message_channel.send(UserMessage(SyncMessage::BlockVerified)).expect("Error sending BlockVerified message");
|
||||||
|
@ -258,6 +258,7 @@ impl<'a> CodeReader<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(enum_variant_names)]
|
||||||
enum InstructionCost {
|
enum InstructionCost {
|
||||||
Gas(U256),
|
Gas(U256),
|
||||||
GasMem(U256, U256),
|
GasMem(U256, U256),
|
||||||
@ -282,7 +283,7 @@ impl evm::Evm for Interpreter {
|
|||||||
let code = ¶ms.code.as_ref().unwrap();
|
let code = ¶ms.code.as_ref().unwrap();
|
||||||
let valid_jump_destinations = self.find_jump_destinations(&code);
|
let valid_jump_destinations = self.find_jump_destinations(&code);
|
||||||
|
|
||||||
let mut current_gas = params.gas.clone();
|
let mut current_gas = params.gas;
|
||||||
let mut stack = VecStack::with_capacity(ext.schedule().stack_limit, U256::zero());
|
let mut stack = VecStack::with_capacity(ext.schedule().stack_limit, U256::zero());
|
||||||
let mut mem = vec![];
|
let mut mem = vec![];
|
||||||
let mut reader = CodeReader {
|
let mut reader = CodeReader {
|
||||||
@ -380,10 +381,9 @@ impl Interpreter {
|
|||||||
|
|
||||||
let gas = if self.is_zero(&val) && !self.is_zero(newval) {
|
let gas = if self.is_zero(&val) && !self.is_zero(newval) {
|
||||||
schedule.sstore_set_gas
|
schedule.sstore_set_gas
|
||||||
} else if !self.is_zero(&val) && self.is_zero(newval) {
|
|
||||||
// Refund is added when actually executing sstore
|
|
||||||
schedule.sstore_reset_gas
|
|
||||||
} else {
|
} else {
|
||||||
|
// Refund for below case is added when actually executing sstore
|
||||||
|
// !self.is_zero(&val) && self.is_zero(newval)
|
||||||
schedule.sstore_reset_gas
|
schedule.sstore_reset_gas
|
||||||
};
|
};
|
||||||
InstructionCost::Gas(U256::from(gas))
|
InstructionCost::Gas(U256::from(gas))
|
||||||
@ -406,10 +406,7 @@ impl Interpreter {
|
|||||||
let gas = U256::from(schedule.sha3_gas) + (U256::from(schedule.sha3_word_gas) * words);
|
let gas = U256::from(schedule.sha3_gas) + (U256::from(schedule.sha3_word_gas) * words);
|
||||||
InstructionCost::GasMem(gas, try!(self.mem_needed(stack.peek(0), stack.peek(1))))
|
InstructionCost::GasMem(gas, try!(self.mem_needed(stack.peek(0), stack.peek(1))))
|
||||||
},
|
},
|
||||||
instructions::CALLDATACOPY => {
|
instructions::CALLDATACOPY | instructions::CODECOPY => {
|
||||||
InstructionCost::GasMemCopy(default_gas, try!(self.mem_needed(stack.peek(0), stack.peek(2))), stack.peek(2).clone())
|
|
||||||
},
|
|
||||||
instructions::CODECOPY => {
|
|
||||||
InstructionCost::GasMemCopy(default_gas, try!(self.mem_needed(stack.peek(0), stack.peek(2))), stack.peek(2).clone())
|
InstructionCost::GasMemCopy(default_gas, try!(self.mem_needed(stack.peek(0), stack.peek(2))), stack.peek(2).clone())
|
||||||
},
|
},
|
||||||
instructions::EXTCODECOPY => {
|
instructions::EXTCODECOPY => {
|
||||||
@ -978,9 +975,9 @@ impl Interpreter {
|
|||||||
let (a, neg_a) = get_and_reset_sign(stack.pop_back());
|
let (a, neg_a) = get_and_reset_sign(stack.pop_back());
|
||||||
let (b, neg_b) = get_and_reset_sign(stack.pop_back());
|
let (b, neg_b) = get_and_reset_sign(stack.pop_back());
|
||||||
|
|
||||||
let is_positive_lt = a < b && (neg_a | neg_b) == false;
|
let is_positive_lt = a < b && !(neg_a | neg_b);
|
||||||
let is_negative_lt = a > b && (neg_a & neg_b) == true;
|
let is_negative_lt = a > b && (neg_a & neg_b);
|
||||||
let has_different_signs = neg_a == true && neg_b == false;
|
let has_different_signs = neg_a && !neg_b;
|
||||||
|
|
||||||
stack.push(self.bool_to_u256(is_positive_lt | is_negative_lt | has_different_signs));
|
stack.push(self.bool_to_u256(is_positive_lt | is_negative_lt | has_different_signs));
|
||||||
},
|
},
|
||||||
@ -993,9 +990,9 @@ impl Interpreter {
|
|||||||
let (a, neg_a) = get_and_reset_sign(stack.pop_back());
|
let (a, neg_a) = get_and_reset_sign(stack.pop_back());
|
||||||
let (b, neg_b) = get_and_reset_sign(stack.pop_back());
|
let (b, neg_b) = get_and_reset_sign(stack.pop_back());
|
||||||
|
|
||||||
let is_positive_gt = a > b && (neg_a | neg_b) == false;
|
let is_positive_gt = a > b && !(neg_a | neg_b);
|
||||||
let is_negative_gt = a < b && (neg_a & neg_b) == true;
|
let is_negative_gt = a < b && (neg_a & neg_b);
|
||||||
let has_different_signs = neg_a == false && neg_b == true;
|
let has_different_signs = !neg_a && neg_b;
|
||||||
|
|
||||||
stack.push(self.bool_to_u256(is_positive_gt | is_negative_gt | has_different_signs));
|
stack.push(self.bool_to_u256(is_positive_gt | is_negative_gt | has_different_signs));
|
||||||
},
|
},
|
||||||
|
@ -25,6 +25,7 @@ struct FakeLogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
|
#[allow(enum_variant_names)] // Common prefix is C ;)
|
||||||
enum FakeCallType {
|
enum FakeCallType {
|
||||||
CALL, CREATE
|
CALL, CREATE
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ mod tests {
|
|||||||
&Address::new(),
|
&Address::new(),
|
||||||
&Address::new(),
|
&Address::new(),
|
||||||
Some(U256::from_str("0000000000000000000000000000000000000000000000000000000000150000").unwrap()),
|
Some(U256::from_str("0000000000000000000000000000000000000000000000000000000000150000").unwrap()),
|
||||||
&vec![],
|
&[],
|
||||||
&Address::new(),
|
&Address::new(),
|
||||||
&mut output);
|
&mut output);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,15 @@
|
|||||||
#![feature(cell_extras)]
|
#![feature(cell_extras)]
|
||||||
#![feature(augmented_assignments)]
|
#![feature(augmented_assignments)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
|
// Clippy
|
||||||
#![plugin(clippy)]
|
#![plugin(clippy)]
|
||||||
#![allow(needless_range_loop, match_bool)]
|
// TODO [todr] not really sure
|
||||||
|
#![allow(needless_range_loop)]
|
||||||
|
// Shorter than if-else
|
||||||
|
#![allow(match_bool)]
|
||||||
|
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||||
|
#![allow(clone_on_copy)]
|
||||||
|
|
||||||
|
|
||||||
//! Ethcore library
|
//! Ethcore library
|
||||||
//!
|
//!
|
||||||
|
@ -165,7 +165,7 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
Some(ref a) => {
|
Some(ref a) => {
|
||||||
public_address = SocketAddr::from_str(a.as_ref()).expect("Invalid listen/public address given with --address");
|
public_address = SocketAddr::from_str(a.as_ref()).expect("Invalid listen/public address given with --address");
|
||||||
listen_address = public_address.clone();
|
listen_address = public_address;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ impl Visitor for BlockNumberVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Into<BlockId> for BlockNumber {
|
impl Into<BlockId> for BlockNumber {
|
||||||
|
#[allow(match_same_arms)]
|
||||||
fn into(self) -> BlockId {
|
fn into(self) -> BlockId {
|
||||||
match self {
|
match self {
|
||||||
BlockNumber::Num(n) => BlockId::Number(n),
|
BlockNumber::Num(n) => BlockId::Number(n),
|
||||||
|
@ -240,6 +240,8 @@ impl ChainSync {
|
|||||||
self.peers.clear();
|
self.peers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[allow(for_kv_map)] // Because it's not possible to get `values_mut()`
|
||||||
/// Rest sync. Clear all downloaded data but keep the queue
|
/// Rest sync. Clear all downloaded data but keep the queue
|
||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
self.downloading_headers.clear();
|
self.downloading_headers.clear();
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
#![plugin(clippy)]
|
|
||||||
#![feature(augmented_assignments)]
|
#![feature(augmented_assignments)]
|
||||||
|
#![plugin(clippy)]
|
||||||
|
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||||
|
#![allow(clone_on_copy)]
|
||||||
|
|
||||||
//! Blockchain sync module
|
//! Blockchain sync module
|
||||||
//! Implements ethereum protocol version 63 as specified here:
|
//! Implements ethereum protocol version 63 as specified here:
|
||||||
//! https://github.com/ethereum/wiki/wiki/Ethereum-Wire-Protocol
|
//! https://github.com/ethereum/wiki/wiki/Ethereum-Wire-Protocol
|
||||||
|
@ -170,8 +170,7 @@ impl<K, V> RangeCollection<K, V> for Vec<(K, Vec<V>)> where K: Ord + PartialEq +
|
|||||||
|
|
||||||
// todo: fix warning
|
// todo: fix warning
|
||||||
let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) {
|
let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) {
|
||||||
Ok(index) => index,
|
Ok(index) | Err(index) => index
|
||||||
Err(index) => index,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut to_remove: Option<usize> = None;
|
let mut to_remove: Option<usize> = None;
|
||||||
|
@ -19,9 +19,17 @@
|
|||||||
#![feature(augmented_assignments)]
|
#![feature(augmented_assignments)]
|
||||||
#![feature(associated_consts)]
|
#![feature(associated_consts)]
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
||||||
#![plugin(clippy)]
|
|
||||||
#![allow(needless_range_loop, match_bool)]
|
|
||||||
#![feature(catch_panic)]
|
#![feature(catch_panic)]
|
||||||
|
// Clippy settings
|
||||||
|
#![plugin(clippy)]
|
||||||
|
// TODO [todr] not really sure
|
||||||
|
#![allow(needless_range_loop)]
|
||||||
|
// Shorter than if-else
|
||||||
|
#![allow(match_bool)]
|
||||||
|
// We use that to be more explicit about handled cases
|
||||||
|
#![allow(match_same_arms)]
|
||||||
|
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||||
|
#![allow(clone_on_copy)]
|
||||||
|
|
||||||
//! Ethcore-util library
|
//! Ethcore-util library
|
||||||
//!
|
//!
|
||||||
|
@ -104,7 +104,7 @@ impl<F> OnPanicListener for F
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn convert_to_string(t: &Box<Any + Send>) -> Option<String> {
|
fn convert_to_string(t: &Box<Any + Send>) -> Option<String> {
|
||||||
let as_str = t.downcast_ref::<&'static str>().map(|t| t.clone().to_owned());
|
let as_str = t.downcast_ref::<&'static str>().cloned().map(|t| t.to_owned());
|
||||||
let as_string = t.downcast_ref::<String>().cloned();
|
let as_string = t.downcast_ref::<String>().cloned();
|
||||||
|
|
||||||
as_str.or(as_string)
|
as_str.or(as_string)
|
||||||
|
Loading…
Reference in New Issue
Block a user