You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently downstream errors containing Db::Error have to add manual bounds for Debug if they want any printing strategy. However, Debug is derived or impld for all current errors used in revm. This would be a breaking change, however it is unlikely that any downstream implementors have non-Debug error types (I checked the foundry fork DB and they're already Debug)
This affects EVMError<Db::Error> because it derives Debug and therefore has no Debug impl unless the inner Db::Error has a Debug bound
affected traits:
Database
DatabaseRef
State
StateRef
BlockHash
BlockHashRef
What I want to do:
// broken code
#[derive(Debug, thiserror::Error)]
pub enum Error<Db>
where
Db: Database
{
// results in an error
// `EvmError<Db::Error>` cannot be formatted using `{:?}` because it doesn't implement `Debug`
#[error("{0:?}"]
Evm(EVMError<Db::Error>),
...
}
What I have to do instead:
#[derive(Debug, thiserror::Error)]
pub enum Error<Db>
where
Db: Database
// this bound holds for all current Database implementors, but must be manually written by consumers
Db::Error: Debug,
{
#[error("{0:?}"]
Evm(EVMError<Db::Error>),
...
}
the same is true of std::error::Error, however:
this approach does not dovetail with the crates extern crate alloc as std strategy for no_std support
it would require an intermediary trait ErrBound to handle changing the bound for std/no_std
there would need to be a cfg(feature = "std") implementation of std::error::Error for DatabaseComponentError
so while adding a std::error::Error it seems like supporting a bound of std::error::Error would be much more invasive, while adding Debug is non-invasive
The text was updated successfully, but these errors were encountered:
Currently downstream errors containing
Db::Error
have to add manual bounds forDebug
if they want any printing strategy. However,Debug
is derived or impld for all current errors used in revm. This would be a breaking change, however it is unlikely that any downstream implementors have non-Debug error types (I checked the foundry fork DB and they're alreadyDebug
)This affects
EVMError<Db::Error>
because it derivesDebug
and therefore has noDebug
impl unless the innerDb::Error
has aDebug
boundaffected traits:
Database
DatabaseRef
State
StateRef
BlockHash
BlockHashRef
What I want to do:
What I have to do instead:
the same is true of
std::error::Error
, however:extern crate alloc as std
strategy forno_std
supporttrait ErrBound
to handle changing the bound for std/no_stdcfg(feature = "std")
implementation ofstd::error::Error
forDatabaseComponentError
so while adding a
std::error::Error
it seems like supporting a bound ofstd::error::Error
would be much more invasive, while addingDebug
is non-invasiveThe text was updated successfully, but these errors were encountered: