Skip to content

refactor: exhaustively match on token::LitKind - #7216

Open
ytmimi wants to merge 1 commit into
rust-lang:mainfrom
ytmimi:refactor_rewrite_literal
Open

ytmimi wants to merge 1 commit into
rust-lang:mainfrom
ytmimi:refactor_rewrite_literal

Conversation

@ytmimi

@ytmimi ytmimi commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Based on #7215 it seems that we missed handling different kinds of string literals. Before trying to address that issue I thought it would be best if we refactored the match to be exhaustive.

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Oct 26, 2026
@jieyouxu jieyouxu self-assigned this Oct 26, 2026
Comment thread src/expr.rs
shape,
)
.max_width_error(shape.width, span),
token::LitKind::Bool

@matthewhughes934 matthewhughes934 Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought it be be clearer to have the comments next to the type like:

        token::LitKind::Bool // token::LitKind::Bool is true or false

But that would remove the comment: error[internal]: not formatted because a comment would be lost 🫠 I'll go check if there's an open issue for that

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's why I didn't place them there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@matthewhughes934 there was an initial attempt at solving this at #6893, but we haven't merged it yet because it contains some other changes that I wanted removed. I don't think we necessarily need to worry about that right now, but I'm bringing it up because there are several linked issues on that PR.

Comment thread src/expr.rs Outdated
Based on rustfmt issue 7215 it seems that we missed handling different kinds of
string literals. Before trying to address that issue I thought it would be best
if we refactored the match to be exhaustive.
@ytmimi
ytmimi force-pushed the refactor_rewrite_literal branch from 14ce102 to afea4a8 Compare October 27, 2026 03:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants