Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the trait Decode is not implemented for BoundedBTreeMap<ElectionScore, u32> #454

Closed
jsdw opened this issue Feb 16, 2022 · 0 comments · Fixed by #455
Closed

the trait Decode is not implemented for BoundedBTreeMap<ElectionScore, u32> #454

jsdw opened this issue Feb 16, 2022 · 0 comments · Fixed by #455

Comments

@jsdw
Copy link
Collaborator

jsdw commented Feb 16, 2022

This error crops up when attempting to build subxt against the latest substrate master.

It occurs because BoundedBTreeMap<K,V> is a generated struct that contains a BTreeMap<K,V>, and Decode is only implemented on BTreeMap<K,V> if K: Ord.

In the erroneous case, we generate a BoundedBTreeMap<ElectionScore, u32>, and ElectionScore is another generated type which gets the default derives that we apply to all generated types (which doesn't include Ord).

Adding Ord (and thus also adding PartialOrd, Eq, PartialEq) to all types doesn't work out (loads of things can't impl this).

The best idea I have offhand is to iterate through the type registry looking for anything called "BTreeMap", and then adding the type ID of the first parameter it takes to some list. Later, when we generate all of our types, make sure that those IDs get the extra traits that they need to allow Decoding when they are keys in a BTreeMap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant