-
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_chain to return RewriteResult #6270
Conversation
// TODO(ding-young): Consider calling format_overflow_style() | ||
// only when item.rewrite_result() returns RewriteError::ExceedsMaxWidth. | ||
// It may be inappropriate to call format_overflow_style on other RewriteError | ||
// since the current approach retries formatting if allow_overflow is true | ||
item.rewrite_result(context, rewrite_shape) | ||
.or_else(|_| format_overflow_style(item.span, context).unknown_error()) |
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 updated the TODO comment to include the detail about the future improvement.
fn format_overflow_style(span: Span, context: &RewriteContext<'_>) -> Option<String> { | ||
// TODO(ding-young): Currently returning None when the given span is out of the range | ||
// covered by the snippet provider. If this is a common cause for internal | ||
// rewrite failure, add a new enum variant and return RewriteError instead of None | ||
context.snippet_provider.span_to_snippet(span).map(|s| { |
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.
Here, too.
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 making those updates.
Edit: Diff Check Job passed ✅
Tracked by #6206
Description
rewrite_result
forChain
rewrite_chain
and methods of the traitChainFormatter
to return RewriteResultTODO
I'll add some comments to the code shortly