-
Notifications
You must be signed in to change notification settings - Fork 94
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
Derivation adds unnecessary bounds that can't be satisfied for certain recursive types #603
Comments
To summarize my understanding of the issue here: Say you have a generic type like In order to avoid an issue, it will skip doing this when the field is recursively referencing itself (ie when The suggested fix above won't quite work because what if we have two types with the same name in different modules that reference eachother (eg Can we simplify the @ascjones you may know something about this :) |
The problem is the algorithm that tries to determine the trait bounds. It tries to be better than what we have in the standard library. However, we don't access to the type system in macros and we need to "guess". For the situation like you are facing, you can use the attribute |
My feeling is that we should simplify the trait bound stuff in this lib so that it is a bit dumber by default and just applies basic bounds on each generic like the std library, and then let users use Maybe there were good reasons to make it smarter though which I'm missing, ie maybe we did it to avoid issues where we use generic associated types like
Yeah good point, we'll maybe do that in our codegen to avoid this issue :) |
Oh!! |
Error encountered
Minimal Repro:
Produces trait with extra bounds(expansion below, note extra
Containter<Self>
bounds introduced):Click me(`Encode` as the example, although same happens for `Decode` too)
changing this line to
seems to solve the issue of correctly detecting the recursive ty_ident.
Tests pass after the change, however it might break things not tested in the ecosystem(?)
also see: paritytech/subxt#1603
The text was updated successfully, but these errors were encountered: