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

Avoid expanding single-element tuple patterns #7683

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

charliermarsh
Copy link
Member

Summary

The formatting for tuple patterns is now intended to match that of for loops:

  • Always parenthesize single-element tuples.
  • Don't break on the trailing comma in single-element tuples.
  • For other tuples, preserve the parentheses, and insert if-breaks.

Closes #7681.

Test Plan

cargo test

@charliermarsh charliermarsh added the formatter Related to the formatter label Sep 27, 2023
@charliermarsh charliermarsh force-pushed the charlie/pat branch 2 times, most recently from eb2ef9d to d54079d Compare September 27, 2023 23:49
@charliermarsh charliermarsh enabled auto-merge (squash) September 27, 2023 23:55
@charliermarsh charliermarsh merged commit 58b50a6 into main Sep 27, 2023
15 checks passed
@charliermarsh charliermarsh deleted the charlie/pat branch September 27, 2023 23:57


# Single-element tuples.
match pattern:
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some more tests with comments?

};

match (patterns.as_slice(), sequence_type) {
// If the sequence is empty, the parentheses with any dangling comments.
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems to miss at least a verb.

charliermarsh added a commit that referenced this pull request Sep 28, 2023
Just changes to internal comments and tests.

See comments in #7683.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter: breaks single-element pattern
2 participants