Add explicit impls for std::error::Error for all error types#5919
Add explicit impls for std::error::Error for all error types#5919mpbagot wants to merge 8 commits intorust-bitcoin:masterfrom
std::error::Error for all error types#5919Conversation
hashes/src/sha256/crypto.rs
Outdated
| 0xa507ea32, 0x6fab9537, 0x17406110, 0x0d8cd6f1, 0xcdaa3b6d, 0xc0bbbe37, 0x83613bda, | ||
| 0xdb48a363, 0x0b02e931, 0x6fd15ca7, 0x521afaca, 0x31338431, 0x6ed41a95, 0x6d437890, | ||
| 0xc39c91f2, 0x9eccabbd, 0xb5c9a0e6, 0x532fb63c, 0xd2c741c6, 0x07237ea3, 0xa4954b68, | ||
| 0x4c191d76, |
There was a problem hiding this comment.
Original format is better, I'm surprised to see this since this code is old as hell. I 100% do not understand exactly when the formatter runs on files. These need a skip please mate.
hashes/src/sha256/crypto.rs
Outdated
| mut msg2_b, | ||
| mut msg3_a, | ||
| mut msg3_b, | ||
| ); |
|
Mad, thanks man! Did you do anything to check if there were already impls on enums that have all variants without inner errors that do not match on |
I didn't do anything intelligent here. I only did a regex search in VSCode for On another note, it brought up the enums that have matches with ors on the arms, like: #[cfg(feature = "std")]
impl std::error::Error for PrevoutsIndexError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::InvalidOneIndex | Self::InvalidAllIndex => None,
}
}
}I used an arm for each enum variant. Should I add a patch to change errors like these to use an arm per variant, or should I go back and change the new ones to use ors? Or is a mismatch fine in this case? |
|
I don't think its too bigger deal (I didn't notice during review) but I"d personally favour using the |
What about prompt it with 'print the impls of all |
|
670acd8 needs rebase |
670acd8 to
31d7595
Compare
|
The formatting changes are problematic. Fixed in #5927 |
|
All good except fmt stuff. Reviewed 31d7595 |
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None. For enum errors, also return None for each match arm.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None. For enum errors, also return None for each match arm.
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation. Replace all default impls of std::error::Error with explicit impls returning None. For enum errors, also return None for each match arm.
As part of introducing explicit impls for std::error::Error, various error types are now recorded as including a source() impl. To satisfy the API checker, the files must be updated. Update API files with just check-api
31d7595 to
d2cfff4
Compare
|
Rebased and dropped the formatting patch |
|
d2cfff4 needs rebase |
The std::error::Error impls on many error types rely on the default implementation for the trait, which returns None. While these are (presumably) correct, explicit return values make the functionality more obvious to later developers without requiring pre-existing knowledge of the trait or needing to search documentation.
Closes #5908