-
Notifications
You must be signed in to change notification settings - Fork 56
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
Customisation #33
Customisation #33
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
- Start Date: 2016-10-25 | ||
- RFC Issue: #3 | ||
- RFC PR: | ||
- Implementation Issue: (leave this empty) | ||
|
||
# Summary | ||
[summary]: #summary | ||
|
||
Customisation of Rustfmt should be allowed (via a `rustfmt.toml` file), but not | ||
encouraged. | ||
|
||
|
||
# Details | ||
[details]: #details | ||
|
||
A formatter such as Rustfmt may be customised by the user. These customisations | ||
may be saved for a project using a cusomtisation file. For example, Rustfmt can | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spelling: cusomtisation vs customisation. |
||
be customised by either a `rustfmt.toml` or `.rustfmt.toml` in their project | ||
directory or any parent of that directory. Rustfmt will read options from the | ||
first toml file (scanning up the directory tree). If an option is not present in | ||
the file, Rustfmt uses the default option (as specified by the code style | ||
process RFCs). The set of options available is not specified at this time; it | ||
will be part of the style RFC process to enumerate them. | ||
|
||
A formatting tool may be customised in other ways, but must stick to the options | ||
and defaults specified by the style RFCs. | ||
|
||
Customisation will be documented, but explicitly discouraged. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we go from "not encouraged" to "explicitly discouraged", a somewhat stronger form of "non-encouragement". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think explicit discouragement is what we want. I'll try and make sure this is consistent throughout. |
||
|
||
All official Rust projects which use Rustfmt *must* use the default style and | ||
*must not* include a customisation file. | ||
|
||
# Implementation | ||
[implementation]: #implementation | ||
|
||
Rustfmt already allows customisation via `rustfmt.toml`. There is nothing more | ||
to implement here. Over time, I expect the number of options to be reduced. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it's a noble desire, where I can understand the background thinking for it, I do think the latter sentence represents somewhat unrealistic expectations; I would vote for removing that part. (The number of options are more likely to increase as the adoption rate for Rust increases, or at least stay more-or-less constant. Expecting it to be reduced is expecting people to think more and more the same as time goes by; I'm not sure that's a realistic way of thinking.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant that the RFC process should lead to a reduction, I agree that as time goes by there is likely to be a natural increase. I'll clarify. |
||
|
||
See [config.rs](https://github.com/rust-lang-nursery/rustfmt/blob/master/src/config.rs) | ||
for the definition of the config file. | ||
|
||
# Rationale | ||
[rationale]: #rationale | ||
|
||
Beyond the advantage of automatically formatting code, there is a large | ||
advantage in all code being formatted the same way. This holds within a single | ||
project, and between projects - reading code in a new project is easier if one | ||
does not have to adjust to a new code style at the same time. Since Rust | ||
encourages sharing small crates between projects, this is likely to be a bigger | ||
advantage in Rust than, say, C++. | ||
|
||
However, code style is an intensely subjective matter and many programmers feel | ||
strongly about it. Furthermore, the Rust community encourages diversity, | ||
individualism, and democracy as part of its culture, and tends not to accept | ||
dictated decisions. It is therefore likely that if Rustfmt only enforced a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I have mixed feelings about this paragraph. Rust is not really "democratic" in the typical understanding of the word, but we do closely follow the principles of deliberative democracy via the RFC process. One of the key tenets there is that, after deliberation is complete and a decision is reached, the decision is treated as legitimate and the community abides by it, even if individuals disagree. That's the essence of our RFC process, and the fact that we're using RFCs to determine the standard style means that it's not dictated, but rather deliberated. I also don't quite follow the logic here: is the concern about the standard style being adopted, or the rustfmt tool being adopted? The "it" in the final sentence is unclear on this point, but it seems important. You clarify this some in the paragraph below, but don't really spell out why you believe there's more benefit in more widespread rustfmt usage, how you're gauging the relative sizes of these populations, and what role newcomers to Rust play in this breakdown. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Strong 👍 to all of this, though especially this bit; it's the sentiment I'm getting at here. |
||
single style, it would be rejected by a significant proportion of the community. | ||
|
||
We believe there is more benefit in a large proportion of the community using | ||
Rustfmt in any configuration, than in a small proportion using it in a single | ||
configuration. We also believe that the best approach to encouraging use of the | ||
default style is to lead by example and exert cultural pressure, rather than | ||
enforcement by coercion. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these beliefs axiomatic, or can they be broken down into more detailed rationale? |
||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit of bikeshedding: Any consideration for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both work, as described in the details section There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woops, missed that. I think I need to sleep 💤 |
||
|
||
No customisation is an alternative. However, we believe this will reduce | ||
Rustfmt's usage and users will either fork Rustfmt or move to a more flexible | ||
formatting tool. | ||
|
||
A number of possible 'speed bumps' have been proposed (most are described in | ||
https://github.com/rust-lang-nursery/fmt-rfcs/issues/3). These aim to add a | ||
technical barrier to customisation as well as a social/cultural one. We decided | ||
that any of these measures would be annoying without being effective, and instead | ||
we should rely on cultural pressure. | ||
|
||
# Unresolved questions | ||
[unresolved]: #unresolved-questions | ||
|
||
How should we control the options Rustfmt makes available? I feel that the | ||
current set of options is too large (catering for some very niche formatting, | ||
and imposing a cost in complexity and hugely expanded scope for bugs), and is | ||
not very coherent. We have considered having RFCs include a set of alternatives | ||
that Rustfmt will support, however, it has been suggested that this might make | ||
the alternatives too official and is perhaps beyond the scope of the style RFC | ||
process. |
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.
A bit of a nit: should we really be referring to
rustfmt
as Rustfmt? (I see that https://github.com/rust-lang-nursery/rustfmt also does the same)I find it a bit confusing, since the actual binary you invoke is not
Rustfmt
butrustfmt
. It would feel more consistent to refer to it by the latter form everywhere. Has this been discussed previously and settled to use the initial-capital form?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 think of 'Rustfmt' as the name of the abstract tool, and thus (like all names) should be capitalised.
rustfmt
is the name of the executable and coincidentally has the same name. Similarly we talk about 'Rust' the language, butrustc
the command line.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.
Not that my opinion matters much here but I agree regarding
rustfmt
. The tool (and repo) is namedrustfmt
so that solidifies the name to me.