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
This means that we cannot make objects out of the ChainHandle trait. So the compiler will forbid something of the kind:
pubstructForeignClient{/// The configuration of this clientconfig:ForeignClientConfig,/// A handle to the chain hosting this clienthost_chain:dynChainHandle,}
The precise error is as follows:
error[E0038]: the trait `ChainHandle` cannot be made into an object
--> relayer/src/foreign_client.rs:59:17
|
59 | host_chain: Box<dyn ChainHandle>,
| ^^^^^^^^^^^^^^^^^^^^ the trait `ChainHandle` cannot be made into an object
|
::: relayer/src/chain/handle.rs:177:24
|
177 | pub trait ChainHandle: Clone + Send + Sync {
| ----------- ----- ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0038`.
error: could not compile `relayer`
pubstructForeignClient{/// The configuration of this clientconfig:ForeignClientConfig,/// A handle to the chain hosting this clienthost_chain:Box<dynChainHandle>,}
Alternative solutions include splitting the handle trait into the handle proper + a constructor, or adding specific where clauses cf. this. But the DynClone method seems the most robust and simple.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate milestone (priority) applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Crate
relayer
Summary & problem definition
The
ChainHandle
trait is currently clonable thanks to its bound onClone
, which impliesSized
, which in turn makes theChainHandle
non-object-safe.https://github.com/informalsystems/ibc-rs/blob/65e4f268efc176d861d30949dc7bde049e0b3bb5/relayer/src/chain/handle.rs#L177
This means that we cannot make objects out of the
ChainHandle
trait. So the compiler will forbid something of the kind:The precise error is as follows:
See more details on object safety here:
https://rust-lang.github.io/rfcs/0255-object-safety.html#detailed-design
Proposal
At @romac's suggestion, we can replace the
Clone
bound withDynClone
instead, and obtain object safety. https://github.com/kardeiz/objekt-clonable may also be an option. Then we can do this:Alternative solutions include splitting the handle trait into the handle proper + a constructor, or adding specific
where
clauses cf. this. But theDynClone
method seems the most robust and simple.For Admin Use
The text was updated successfully, but these errors were encountered: