-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Remove crash macro from fmt and unexpand #5522
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
GNU testsuite comparison:
|
37a7755
to
c84dd50
Compare
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! I like it, but errors can be tricky so I think we should refine this a little bit, mostly because you changes allows us to make the code even better :)
src/uu/unexpand/src/unexpand.rs
Outdated
@@ -209,16 +209,19 @@ pub fn uu_app() -> Command { | |||
) | |||
} | |||
|
|||
fn open(path: &str) -> BufReader<Box<dyn Read + 'static>> { | |||
fn open(path: &str) -> std::io::Result<BufReader<Box<dyn Read + '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.
It looks like this should return UResult
instead, because then we don't have to show!
the error immediately. You can look at the map_err_context
method too for io errors, that allows us to add a context string and turn them in a UError
.
To do this, you could split of all the code that could have write errors into a separate function that returns std::io::Result
and then call that with map_err_context
in unexpand
.
src/uu/fmt/src/linebreak.rs
Outdated
Some(&s) => s, | ||
None => { | ||
show!(USimpleError::new( |
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.
Shouldn't we stop execution at this error? Either that, or if we can verify that it really never happens it should maybe be an unreachable!
call.
c84dd50
to
239f155
Compare
GNU testsuite comparison:
|
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.
Sorry, it needs to be rebased (conflict)
no activity for a while, closing |
This PR is related to #5487.
It removes the crash! macro from fmt and unexpand.