From f2600745f9f2c8c62af710393a5c0a8dc3461b07 Mon Sep 17 00:00:00 2001 From: Wodann Date: Tue, 17 Sep 2024 22:14:35 +0000 Subject: [PATCH] revert to Rust 1.80 --- crates/interpreter/src/interpreter/analysis.rs | 6 ++++-- crates/interpreter/src/opcode.rs | 4 ++-- crates/optimism/src/result.rs | 3 ++- crates/primitives/src/bytecode.rs | 3 ++- crates/primitives/src/bytecode/eof.rs | 3 ++- crates/primitives/src/eip7702/bytecode.rs | 3 ++- crates/primitives/src/evm_wiring.rs | 13 +++++++++++-- crates/primitives/src/precompile.rs | 6 ++++-- crates/primitives/src/result.rs | 6 ++++-- examples/db_by_ref.rs | 2 +- 10 files changed, 34 insertions(+), 15 deletions(-) diff --git a/crates/interpreter/src/interpreter/analysis.rs b/crates/interpreter/src/interpreter/analysis.rs index c2ea93506c..0f3651a7bd 100644 --- a/crates/interpreter/src/interpreter/analysis.rs +++ b/crates/interpreter/src/interpreter/analysis.rs @@ -219,7 +219,8 @@ impl fmt::Display for EofError { } } -impl core::error::Error for EofError {} +#[cfg(feature = "std")] +impl std::error::Error for EofError {} #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum EofValidationError { @@ -441,7 +442,8 @@ impl fmt::Display for EofValidationError { } } -impl core::error::Error for EofValidationError {} +#[cfg(feature = "std")] +impl std::error::Error for EofValidationError {} /// Validates that: /// * All instructions are valid. diff --git a/crates/interpreter/src/opcode.rs b/crates/interpreter/src/opcode.rs index 587810f5d6..0695b9d6f1 100644 --- a/crates/interpreter/src/opcode.rs +++ b/crates/interpreter/src/opcode.rs @@ -24,8 +24,8 @@ impl fmt::Display for OpCodeError { } } -#[cfg(feature = "parse")] -impl core::error::Error for OpCodeError {} +#[cfg(all(feature = "parse", feature = "std"))] +impl std::error::Error for OpCodeError {} /// An EVM opcode. /// diff --git a/crates/optimism/src/result.rs b/crates/optimism/src/result.rs index 63093fc9f5..2749f91581 100644 --- a/crates/optimism/src/result.rs +++ b/crates/optimism/src/result.rs @@ -58,7 +58,8 @@ impl Display for OptimismInvalidTransaction { } } -impl core::error::Error for OptimismInvalidTransaction {} +#[cfg(feature = "std")] +impl std::error::Error for OptimismInvalidTransaction {} impl From for OptimismInvalidTransaction { fn from(value: InvalidTransaction) -> Self { diff --git a/crates/primitives/src/bytecode.rs b/crates/primitives/src/bytecode.rs index d3fbbd2868..bae4161806 100644 --- a/crates/primitives/src/bytecode.rs +++ b/crates/primitives/src/bytecode.rs @@ -235,7 +235,8 @@ impl From for BytecodeDecodeError { } } -impl core::error::Error for BytecodeDecodeError {} +#[cfg(feature = "std")] +impl std::error::Error for BytecodeDecodeError {} impl fmt::Display for BytecodeDecodeError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/primitives/src/bytecode/eof.rs b/crates/primitives/src/bytecode/eof.rs index d25f61f6d9..8ed12abb86 100644 --- a/crates/primitives/src/bytecode/eof.rs +++ b/crates/primitives/src/bytecode/eof.rs @@ -182,7 +182,8 @@ impl fmt::Display for EofDecodeError { } } -impl core::error::Error for EofDecodeError {} +#[cfg(feature = "std")] +impl std::error::Error for EofDecodeError {} #[cfg(test)] mod test { diff --git a/crates/primitives/src/eip7702/bytecode.rs b/crates/primitives/src/eip7702/bytecode.rs index 89a8082389..268f2c4aa6 100644 --- a/crates/primitives/src/eip7702/bytecode.rs +++ b/crates/primitives/src/eip7702/bytecode.rs @@ -93,7 +93,8 @@ impl fmt::Display for Eip7702DecodeError { } } -impl core::error::Error for Eip7702DecodeError {} +#[cfg(feature = "std")] +impl std::error::Error for Eip7702DecodeError {} #[cfg(test)] mod tests { diff --git a/crates/primitives/src/evm_wiring.rs b/crates/primitives/src/evm_wiring.rs index ed59f8a7b8..d4f19add67 100644 --- a/crates/primitives/src/evm_wiring.rs +++ b/crates/primitives/src/evm_wiring.rs @@ -1,3 +1,5 @@ +use cfg_if::cfg_if; + use crate::{db::Database, Block, SpecId, Transaction}; use core::{fmt::Debug, hash::Hash}; @@ -17,8 +19,15 @@ impl HaltReasonTrait for HaltReasonT where } pub trait TransactionValidation { - /// An error that occurs when validating a transaction. - type ValidationError: Debug + core::error::Error; + cfg_if! { + if #[cfg(feature = "std")] { + /// An error that occurs when validating a transaction. + type ValidationError: Debug + std::error::Error; + } else { + /// An error that occurs when validating a transaction. + type ValidationError: Debug; + } + } } pub trait ChainSpec: Sized { diff --git a/crates/primitives/src/precompile.rs b/crates/primitives/src/precompile.rs index 25938bb580..890e1b537e 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/primitives/src/precompile.rs @@ -140,7 +140,8 @@ pub enum PrecompileErrors { Fatal { msg: String }, } -impl core::error::Error for PrecompileErrors {} +#[cfg(feature = "std")] +impl std::error::Error for PrecompileErrors {} impl fmt::Display for PrecompileErrors { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -195,7 +196,8 @@ impl From for PrecompileErrors { } } -impl core::error::Error for PrecompileError {} +#[cfg(feature = "std")] +impl std::error::Error for PrecompileError {} impl fmt::Display for PrecompileError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index e37caed37b..7deeb6b9fb 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -313,7 +313,8 @@ impl From for InvalidTransaction { } } -impl core::error::Error for InvalidTransaction {} +#[cfg(feature = "std")] +impl std::error::Error for InvalidTransaction {} impl fmt::Display for InvalidTransaction { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -389,7 +390,8 @@ pub enum InvalidHeader { ExcessBlobGasNotSet, } -impl core::error::Error for InvalidHeader {} +#[cfg(feature = "std")] +impl std::error::Error for InvalidHeader {} impl fmt::Display for InvalidHeader { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/examples/db_by_ref.rs b/examples/db_by_ref.rs index 4801db5a1b..14c5b32d3b 100644 --- a/examples/db_by_ref.rs +++ b/examples/db_by_ref.rs @@ -1,4 +1,3 @@ -use core::error::Error; use core::fmt::Debug; use revm::{ db::{CacheDB, EmptyDB, WrapDatabaseRef}, @@ -8,6 +7,7 @@ use revm::{ primitives::{EthereumWiring, HaltReason, ResultAndState}, DatabaseCommit, DatabaseRef, Evm, }; +use std::error::Error; trait DatabaseRefDebugError: DatabaseRef { type DBError: std::fmt::Debug + Error + Send + Sync + 'static;