-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC process for formatting style and Rustfmt defaults #1607
Conversation
formatting, and default settings for Rustfmt. The outcome of the process should be an approved formatting style defined by a style guide and enforced by Rustfmt. This RFC proposes creating a new repository under the [rust-lang](https://github.com/rust-lang) organisation called fmt-rfcs. It will be operated in a similar manner to the [RFCs repository](https://github.com/rust-lang/rfcs), but restricted to formatting issues. A new [sub-team](https://github.com/rust-lang/rfcs/blob/master/text/1068-rust-governance.md#subteams) will be created to deal with those RFCs. Both the team and repository are expected to be temporary. Once the style guide is complete, the team can be disbanded and the repository frozen.
This process is specifically limited to formatting style guidelines which can be | ||
enforced by Rustfmt with its current architecture. Guidelines that cannot be | ||
enforced by Rustfmt without a large amount of work are out of scope, even if | ||
they only pertain to formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? I'm okay (might want to check with other maintainers) with having clippy constrained by the style rfcs, and allowing any kind of style rfc that can be enforced by rustfmt or clippy (which together should cover most style guidelines except for those pertaining to overall design).
I do intend to write up a huge clippy rfc for deciding defaults at some point, but if this existed it might be possible in a more incremental fashion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered a broader focus for the style team - including lints and unenforceable conventions. However, after some discussion, we thought it would be better to keep the style team as focussed as possible in order to get a quick resolution and to be really clear about the scope of the process.
This answers my question on how to choose the right defaults for my take on rust-lang/rustfmt#298 then, I guess. 👍 |
Has anyone considered a kind of "crater for rustfmt"? We could take a sampling of crates and see how large the diff is when applying various defaults. That would give a sense of what the community actually thinks about style guidelines, when styling code by hand. |
One question about the scope of RFCs: I imagine that there will be some topics -- such as appropriate places for line-breaking -- that cut across a lot of different areas, but which ought nonetheless to be considered as a unit. It seems like this would be a good topic for an RFC, but it seems to run somewhat counter to this wording:
|
I'm really excited about this approach to settling on a consensus format. While rustfmt is a useful tool even if everyone configures it differently, (1) defaults matter and (2) achieving community buy-in for a standard format can reduce needless friction in the ecosystem (e.g., as experienced when moving between projects that are styled in radically different ways). Standardized formatting, of course, been a point of pride for Go; I'm excited about taking a Rustaceous approach to get there, deciding via community-driven RFCs. The RFC doesn't emphasize it other than in the summary, but a key point is that the proposed subteam is temporary and has a very clear end goal -- the production of a style guide that is enforced by rustfmt (at least in its default configuration). This is the first proposal for a "strike team":
I think this is a great model for focusing the community's attention on an area that needs specific, limited work. I was initially skeptical about introducing a separate RFC repo, but the detailed process that @nrc is proposing seems quite plausible, and does seem to profit from separating out the traffic from our existing venues. I like that we both end up with a single coherent specification (the style guide) but also have the repo for historical information about how we arrived at that consensus. Probably my biggest concern is making sure we have a strong "overall vision" and not just isolated RFCs that don't coordinate well -- but I see that @nikomatsakis just made essentially the same point. |
As a counter to the strong overall vision; I would worry, as a user of Rust, that any team made up of core Rust people would end up making a style which is similar to rustc style (which I personally, and many rust people I know, don't like), which I don't think is the right way to go. I'd much rather be able to speak in an open, RFC style, versus being dictated to. |
@ubsan I think there must be some misunderstanding -- I wasn't suggesting that the overall vision should be set outside of the RFC process -- in fact I was saying the opposite. The RFCs in the strike team shouldn't necessarily be limited in the way that this RFC suggests, but should instead include style striketeam RFCs on the larger vision that the entire community can weigh in on. |
IIRC the reason people don't like rustc style is because it isn't a style at all; it's a mishmash of styles from various points of time in the evolution of rust. New rust PRs seem to have a style more or less consistent with the ecosystem. Legacy style is irrelevant here. |
I, like @aturon, was somewhat skeptical of a whole subteam and extra repo for coordinating this, but due to what I suspect is the high level of traffic this will receive that we'll want a high signal-to-noise ratio which somewhat necessitates splitting it from the main repo. In other words, it sounds like a reasonable idea to me! |
@aturon Ah, then I'm fine :) I just didn't want a core team to override the feelings of the community. @Manishearth No, I'm talking modern rustc style. |
There is one thing I think rustfmt does wrong: removing trailing commas. |
@ticki The only place I can think where rustfmt removes trailing commas is after curly-brace-blocks in match arms. In other contexts, like multi-line arrays or function argument lists (at definitions or calls), it adds commas so that every line ends in a comma. |
It removes it in |
@ticki I don't believe you recall correctly. See http://is.gd/b9IQdf and hit the format button. It makes sure every Like I said before, it removes the trailing comma after the curly-brace-block |
It also removes trailing commas from function argument lists (declarations On Mon, May 9, 2016 at 3:38 PM, Scott Olson notifications@github.com
|
@durka Ah, yes, because it doesn't block-indent multiline argument lists by default. Nothing with the trailing delimiter on the same line would have a trailing comma. Presumably it would keep trailing commas in the case where you enabled that option, like this: foo(
some_long_expression(),
long_enough_to_be_multiline(),
); EDIT: If it removes them in this case with this option, it's just a simple bug/inconsistency with the handling of trailing commas elsewhere. Anyway, this is definitely a detail too specific for this general RFC. |
No, it still removes them in that case. Anyway this isn't important to On Mon, May 9, 2016 at 4:02 PM, Scott Olson notifications@github.com
|
* the language, tools, and libraries sub-teams (since each has a stake in code style), | ||
* large Rust projects. | ||
|
||
Because activity such as this hasn't been done before in the RUst community, it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "RUst"
This basically looks ok to me, with a few concerns: This establishes an official team, with a page on the website and all, for a very narrow purpose. What's the purpose of creating a team? Do we feel that people won't be motivated to work on it if they don't get a picture on the web site? Do we feel that the team won't be seen as legitimate? This RFC focuses on breaking down style decisions into very-fined grained decisions, but style is not such a local decision - every style decision affects the appearance of every other. I'd like this RFC to address how the overall quality will be kept in check. Just as an example, perhaps the team is maintaining a rustfmt'd integration test that exhaustively shows all styles together, that gets reviewed with each new RFC, or maybe a corpus of real-world code that does the same. |
Hmm, not that I care too much, but I did not envision this strike team being listed on the web page along with the other teams, nor do I envision having the other "random bits of stuff" that come with a subteam (e.g. git alias). This is just because it's work to maintain and the team is temporary. I think the purpose of having a team is just to clarify where the ultimate decision-making power on the matter of formatting decisions resides. (Like any team, I would expect that the process would be open, and would take into account objections from the entire community.) |
So @wycats raised an interesting point in discussion. He -- and many others I know -- are of the opinion that rustfmt should not have any options; or, at minimum, if you want to have options, you should have to install a distinct tool ( Now, it seems like settling this question is orthogonal to this particular RFC -- at least, it seemed so to me, at first. I imagined that we would settle this default question separately (personally, I'd probably like to remove the options, because I buy into that reasoning above, but I don't care that much tbh). But @wycats pointed out that deciding on a particular default or format setting is very different in a context where you expect people to configure from another context. So if we wind up making this decision after a number of formatting decisions have been made, we might find we want to revisit those decisions. Therefore, I'd like to propose that we discuss this question of whether to remove configurability a bit. I could imagine adding such a clause into this RFC itself. I could also imagine raising this question as one of the first points of discussion for the new team. |
(Other than the point about options, I think that all of @rust-lang/core at least is pretty comfortable with the idea of EDIT: Corrected amusing typo. :) |
😂
Wouldn't an option-less rustfmt require us to decide on a formatting profile, too, one way or another? |
@8573 I don't think anyone is currently arguing for never providing knobs in rustfmt (speak up if you are!). So yes, I was referring to the speedbump. |
@aturon - I think you summed it up quite well there. No objections from my side. |
The RFC still frames the strike team as a new subteam. I prefer not to set the precedent that 'strike teams' are subteams. I do want to empower people to make decisions, and to give them credit, but prefer not to create increasingly special-purpose teams. Can we remove the language making the strike team a subteam? For comparison, the unsafe strike team RFC does not establish a new subteam. Both of these are going to be setting precedent. I also think it is desirable for strike team RFCs to lay out the conditions for concluding their work and disbanding, similar to charters for things like IETF work groups. |
@brson I agree with the "strike teams are not subteams", but for a different reason. I think that the subteams should start to step down over the next ten years, and strike teams should start to take their place - specialized teams which can focus on a specific area, rather than the "lang team, responsible for designing new language features". This would bring our model more in line with modern C++, which is a language that's had a crazy transformation from C++03 to C++14 standardization processes, and whose standardization process works really well. I don't agree strike teams should lay out the conditions for concluding their work, in other terms. |
rustfmt seems pretty uninteresting to me if it's not a ticket to having my code formatted in a way that's acceptable to 100% of the rust community. there's formatters for all kinds of languages and most people totally ignore them and most lang communities never agree on configuring them, gofmt probably only works because you don't have to think about formatting politics. future generations of rust programmers won't thank us if we fragment the community along formatting lines just to preserve the preferred style of present-day codebases |
I'm sorry if this has already come up, I've only skimmed this thread, but I'd love to see a method to disable automatic formatting in certain places, something like |
@hoodie you can do that with the |
@brson it's unclear to me exactly what it means that a strike team is or is not a sub-team. I mean they are both teams of people working on a facet of Rust, they both have authority (thought not total authority in either case) to make decisions. Clearly a strike team should have limited scope in both time and jurisdiction, but that doesn't seem enough to explicitly say "is not". As far as I see it, calling a strike team a (temporary) sub-team is a way to re-use the technical and social infrastructure we have in place, rather than having to recreate that infrastructure. If there are specific aspects of being a sub-team you think we'd be better not to emulate, then I think it makes sense to call them out, that seems preferable to starting from scratch with strike teams. |
@nrc I'm warming up to the idea of lots of teams, some of them being temporary. I wouldn't mind adding an unsafe team and rustfmt team to teams.html, as long as their scope is clear, and as a project we're making this expansion intentionally, and the other RFC is aligned. It feels though like there are policy issues to be resolved about what it means to be a team that are larger than this RFC. I've left some similar comments on the other RFC. |
Whatever style you pick here, please don't use egyptian brackets. It just looks horrible everywhere. |
@Darkstalker This comment thread isn't the right place to work out which particular style choices should be default. Hold those thoughts for the fmt-rfcs process this RFC is proposing. I feel compelled to add, "looks horrible" comments ought to be ignored. If you want to have a voice, at least bring something meaningful to the conversation. |
I'm 👍 on the idea of having a strike team to work out the "default and recommended style" for Rust programs. I am fine with rustfmt permitting knobs by default, but I think we should strongly encourage people not to use them. I suspect few people will anyhow, both because it would bring their code out of sync with the mainstream, and because it's just that much more annoying to have to set them up. I do wonder: once we settle on a default style, I imagine there may be future questions that arise -- or corner cases that were not considered. Is there a plan for resolving those questions? Maybe this won't really be a big problem? |
Could vertically align be considered? Many people love it. Especially in the match block with one line branches. |
This discussion isn't for defining the standards, just for defining the process by which we define the standards. I would suggest opening an issue on rustfmt itself to make this an option first. |
@aturon It seems that the conclusion to the 'should there be knobs' is unchanged, and a qualified 'yes'. I would suggest this should be clarified in one of the first style team RFCs. Another question that has been asked is 'what, precisely is the duration of the team and what happens after?' I suggest that the duration should be one year, and at the end of that time responsibility for style team issues should go the tools team, unless the core team decide otherwise at the time. The objective is that there should be a fairly complete set of style guidelines by then, and that these will be in maintenance mode after a year (I foresee changes being needed due to new language features and due to technical changes as Rustfmt evolves. I expect both could be managed by PRs to the style repo, shepherded by the tools team). Are there other questions that need resolving here? If not and the above is acceptable, I can update the RFC. |
Some thoughts:
|
Please read the final RfC decision. All the points you mention have been discussed before; the final comment period is not for rehashing resolved discussions.
Nobody is doing that.
This is not the final decision, if you read the thread. The decision is to have a "strongly recommended set of defaults". The usage of the word "defaults" implies that it is configurable. |
Can't we just hire Rob Pike to dictate the format we should use? I think having a solidified, discussed and final format is critical for rust's growth. I strongly support the strike team and think this is something that needs to be solved as soon as possible. |
Huzzah! The @rust-lang/core team has decided to accept this RFC. The main controversial issues have been about what kinds of knobs to provide, how to make them accessible, and the "permanency" and scope of the strike team being forced. The general conclusions:
|
For those on this thread who are interested in participating in the style/formatting process, it is now underway and the style team has been formed. The repo where we're working is https://github.com/rust-lang-nursery/fmt-rfcs and we discuss in #rust-style on irc. |
This RFC proposes a process for deciding detailed guidelines for code
formatting, and default settings for Rustfmt. The outcome of the process should
be an approved formatting style defined by a style guide and enforced by
Rustfmt.
Rendered