Skip to content

Add style guide for default field values#149423

Open
agraven wants to merge 2 commits intorust-lang:mainfrom
agraven:style-guide-default-field-values
Open

Add style guide for default field values#149423
agraven wants to merge 2 commits intorust-lang:mainfrom
agraven:style-guide-default-field-values

Conversation

@agraven
Copy link

@agraven agraven commented Nov 28, 2025

Tracking issue: #132162

See in particular rust-lang/style-team#205.

@rustbot
Copy link
Collaborator

rustbot commented Nov 28, 2025

Some changes occurred in src/doc/style-guide

cc @rust-lang/style

@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 Nov 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 28, 2025

r? @traviscross

rustbot has assigned @traviscross.
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

@traviscross traviscross added the I-style-nominated Nominated for discussion during a style team meeting. label Nov 29, 2025
long_name:
LongType,
LongType =
long_expr,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this line have an extra indent?

Copy link
Author

Choose a reason for hiding this comment

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

I was following the example of the style guide for let statements. I do think the extra indent would be arguably slightly nicer but consistency feels more important to me.

let pattern:
    Type =
    expr;

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, that makes a lot of sense, but I also didn't know this was the current precedent. I also definitely was not fully awake when I was reading this, so, keeping in mind that it's both a type and a value, I think this is very reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the style team, we've been wanting to move the = to the start of the next line rather than the end of the preceding one in the next style edition. Since this is a new thing we're formatting, perhaps we should consider doing that here too, in the spirit of prioritizing inter-edition consistency over intra-edition consistency.

cc @rust-lang/style

Copy link
Author

Choose a reason for hiding this comment

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

I am fine with doing that. Is this something that requires consensus from the team first, or should I just go ahead and do it?

Copy link
Member

Choose a reason for hiding this comment

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

@agraven Please do go ahead and make the change. We talked about this in the style team meeting, and we're reasonably confident we'd like to 1) change this to have = at the start of the line with the expr and 2) indent an extra time if breaking for both the type and the expr, per @estebank's example in the issue that led to this.

Once that change is made, we're happy to start an FCP on this.

Copy link
Author

Choose a reason for hiding this comment

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

@agraven agraven force-pushed the style-guide-default-field-values branch from 0fb8104 to 221138d Compare February 22, 2026 15:59
@rustbot
Copy link
Collaborator

rustbot commented Feb 22, 2026

This PR was rebased onto a different main 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.

The example changed to break before the `=`, but the text still said "after"; fix it to say "before the =".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants