Skip to content

Conversation

epage
Copy link
Contributor

@epage epage commented Aug 19, 2025

Taken from a style team discussion.

Assumptions on my part:

  • I specify that frontmatter fences should not have trailing whitespace
  • We aren't specifying when to include the infostring (one idea being if there is no shebang)
  • Keep it simple and have a single example instead of showing allowed several variations

Tracking issue: #136889

Closes rust-lang/style-team#212

@epage epage added the F-frontmatter `#![feature(frontmatter)]` label Aug 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 19, 2025

r? @calebcartwright

rustbot has assigned @calebcartwright.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-style Relevant to the style team, which will review and decide on the PR/issue. labels Aug 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 19, 2025

Some changes occurred in src/doc/style-guide

cc @rust-lang/style

@rustbot

This comment has been minimized.

@epage
Copy link
Contributor Author

epage commented Aug 19, 2025

CC @calebcartwright

From rust-lang/style-team#212 (comment)

Before anything else, let's confirm if @calebcartwright is in agreement with the above.

@joshtriplett
Copy link
Member

joshtriplett commented Aug 21, 2025

I don't need to specify the lack of trailing spaces after the code fence / infostring

We don't actually have a general specification of that anywhere (just one specific to doc comments), so it may be worth specifying, until we add a more general prohibition.

We aren't specifying when to include the infostring (one idea being if there is no shebang)

I don't think we should specify whether to include or exclude the infostring; that's outside the scope of formatting (at least, until a hypothetical future in which we know how to format certain types of infostrings).

Keep it simple and have a single example instead of showing allowed several variations

Seems fine.

@traviscross
Copy link
Contributor

We don't actually have a general specification of that anywhere (just one specific to doc comments), so it may be worth specifying, until we add a more general prohibition.

Agreed. I'd want rustfmt to normalize out trailing spaces.

@joshtriplett
Copy link
Member

#145735

jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 25, 2025
test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (rust-lang#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: rust-lang#136889
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 26, 2025
test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (rust-lang#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: rust-lang#136889
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 26, 2025
test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (rust-lang#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: rust-lang#136889
rust-timer added a commit that referenced this pull request Aug 26, 2025
Rollup merge of #145766 - epage:rustfmt, r=calebcartwright

test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: #136889
@rustbot

This comment has been minimized.

github-actions bot pushed a commit to rust-lang/compiler-builtins that referenced this pull request Aug 28, 2025
test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (rust-lang/rust#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: rust-lang/rust#136889
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

Taken from [a style team
discussion](rust-lang/style-team#212 (comment)).

Assumptions on my part:
- I don't need to specify the lack of trailing spaces after the code
  fence / infostring
- We aren't specifying when to include the infostring (one idea being if
  there is no shebang)
- Keep it simple and have a single example instead of showing allowed several
  variations
@rustbot
Copy link
Collaborator

rustbot commented Sep 4, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

fmease added a commit to fmease/rust that referenced this pull request Sep 5, 2025
…whitespace, r=joshtriplett

style-guide: Document absence of trailing whitespace

We didn't previously have a blanket prohibition on trailing whitespace. Adding
one, inspired by discussion in rust-lang#145617 .
rust-timer added a commit that referenced this pull request Sep 6, 2025
Rollup merge of #145735 - joshtriplett:style-guide-trailing-whitespace, r=joshtriplett

style-guide: Document absence of trailing whitespace

We didn't previously have a blanket prohibition on trailing whitespace. Adding
one, inspired by discussion in #145617 .
mohe2015 pushed a commit to tucan-plus/rustfmt that referenced this pull request Sep 6, 2025
test(rustfmt): Verify frontmatter is preserved

This is to prove that the frontmatter is preserved.

The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters (rust-lang/rust#145617).

While rustfmt is developed in a different repo, work involving upstream integration is blocked on some work that is being finished up in that repo.  I was told that it would be ok to post against this repo in the mean time.

Tracking issue: rust-lang/rust#136889
@traviscross traviscross added the I-style-nominated Nominated for discussion during a style team meeting. label Sep 24, 2025
@traviscross
Copy link
Contributor

Let's do it. In particular, we're deciding to accept the following set of decisions, from rust-lang/style-team#212 (comment):

  1. The Style Guide should require zero blank lines before frontmatter. (That's true whether there's a shebang or not.)

  2. The Style Guide should require normalizing blank lines after frontmatter to reduce more-than-one blank line down to one blank line, but should allow either zero or one blank lines after frontmatter, without prescribing whether it should be zero or one. (For precedent here, we're using the current handling of blank lines around inner/outer doc comments.)

  3. The Style Guide should require exactly one space between the opening dashes and the infostring. Looking at many examples, this felt substantially different from markdown's triple-backquotes, which didn't feel "attached" to the infostring. Dashes feel more "attached" to the infostring, perhaps because of mental lexing of command-line options. This also seemed better for infostrings that look like filenames (e.g. starting with a / or .). We initially were inclined to allow zero-or-one, or even normalize to zero, but then we looked at actual code in context in a code editor rather than on github or markdown, and rapidly changed our minds because zero spaces felt wrong.

  4. The Style Guide should require normalizing the number of matching dashes before and after the frontmatter to the minimum number needed to unambiguously delimit the frontmatter. (For instance, use 4 dashes if the frontmatter contains 3 dashes.)

@rfcbot fcp merge

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Sep 24, 2025

Team member @traviscross 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.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Sep 24, 2025
@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 24, 2025
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Oct 4, 2025
@rust-rfcbot
Copy link
Collaborator

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.

Comment on lines +17 to +23
There should be no blank lines between the frontmatter and either the start of the file or a shebang.
There can be zero or one line between the frontmatter and any following content.

The frontmatter fences should use the minimum number of dashes necessary for the contained content (one more than the longest series of initial dashes in the
content, with a minimum of 3 to be recognized as frontmatter delimiters).
If an infostring is present after the opening fence, there should be one space separating them.
The frontmatter fence lines should not have trailing whitespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of the style guide is consistently wrapped at 80 columns. The remainder of this chapter, though, is not hard wrapped at all. It seems we should do one of the two.

@joshtriplett, do you have thoughts about the style guide for the style guide?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's ever anything that's been enforced (once upon a time before the style guide was in this repo I'd merge text and modify it after versus asking the author).

If we are going to try to maintain consistency then maybe it could be incorporated into the tidy checks someday?

For now my .02 would be to proceed and circle back to it if/when we make that decision

Copy link
Contributor

Choose a reason for hiding this comment

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

(once upon a time before the style guide was in this repo I'd merge text and modify it after versus asking the author).

Similarly to that, we could push a commit ourselves to this branch doing it, then merge it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's ever anything that's been enforced...

I had looked through all the chapters before asking. They're mostly wrapped at 80, with a handful of sections wrapped closer to 90 or 95, and then there's the types chapter where two sections are unwrapped and the nightly chapter that is unwrapped.

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. F-frontmatter `#![feature(frontmatter)]` finished-final-comment-period The final comment period is finished for this PR / Issue. I-style-nominated Nominated for discussion during a style team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-style Relevant to the style team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styling of Rust Frontmatter

6 participants