refactor: new error system - #624
Conversation
Signed-off-by: Alejandro Vaz <alejandro.vaz.myt@gmail.com>
|
this diverges from |
|
I'm not sure I fully like this, I'll go back to working on it |
|
now it is cleaner |
|
Is this worth the complication? As far as I can tell there are no functions that could benefit from a more precise error signature. |
|
it kills honestly my stance is that something better is worth merging and the trait machinery makes the internal API better that's about it in terms of how much can I defend this originally it was about making function signatures more precise by letting both kinds of errors exist independently, but it isn't even used anywhere |
Do we want error handling code to be inlined? Allocation errors should always be the cold path, and we don't want to duplicate this code that will likely never be called.
Yeah, I was confused by the name when I first came to the repo. Do we need it to be a trait? Couldn't it just be a method on the error enum? |
|
it really can't be a method on the enum because we are implementing it on I think we want error handling to be inlined because it is not just error handling, it is matching the if it weren't inlined, there would be an additional jump always but we could have something like "if it's okay then give the value, if not call this cold never inlined function which matches the error variant (a method)" I think that's cleaner indeed |
Oh, I didn't see that. So it's either a trait or use something like |
|
yeah but |
Does MSRV not allow arbitrary return types on functions that never return? Something like fn hande<T>(e: CollectionAllocErr) -> T {
panic!() or whatever
} |
|
your way is better |
|
How come pub fn reserve(&mut self, additional: usize) {
infallibe(self.try_reserve(additional));
}? Same with That's probably out of scope for this PR though. |
|
I do want #644 merged soon because the nightly check takes ages to complete |
|
how the hell has it been going for 20 minutes |
jdm
left a comment
There was a problem hiding this comment.
It appears that the final changes in this PR are:
- rename the error type
- change one variant away from an struct variant
- replace uses of the infallible function with unwrap_or_else
This ultimately feels more like idiomatic Rust, so I'm fine with that.
this PR remakes error handling to be trait-based instead of relying on
fn infalliblecloses #622