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

Use RewriteResult in visit_item #6410

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

camsteffen
Copy link
Contributor

@camsteffen camsteffen commented Dec 1, 2024

CC #6206

Comment on lines -1192 to +1190
return None;
return Err(RewriteError::Unknown);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something we need to do in this PR, but it would be nice to add a new variant to RewriteError that communicates that rewriting failed because comments would be lost.

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 was wondering about this too. Or maybe something more general like KnownLimitation. But would such an error actually be useful over Unknown at runtime?

Copy link
Contributor

@ytmimi ytmimi Dec 1, 2024

Choose a reason for hiding this comment

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

For the potential comment loss, yes it would be. Eventually we'll want to communicate to end users that we failed to format their code because we weren't expecting to find a comment in a particular location, and in order to avoid removing the comment entirely we're leaving that AST node unformatted.

Copy link
Contributor

Choose a reason for hiding this comment

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

In some cases we already communicate that to end users, but it's not always consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense!

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.

Overall code changes look good to me. Should be good to merge after the Diff Check Job completes.

Edit: The job ran successfully ✅

@ytmimi ytmimi merged commit 9f8fcc2 into rust-lang:master Dec 2, 2024
26 checks passed
@camsteffen camsteffen deleted the rewriteresult-items branch December 2, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants