-
Couldn't load subscription status.
- Fork 141
Replace std::error::Error with core::error::Error
#116
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
Conversation
hash/src/lib.rs
Outdated
| Invalid, | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] |
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.
i guess it can be dropped
pubkey/src/lib.rs
Outdated
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] |
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.
the same here
pubkey/src/lib.rs
Outdated
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] |
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.
and here
instruction/src/error.rs
Outdated
| ArithmeticOverflow, | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] |
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.
and this one also
instruction/src/error.rs
Outdated
| // conversions must also be added | ||
| } | ||
|
|
||
| #[cfg(feature = "std")] |
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.
one more place
instruction/src/error.rs
Outdated
| impl std::error::Error for InstructionError {} | ||
| impl core::error::Error for InstructionError {} | ||
|
|
||
| #[cfg(feature = "std")] |
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 is also can be omitted, because this is a core::fmt::Dispalay trait
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.
Okay, I originally considered dropping these attributes, but I wasn't sure. Thank you for confirming.
|
Rebased the last few commits and removed the feature attributes for |
|
There have been quite a few changes since the PR was first opened, but we should be ready to integrate it -- can you rebase and update your branch? Let me know if you don't have time, and I'll be happy to take this over |
NO worries, will rebase and push by today. |
|
Could you please add Otherwise the error messages for people on old Rust versions will be confusing |
.github/workflows/main.yml
Outdated
| - name: Check formatting | ||
| run: ./scripts/check-fmt.sh | ||
|
|
||
| check: |
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.
why is this PR changing CI?
|
@divyaranjan1905 do you still have time for this? If not I can take over the PR |
I tried to rebase, but it didn't resolve nicely. Anything should I be specifically paying attention to? I'll try once again. |
|
There have been a lot of changes since the PR was created, so it would probably be easier to redo it from scratch. It looks like a few merge commits snuck in too, which probably isn't helping |
|
@joncinque Would this be required anymore? I was told to remove the solana-sdk/signature/src/error.rs Line 27 in ec56d76
|
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.
Looks good overall! Just a few last things to fixup, then we should be good to go
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.
Just a last bit, then this can go in!
| #[cfg(feature = "std")] | ||
| use std::{error::Error, vec::Vec}; | ||
| use core::error::Error; | ||
| use std::vec::Vec; |
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 isn't correct -- the whole point is to only bring in vec if the std feature is enabled:
| #[cfg(feature = "std")] | |
| use std::{error::Error, vec::Vec}; | |
| use core::error::Error; | |
| use std::vec::Vec; | |
| #[cfg(feature = "std")] | |
| use std::vec::Vec; | |
| use core::error::Error; |
signature/src/error.rs
Outdated
| //! [RustCrypto's opaque signature error](https://github.com/RustCrypto/traits/tree/master/signature) | ||
| #[cfg(all(feature = "std", feature = "alloc"))] | ||
| #[cfg(all(feature = "alloc"))] |
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.
nit: for all of these, we don't need all anymore
| #[cfg(all(feature = "alloc"))] | |
| #[cfg(feature = "alloc")] |
|
That should be it :) Sorry for the tiny mistakes. |
|
Looks like there are some CI failures:
|
|
Looks like it's still failing. Interesting: I have not touched it in my diff though. |
|
Changing it to |
signature/src/error.rs
Outdated
| self.source | ||
| .as_ref() | ||
| .map(|source| source.as_ref() as &(dyn std::error::Error + 'static)) | ||
| .map(|source| source.as_ref() as &(dyn core::error::Error + 'static)) |
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.
The issue is here -- since source only exists when the alloc feature is enabled, we need to gate this properly:
| self.source | |
| .as_ref() | |
| .map(|source| source.as_ref() as &(dyn std::error::Error + 'static)) | |
| .map(|source| source.as_ref() as &(dyn core::error::Error + 'static)) | |
| #[cfg(feature = "alloc")] | |
| { | |
| self.source.as_ref() | |
| .map(|source| source.as_ref() as &(dyn core::error::Error + 'static)) | |
| } | |
| #[cfg(not(feature = "alloc"))] | |
| { | |
| None | |
| } |
* Also adds rust-version = "1.81.0" for all such crates * Removes the redundant std attribute
|
Looks like there's still a formatting issue and a build issue. If you can, please run the commands before committing. And if you don't have time, I can take the PR from here |
|
@joncinque The commands somehow don't run on my system. And it's probably my system's issue. But yeah please take the PR from here and make the necessary formatting fixes. |
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.
Thanks for your contribution! I might need another approval, but let's see if this works...
Edit: I do need another approval
* replace std with core for Error * Also adds rust-version = "1.81.0" for all such crates * Removes the redundant std attribute * Fix CI failures --------- Co-authored-by: Jon C <[email protected]>
This PR simply replaces instances of
std::error::Errorwithcore::error::Error. It fixes #81, but as mentioned in the issue, it should probably be merged after #115.Regards,
Divya.