Skip to content

Commit

Permalink
Extend clippy - rust-ethereum#245
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Nov 30, 2023
1 parent 743f288 commit 0d62095
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions interpreter/src/call_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum CreateScheme {
impl CreateScheme {
pub fn address<H: RuntimeBackend>(&self, handler: &H) -> H160 {
match self {
CreateScheme::Create2 {
Self::Create2 {
caller,
code_hash,
salt,
Expand All @@ -46,7 +46,7 @@ impl CreateScheme {
hasher.update(&code_hash[..]);
H256::from_slice(hasher.finalize().as_slice()).into()
}
CreateScheme::Legacy { caller } => {
Self::Legacy { caller } => {
let nonce = handler.nonce(*caller);
let mut stream = rlp::RlpStream::new_list(2);
stream.append(caller);
Expand All @@ -56,7 +56,7 @@ impl CreateScheme {
}
}

pub fn caller(&self) -> H160 {
pub const fn caller(&self) -> H160 {
match self {
Self::Create2 { caller, .. } => *caller,
Self::Legacy { caller } => *caller,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub enum CallCreateTrapData {
}

impl CallCreateTrapData {
pub fn target_gas(&self) -> Option<U256> {
pub const fn target_gas(&self) -> Option<U256> {
match self {
Self::Call(CallTrapData { gas, .. }) => Some(*gas),
Self::Create(_) => None,
Expand Down
4 changes: 2 additions & 2 deletions interpreter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl From<ExitException> for ExitResult {

impl From<ExitException> for ExitError {
fn from(s: ExitException) -> Self {
ExitError::Exception(s)
Self::Exception(s)
}
}

Expand Down Expand Up @@ -203,6 +203,6 @@ impl From<ExitFatal> for ExitResult {

impl From<ExitFatal> for ExitError {
fn from(s: ExitFatal) -> Self {
ExitError::Fatal(s)
Self::Fatal(s)
}
}
4 changes: 2 additions & 2 deletions interpreter/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where

impl<S, H, Tr> Etable<S, H, Tr> {
/// Default core value for Etable.
pub const fn core() -> Etable<S, H, Tr> {
pub const fn core() -> Self {
let mut table = [eval_unknown as _; 256];

table[Opcode::STOP.as_usize()] = eval_stop as _;
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<S: AsRef<RuntimeState>, H: RuntimeEnvironment + RuntimeBackend, Tr: CallCre
Etable<S, H, Tr>
{
/// Runtime Etable.
pub const fn runtime() -> Etable<S, H, Tr> {
pub const fn runtime() -> Self {
let mut table = Self::core();

table.0[Opcode::SHA3.as_usize()] = eval_sha3 as _;
Expand Down
2 changes: 1 addition & 1 deletion interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Machine<S> {

impl<S> Machine<S> {
/// Return a reference of the program counter.
pub fn position(&self) -> usize {
pub const fn position(&self) -> usize {
self.position
}

Expand Down
6 changes: 3 additions & 3 deletions interpreter/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Memory {
}

/// Memory limit.
pub fn limit(&self) -> usize {
pub const fn limit(&self) -> usize {
self.limit
}

Expand All @@ -34,7 +34,7 @@ impl Memory {
}

/// Get the effective length.
pub fn effective_len(&self) -> U256 {
pub const fn effective_len(&self) -> U256 {
self.effective_len
}

Expand All @@ -44,7 +44,7 @@ impl Memory {
}

/// Return the full memory.
pub fn data(&self) -> &Vec<u8> {
pub const fn data(&self) -> &Vec<u8> {
&self.data
}

Expand Down
4 changes: 2 additions & 2 deletions interpreter/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ pub struct RuntimeState {
pub gas: U256,
}

impl AsRef<RuntimeState> for RuntimeState {
impl AsRef<Self> for RuntimeState {
fn as_ref(&self) -> &Self {
self
}
}

impl AsMut<RuntimeState> for RuntimeState {
impl AsMut<Self> for RuntimeState {
fn as_mut(&mut self) -> &mut Self {
self
}
Expand Down
6 changes: 3 additions & 3 deletions interpreter/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ macro_rules! impl_perform_popn_pushn {

impl Stack {
/// Create a new stack with given limit.
pub fn new(limit: usize) -> Self {
pub const fn new(limit: usize) -> Self {
Self {
data: Vec::new(),
limit,
Expand All @@ -57,7 +57,7 @@ impl Stack {

#[inline]
/// Stack limit.
pub fn limit(&self) -> usize {
pub const fn limit(&self) -> usize {
self.limit
}

Expand All @@ -75,7 +75,7 @@ impl Stack {

#[inline]
/// Stack data.
pub fn data(&self) -> &Vec<H256> {
pub const fn data(&self) -> &Vec<H256> {
&self.data
}

Expand Down
2 changes: 1 addition & 1 deletion interpreter/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct I256(pub Sign, pub U256);

impl I256 {
/// Zero value of I256.
pub fn zero() -> I256 {
pub const fn zero() -> I256 {
I256(Sign::Zero, U256::zero())
}
/// Minimum value of I256.
Expand Down

0 comments on commit 0d62095

Please sign in to comment.