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

Tracking Issue for Rust 2024: rustfmt single line where clauses #132381

Open
1 of 4 tasks
calebcartwright opened this issue Oct 31, 2024 · 3 comments
Open
1 of 4 tasks

Tracking Issue for Rust 2024: rustfmt single line where clauses #132381

calebcartwright opened this issue Oct 31, 2024 · 3 comments
Assignees
Labels
A-edition-2024 Area: The 2024 edition A-rustfmt Area: Rustfmt C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC I-style-nominated Nominated for discussion during a style team meeting. S-tracking-impl-incomplete Status: The implementation is incomplete. T-style Relevant to the style team, which will review and decide on the PR/issue.

Comments

@calebcartwright
Copy link
Member

calebcartwright commented Oct 31, 2024

This is a tracking issue for changing the formatting of where clauses to be formatted on a single line in some additional contexts, provided they meet certain constraints (short, single bound, and no = on aliases)

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

None.

Implementation history

cc @rust-lang/rustfmt @rust-lang/style

@calebcartwright calebcartwright added A-edition-2024 Area: The 2024 edition A-rustfmt Area: Rustfmt C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC I-style-nominated Nominated for discussion during a style team meeting. S-tracking-impl-incomplete Status: The implementation is incomplete. S-tracking-needs-documentation Status: Needs documentation. T-style Relevant to the style team, which will review and decide on the PR/issue. labels Oct 31, 2024
@calebcartwright
Copy link
Member Author

Similar to my comment in #132380 (comment), I will note that we have already done the development for this and have been testing and reviewing the testing results with the style team.

Going to keep the impl-incomplete label until implementation is merged though

@calebcartwright calebcartwright self-assigned this Oct 31, 2024
@joshtriplett
Copy link
Member

@ytmimi
Copy link
Contributor

ytmimi commented Dec 4, 2024

@calebcartwright was the plan to default where_single_line=true for style_edition=2024 in rustfmt? Should be a one line change:

https://github.com/rust-lang/rustfmt/blob/9f8fcc2f3e7c7ff48412c30cfda67306d8e3320f/src/config/options.rs#L622

-    WhereSingleLine, bool, _ => false;
+    WhereSingleLine, bool, Edition2024 =>  true, _ => false;

That said, I took a look at #119515, and rustfmt doesn't yet format single line where clauses for associated types:

If an associated type is short, has no =, and has a where clause with only
one entry, format the entire type declaration including the where clause on
the same line if it fits:

type Item<'a> where Self: 'a;
type Item<'a>: PartialEq + Send where Self: 'a;

If the associated type has a =, or if the where clause contains multiple
entries, format it across multiple lines as with a type alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition A-rustfmt Area: Rustfmt C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC I-style-nominated Nominated for discussion during a style team meeting. S-tracking-impl-incomplete Status: The implementation is incomplete. T-style Relevant to the style team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants