-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Carry over where clauses specified in Config
trait to other trait impls
#12053
Comments
Pallet<T>
for all Automatic ImplsConfig
trait to other trait impls
This might not be a good idea after all. In vanilla Rust, one would not expect to have the where clause on one trait to be carried over onto another trait bound -- it is expected that you rewrite the bound, because it is entirely possible for the other trait to be implemented under different conditions. Having such a replication of the where clause brings in more weirdness than it is worth IMHO, because now you could not specify a more lenient trait bound on the |
@mustermeiszer did you tried to add the where bound to the
I mean I would also expect the same for vanilla Rust. I still think that this is a bug/short coming of the current rustc implementation and that chalk will fix it. The point here being that you can only implement the trait when all the given bounds are matching. No need to carry it around all the time. It should be enough to check this on the implementation side. |
the following approach would work, but it does not as currently parity does not take over all trait bounds on all implementations on Pallet<T>. So I wanna have this state stored and the next commit will revert it to a state that does actually compile. Once, paritytech/substrate#12053 is resolved, we can simply revert the next commit and should be fine.
@bkchr I removed it from the trait and just use the bounds on the Anyways, it works like this. I will check if the runtime adheres to the bounds. If you have any insight on this, happy hear already now. |
@KiChjang and @bkchr, I think it would be nice to carry this over. The |
Hmm. I mean I get your frustration. But the current FRAME macros also try to be as close as possible to normal rust. However, we could maybe support that if you don't provide these bounds manually that we add them for you. |
No, can totally understand this. It's just a bit ugly this way, as I need an empty hooks impl and append it everywhere. Will close this then. It's rather an edge case anyways ^^ |
Actually, now that I think about it, you're right, because we've already trait bounded the It does now sound like it's a Rust compiler issue, so when we finally have chalk, this issue should be resolved. |
* Insert pallet-investment from stale branch * WIP: Amend * Make compile again with asterix the following approach would work, but it does not as currently parity does not take over all trait bounds on all implementations on Pallet<T>. So I wanna have this state stored and the next commit will revert it to a state that does actually compile. Once, paritytech/substrate#12053 is resolved, we can simply revert the next commit and should be fine. * Compiles AND contains trait bounds * Docs and fix updating orders on overflowing * Use struct enum variants for Event type * Adapt call docs for collect and collect-for * Restrict trait globally * Fix unintentional replace * Fix node build * Fix typo * Add actual transfer of values to the owner of an asset, i.e. the pool derived account in our case. * Address PR review * Make default with zero for TOtalORder * Seperates logic for invest/redeem everwhere TODO: Change InvestementManager logic to also split invest/tedeem - Add a Subscruber pattern to fulfillment * Change api of traits, use faster hasher * Remove asset from investment pallet * Add order_or_default logic * Add CollectOutcome * Append remaining orders to latest current one * Fix logical bugs - only one processing order concurrently possible - remove orderID from trait - docs for traits * Introduce investment trait for other pallets to consume * Update nix cargosha256 Co-authored-by: Branan Riley <[email protected]>
I wanted to reopen this, as this occurs more often now on my side. @KiChjang WDYT about this now? |
I'm not particularly enthusiastic about implementing this, because this is code that eventually will be removed as the compiler improves. We are basically monkey-patching the compiler trait logic by using our own macros for the benefit of saving a few keystrokes now. I can be convinced otherwise if there is a demonstration of this being a high priority issue that negatively affects pallet development, otherwise I would honestly encourage you to open a compiler issue on this, as I believe that should be the correct abstraction layer to solve this bug. |
But your macros are already doing this. Just not consistently. What is mainly of annoyance here ist that I need associated types where I could use more concrete trait bounds. |
How exactly do our macros carry over where clauses from the |
See above: These do NOT take over the bounds:
These DO take over the bounds:
Lists are probably not exhaustive. |
The commonality in the traits that you listed as "carrying over" are all because they're generated by the pallet macro. For the others that you mentioned, they aren't traits impls that are generated during macro expansion, and instead are explicitly written out by the developer. This is why on the very first comment on this issue, I said that it isn't necessarily a good idea, since the macro is respecting exactly what you have written in your trait impl. If you did not specify any where clauses on the trait impls that you had explicitly written, then the macro would not attempt to be smart and add where clauses when none are written. As such, I would only consider adding the where clauses to trait impls that we generate (i.e. when you skip writing |
Ah, now I understand what you meant. Yes, that would be great and I totally agree, that the macro shouldn't change explicit impls made by the dev. And just to clarify: I did not implement hooks or call, and the macro expansion is NOT automatically adding my where clause. Changing this us what I think would be a valuable adaption. |
I experience an issue, where I have a complex trait bound on my pallets
trait Config
. But not all automatical implementations forPallet<T>
do take over those bounds.Example
As far as I could see in the expansion the following impls do not take over the trait bounds
The text was updated successfully, but these errors were encountered: