Add style guide for default field values#149423
Add style guide for default field values#149423agraven wants to merge 2 commits intorust-lang:mainfrom
Conversation
|
Some changes occurred in src/doc/style-guide cc @rust-lang/style |
|
r? @traviscross rustbot has assigned @traviscross. Use |
src/doc/style-guide/src/items.md
Outdated
| long_name: | ||
| LongType, | ||
| LongType = | ||
| long_expr, |
There was a problem hiding this comment.
Shouldn't this line have an extra indent?
There was a problem hiding this comment.
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;There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
0fb8104 to
221138d
Compare
|
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 =".
Tracking issue: #132162
See in particular rust-lang/style-team#205.