Skip to content
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

Merged
merged 3 commits into from
Jan 24, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions text/0000-customisability.md
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
Copy link

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 but rustfmt. 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?

Copy link
Member Author

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, but rustc the command line.

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 named rustfmt so that solidifies the name to me.

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
Copy link

Choose a reason for hiding this comment

The 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.
Copy link

Choose a reason for hiding this comment

The 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".

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Copy link

Choose a reason for hiding this comment

The 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.)

Copy link
Member Author

Choose a reason for hiding this comment

The 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
Copy link
Member

@aturon aturon Oct 25, 2016

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

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

the decision is treated as legitimate and the community abides by it, even if individuals disagree.

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.
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

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

A bit of bikeshedding: Any consideration for .rustfmt.toml? I'm not convinced one or the other is better, but it might be good to list it as an alternative.

Copy link
Member Author

Choose a reason for hiding this comment

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

both work, as described in the details section

Copy link
Member

Choose a reason for hiding this comment

The 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.