-
Notifications
You must be signed in to change notification settings - Fork 903
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
update rewrite_assignment to return RewriteResult #6295
Conversation
e6ebbbe
to
03fcf0d
Compare
src/expr.rs
Outdated
match (orig_rhs, new_rhs) { | ||
(Some(ref orig_rhs), Some(ref new_rhs)) | ||
(Ok(ref orig_rhs), Ok(ref new_rhs)) | ||
if !filtered_str_fits(&new_rhs, context.config.max_width(), new_shape) => | ||
{ | ||
Some(format!("{before_space_str}{orig_rhs}")) | ||
Ok(format!("{before_space_str}{orig_rhs}")) | ||
} | ||
(Some(ref orig_rhs), Some(ref new_rhs)) | ||
(Ok(ref orig_rhs), Ok(ref new_rhs)) | ||
if prefer_next_line(orig_rhs, new_rhs, rhs_tactics) => | ||
{ | ||
Some(format!("{new_indent_str}{new_rhs}")) | ||
Ok(format!("{new_indent_str}{new_rhs}")) | ||
} | ||
(None, Some(ref new_rhs)) => Some(format!("{new_indent_str}{new_rhs}")), | ||
(None, None) if rhs_tactics == RhsTactics::AllowOverflow => { | ||
(Err(_), Ok(ref new_rhs)) => Ok(format!("{new_indent_str}{new_rhs}")), | ||
(Err(_), Err(_)) if rhs_tactics == RhsTactics::AllowOverflow => { | ||
let shape = shape.infinite_width(); | ||
expr.rewrite(context, shape) | ||
expr.rewrite_result(context, shape) | ||
.map(|s| format!("{}{}", before_space_str, s)) | ||
} | ||
(None, None) => None, | ||
(Some(orig_rhs), _) => Some(format!("{before_space_str}{orig_rhs}")), | ||
(Err(_), Err(new_rhs_err)) => Err(new_rhs_err), | ||
(Ok(orig_rhs), _) => Ok(format!("{before_space_str}{orig_rhs}")), |
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.
(Err(_), Err(new_rhs_err)) => Err(new_rhs_err),
refer to the comment in #6291
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've got a similar response: #6291 (comment). I think it's fine to use the 2nd error as the return, and I think adding a comment to explain that we could have chosen either would be nice.
03fcf0d
to
c4a0e76
Compare
Thanks for leaving the note! I've started the Diff Check |
tracked by #6206
Description
update
rewrite_assignment
to returnRewriteResult