-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
program-error: Add option to specify solana_program crate #7112
Conversation
Problem There are going to be a lot of issues with people seeing errors on spl_program_error derivation. When a build pulls in two version of solana_program, the macro uses `::solana_program`, which now becomes ambiguous. Summary of changes I'm not sure if this is a good idea, but this PR gives the ability to specify which version of `solana_program` to use when deriving the various traits on your error type. Borsh has this same functionality, and it's saved us when pulling in multiple versions of borsh in the SDK. Note: this PR defaults to `solana_program` instead of `::solana_program`, which might cause downstream issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh clever, this could be useful. num-derive
also lets you do this with num-traits
, but it looks like it defaults to expecting the dependency to be in the crate's manifest.
However, they make use of a clever little trick - documented as being plucked from serde - to register the user's import as a local _num_traits
module.
Maybe we can do it this way for the default? I think that should avoid the ambiguous glob problem from #6590. What do you think?
Additionally, now that I'm looking through the
|
This comment was marked as spam.
This comment was marked as spam.
Thanks for the feedback! Let me know how this looks.
Definitely makes sense, but I'd prefer to keep that for future work if that's ok with you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I think this will help with dependencies a lot. Thanks!
Problem
There are going to be a lot of issues with people seeing errors on
spl_program_error derivation. When a build pulls in two version of
solana_program, the macro uses
::solana_program
, which now becomesambiguous.
Summary of changes
I'm not sure if this is a good idea, but this PR gives the ability
to specify which version of
solana_program
to use when deriving thevarious traits on your error type.
Borsh has this same functionality, and it's saved us when pulling in
multiple versions of borsh in the SDK.
Note: this PR defaults to
solana_program
instead of::solana_program
, which might cause downstream issues.