-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
style-guide: Format single associated type where
clauses on the same line
#119515
style-guide: Format single associated type where
clauses on the same line
#119515
Conversation
r? @yaahc (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/doc/style-guide cc @rust-lang/style |
5010ff3
to
6324736
Compare
☔ The latest upstream changes (presumably #119837) made this pull request unmergeable. Please resolve the merge conflicts. |
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Just curious about the reasoning here fn count(self) -> usize
where
Self: Sized,
{
todo!()
} Why exclude functions with bodies, and why not allow |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Please rebase, then r=me. @rustbot author |
@joshtriplett any updates on this? this is ready for a merge and has been approved but requires a rebase before that |
…e line In particular, lifetime-generic associated types often have a `where Self: 'a` bound, which we can format on the same line.
Show an example that has bounds.
Suggested-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
a74515a
to
163b1a6
Compare
Rebased. |
@bors merge r=compiler-errors |
@bors r+ |
…-clause-same-line, r=compiler-errors style-guide: Format single associated type `where` clauses on the same line In particular, lifetime-generic associated types often have a `where Self: 'a` bound, which we can format on the same line.
@pitaj This was intended as a narrow fix for making GATs simpler to write and read. The rationale for excluding functions with bodies is the same as the rationale for excluding types that have an Separate from that: Putting a function's |
A more complex function signature would also be more likely to spill into the next line. The argument seems to apply equally regardless of whether the function has a body or not. |
The argument I wrote above was in response to the idea of writing fn count(self) -> usize
where Self: Sized
{
todo!()
} I'd make a different argument about why not to write: fn count(self) -> usize where Self: Sized
{
todo!()
} That argument would mostly be "that function already has a body, so it's already spread over several lines and has a blank line separating it from other functions, so the incremental value of putting By contrast, if you have: fn count(self) -> usize where Self: Sized;
fn recount(self) -> usize where Self: Sized;
fn turn_purple(&mut self); I think that's more readable than breaking each of the |
…-clause-same-line, r=compiler-errors style-guide: Format single associated type `where` clauses on the same line In particular, lifetime-generic associated types often have a `where Self: 'a` bound, which we can format on the same line.
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#119515 (style-guide: Format single associated type `where` clauses on the same line) - rust-lang#119959 ([meta] Clarify prioritization alert) - rust-lang#123817 (Stabilize `seek_seek_relative`) - rust-lang#124532 (elaborate obligations in coherence) - rust-lang#125063 (Don't call `env::set_var` in `rustc_driver::install_ice_hook`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#119515 (style-guide: Format single associated type `where` clauses on the same line) - rust-lang#119959 ([meta] Clarify prioritization alert) - rust-lang#123817 (Stabilize `seek_seek_relative`) - rust-lang#125063 (Don't call `env::set_var` in `rustc_driver::install_ice_hook`) - rust-lang#125071 (Migrate rustdoc target spec json path) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119515 - joshtriplett:style-guide-gat-where-clause-same-line, r=compiler-errors style-guide: Format single associated type `where` clauses on the same line In particular, lifetime-generic associated types often have a `where Self: 'a` bound, which we can format on the same line.
In particular, lifetime-generic associated types often have a
where Self: 'a
bound, which we can format on the same line.