Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: use global paths in generated code by
ibc-derive
(cosmos#1017)
* ibc-derive: use global paths in generated code Because the generated code uses paths which start with `ibc::`, they are first resolved from the local module’s namespace. That is, if an `ibc` module is defined, the derives create code which does not compile. This is demonstrated by the following fragment: use ::ibc::core::client::context::consensus_state::ConsensusState; use ::ibc::core::commitment_types::commitment::CommitmentRoot; mod ibc {} #[derive(ConsensusState)] enum AnyConsensusState { Foo(Foo) } struct Foo; impl ConsensusState for Foo { fn root(&self) -> &CommitmentRoot { todo!() } fn timestamp(&self) -> ::ibc::primitives::Timestamp { todo!() } fn encode_vec(self) -> Vec<u8> { todo!() } } The compilation fails with ‘failed to resolve: could not find `core` in `ibc`’ errors. To solve this, use global paths (i.e. ones starting with `::ibc::`). Starting from 2018 Rust edition such paths resolve from the extern prelude and thus `::ibc` points at the `ibc` crate. Note however that in 2015 edition global paths are anchored at the crate root so `::ibc` will attempt to look for `crate::ibc` module. This means that this change is breaking for code using ancient Rust editions. * chore: unclog --------- Co-authored-by: Farhad Shabani <[email protected]>
- Loading branch information