-
Notifications
You must be signed in to change notification settings - Fork 989
Description
Is there an existing issue?
- I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- This is not a support question.
Description of bug
This PR was merged recently: rust-lang/rust#115801 and it breaks some things. You can't recursively get Trait::AssociatedType
. Now this won't compile.
We encountered this problem when building with the -C instrument-coverage
flag, but maybe there is some other way to cause it.
The problem is that in rococo runtime or some custom runtime you can do the following:
polkadot-sdk/polkadot/runtime/rococo/src/lib.rs
Lines 279 to 282 in e7651cf
type KeyOwnerProof = | |
<Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof; | |
type EquivocationReportSystem = | |
pallet_babe::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>; |
So, it goes to EquivocationReportSystem
:
impl<T, R, P, L>
OffenceReportSystem<Option<T::AccountId>, (EquivocationProof<T::Header>, T::KeyOwnerProof)>
for EquivocationReportSystem<T, R, P, L>
where
T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes<Call<T>>,
R: ReportOffence<
T::AccountId,
P::IdentificationTuple,
EquivocationOffence<P::IdentificationTuple>,
>,
P: KeyOwnerProofSystem<(KeyTypeId, AuthorityId), Proof = T::KeyOwnerProof>, //recursion occurs in associated types
P::IdentificationTuple: Clone,
L: Get<u64>,
{ ... }
The compiler cannot resolve recursion in associated types:
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, pallet_babe::AuthorityId)>>::Proof;
P: KeyOwnerProofSystem<(KeyTypeId, AuthorityId), Proof = T::KeyOwnerProof>
We can see Proof = T::KeyOwnerProof
in P: ...
, but the KeyOwnerProof
from Config
trying to resolve associated type ::Proof
. It causes recursion and we do <<T::Proof>::Proof>::Proof...
Steps to reproduce
You can try build rococo runtime with RUSTFLAGS="-C instrument-coverage"
. Also see: rust-lang/rust#117211
$ RUSTFLAGS="-Cinstrument-coverage" cargo +nightly-2023-10-14 build -p rococo-runtime --release
Compiling rococo-runtime v1.0.0 (/home/.../work/polkadot-sdk/polkadot/runtime/rococo)
Building [=======================> ] 639/640: rococo-runtime
error[E0275]: overflow evaluating the requirement `<Runtime as pallet_grandpa::Config>::KeyOwnerProof == _`
For more information about this error, try `rustc --explain E0275`.
error: could not compile `rococo-runtime` (lib) due to previous error