Skip to content
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

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

ding-young
Copy link
Contributor

Tracked by #6206

Description

  • impl rewrite_result for Chain
  • update rewrite_chain and methods of the trait ChainFormatter to return RewriteResult

TODO

I'll add some comments to the code shortly

src/chains.rs Outdated Show resolved Hide resolved
src/chains.rs Outdated Show resolved Hide resolved
src/chains.rs Show resolved Hide resolved
src/chains.rs Outdated Show resolved Hide resolved
@ytmimi ytmimi added the GSoC Google Summer of Code label Aug 8, 2024
src/chains.rs Outdated Show resolved Hide resolved
Comment on lines +100 to +105
// 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())
Copy link
Contributor Author

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.

Comment on lines 81 to 85
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| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, too.

Copy link
Contributor

@ytmimi ytmimi left a 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

@ytmimi ytmimi merged commit fbe0424 into rust-lang:master Aug 15, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Google Summer of Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants