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

Closed
1 of 4 tasks
calebcartwright opened this issue Oct 31, 2024 · 5 comments
Closed
1 of 4 tasks

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

calebcartwright opened this issue Oct 31, 2024 · 5 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.

@traviscross
Copy link
Contributor

Reminder: There are only 12 days left until the branch date for Rust 1.85. Anything not in master at that point will not make it into Rust 2024 unless it is accepted by compiler according to the conventions for backports to beta.

I.e., this item is in jeopardy.

@traviscross
Copy link
Contributor

traviscross commented Dec 30, 2024

This item unfortunately isn't going to make Rust 2024 (or, equivalently, the Style Edition 2024), given that it's not implemented in nightly and the branch date for Rust 1.85 (and Rust 2024) is 2025-01-03.

Hopefully this item can be included in a future edition.

We'll be reverting this chapter in the Edition Guide, and the relevant changes will also need to be reverted in the Style Guide.

@rustbot rustbot added A-maybe-future-edition Something we may consider for a future edition. and removed A-edition-2024 Area: The 2024 edition labels Dec 30, 2024
@traviscross traviscross changed the title Tracking Issue for Rust 2024: rustfmt single line where clauses Tracking Issue for future edition: rustfmt single line where clauses Dec 30, 2024
@traviscross traviscross changed the title Tracking Issue for future edition: rustfmt single line where clauses Tracking Issue for Rust 2024: rustfmt single line where clauses Dec 30, 2024
@traviscross traviscross added A-edition-2024 Area: The 2024 edition and removed A-maybe-future-edition Something we may consider for a future edition. labels Dec 30, 2024
@traviscross traviscross closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2024
Noratrieb added a commit to Noratrieb/rust that referenced this issue Dec 31, 2024
…compiler-errors

Revert rust-lang#119515 single line where clause style guide

This did not get implemented for the style edition in 2024, so this PR removes it from the documentation.
See tracking issue rust-lang#132381.

This can be added back in the next edition if it gets implemented. I'm a little unclear on what the style team intends for how future changes are documented. For example, the current style-guide documented behavior that rustfmt does not support. I'm not sure who the audience for this document is, or how this is intended to stay in sync with rustfmt. For example, if I read this and assume this is how it is supposed to work, and then rustfmt breaks that, it seems like that is confusing. Similarly, if I'm staying on an older edition, this documentation would be incorrect for my crate.

Perhaps changes like this could be "teed-up" in a PR, but not merged until the edition is stabilized (similar to how the reference works)? And include notes for parts that are edition-specific (so if I am using an older edition, I can see that something is different). In general, I'm a little confused on how this is intended to work.

Reverts:

- rust-lang#119515
tgross35 added a commit to tgross35/rust that referenced this issue Dec 31, 2024
…compiler-errors

Revert rust-lang#119515 single line where clause style guide

This did not get implemented for the style edition in 2024, so this PR removes it from the documentation.
See tracking issue rust-lang#132381.

This can be added back in the next edition if it gets implemented. I'm a little unclear on what the style team intends for how future changes are documented. For example, the current style-guide documented behavior that rustfmt does not support. I'm not sure who the audience for this document is, or how this is intended to stay in sync with rustfmt. For example, if I read this and assume this is how it is supposed to work, and then rustfmt breaks that, it seems like that is confusing. Similarly, if I'm staying on an older edition, this documentation would be incorrect for my crate.

Perhaps changes like this could be "teed-up" in a PR, but not merged until the edition is stabilized (similar to how the reference works)? And include notes for parts that are edition-specific (so if I am using an older edition, I can see that something is different). In general, I'm a little confused on how this is intended to work.

Reverts:

- rust-lang#119515
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 1, 2025
Rollup merge of rust-lang#134974 - ehuss:revert-single-line-where, r=compiler-errors

Revert rust-lang#119515 single line where clause style guide

This did not get implemented for the style edition in 2024, so this PR removes it from the documentation.
See tracking issue rust-lang#132381.

This can be added back in the next edition if it gets implemented. I'm a little unclear on what the style team intends for how future changes are documented. For example, the current style-guide documented behavior that rustfmt does not support. I'm not sure who the audience for this document is, or how this is intended to stay in sync with rustfmt. For example, if I read this and assume this is how it is supposed to work, and then rustfmt breaks that, it seems like that is confusing. Similarly, if I'm staying on an older edition, this documentation would be incorrect for my crate.

Perhaps changes like this could be "teed-up" in a PR, but not merged until the edition is stabilized (similar to how the reference works)? And include notes for parts that are edition-specific (so if I am using an older edition, I can see that something is different). In general, I'm a little confused on how this is intended to work.

Reverts:

- rust-lang#119515
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

5 participants