You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update documentation
This commit includes changes to the readme, cargo-fmt, and rustfmt
- Readme
- rearrange sections to an order I believe is a more natural
progression (this is opinionated, open to suggestions)
- add a TOC (I can add a CI test to ensure it's up to date, lmk what
you think)
- cargo-fmt
- link to config options
- rustfmt
- elaborate on operation with files/stdin
- include examples
- link to config options
Closes#4336
* fixup! Update documentation
* fixup! Update documentation
* fixup! Update documentation
By default, Rustfmt uses a style which conforms to the [Rust style guide][style
118
+
guide] that has been formalized through the [style RFC
119
+
process][fmt rfcs].
120
+
121
+
Configuration options are either stable or unstable. Stable options can always
122
+
be used on any channel. Unstable options are always available on nightly, but can only be used on stable and beta with an explicit opt-in (starting in Rustfmt v2.0).
123
+
124
+
Unstable options are not available on stable/beta with Rustfmt v1.x.
125
+
126
+
See the configuration documentation on the Rustfmt [GitHub page](https://rust-lang.github.io/rustfmt/) for details (look for the `unstable_features` section).
127
+
128
+
### Rust's Editions
129
+
130
+
Rustfmt is able to pick up the edition used by reading the `Cargo.toml` file if
131
+
executed through the Cargo's formatting tool `cargo fmt`. Otherwise, the edition
132
+
needs to be specified in `rustfmt.toml`, e.g., with `edition = "2018"`.
133
+
134
+
## Limitations
135
+
136
+
Rustfmt tries to work on as much Rust code as possible. Sometimes, the code
137
+
doesn't even need to compile! As we approach a 1.0 release we are also looking
138
+
to limit areas of instability; in particular, post-1.0, the formatting of most
139
+
code should not change as Rustfmt improves. However, there are some things that
140
+
Rustfmt can't do or can't do well (and thus where formatting might change
141
+
significantly, even post-1.0). We would like to reduce the list of limitations
142
+
over time.
123
143
144
+
The following list enumerates areas where Rustfmt does not work or where the
145
+
stability guarantees do not apply (we don't make a distinction between the two
146
+
because in the future Rustfmt might work on code where it currently does not):
147
+
148
+
* a program where any part of the program does not parse (parsing is an early
149
+
stage of compilation and in Rust includes macro expansion).
150
+
* Macro declarations and uses (current status: some macro declarations and uses
151
+
are formatted).
152
+
* Comments, including any AST node with a comment 'inside' (Rustfmt does not
153
+
currently attempt to format comments, it does format code with comments inside, but that formatting may change in the future).
154
+
* Rust code in code blocks in comments.
155
+
* Any fragment of a program (i.e., stability guarantees only apply to whole
156
+
programs, even where fragments of a program can be formatted today).
here, but do not have the test coverage or experience to be 100% sure).
159
+
* Bugs in Rustfmt (like any software, Rustfmt has bugs, we do not consider bug
160
+
fixes to break our stability guarantees).
124
161
125
162
## Running Rustfmt from your editor
126
163
@@ -131,7 +168,6 @@ completed without error (whether or not changes were made).
131
168
* Visual Studio Code using [vscode-rust](https://github.com/editor-rs/vscode-rust), [vsc-rustfmt](https://github.com/Connorcpu/vsc-rustfmt) or [rls_vscode](https://github.com/jonathandturner/rls_vscode) through RLS.
132
169
*[IntelliJ or CLion](intellij.md)
133
170
134
-
135
171
## Checking style on a CI server
136
172
137
173
To keep your code base consistently formatted, it can be helpful to fail the CI build
@@ -197,32 +233,6 @@ CFG_RELEASE_CHANNEL=nightly CFG_RELEASE=1.45.0-nightly cargo test --all-features
197
233
To run rustfmt after this, use `cargo run --bin rustfmt -- filename`. See the
198
234
notes above on running rustfmt.
199
235
200
-
201
-
## Configuring Rustfmt
202
-
203
-
Rustfmt is designed to be very configurable. You can create a TOML file called
204
-
`rustfmt.toml`or `.rustfmt.toml`, place it in the project or any other parent
205
-
directory and it will apply the options in that file. See `rustfmt
206
-
--help=config` for the options which are available, or if you prefer to see
By default, Rustfmt uses a style which conforms to the [Rust style guide][style
210
-
guide] that has been formalized through the [style RFC
211
-
process][fmt rfcs].
212
-
213
-
Configuration options are either stable or unstable. Stable options can always
214
-
be used on any channel. Unstable options are always available on nightly, but can only be used on stable and beta with an explicit opt-in (starting in Rustfmt v2.0).
215
-
216
-
Unstable options are not available on stable/beta with Rustfmt v1.x.
217
-
218
-
See the configuration documentation on the Rustfmt [GitHub page](https://rust-lang.github.io/rustfmt/) for details (look for the `unstable_features` section).
219
-
220
-
### Rust's Editions
221
-
222
-
Rustfmt is able to pick up the edition used by reading the `Cargo.toml` file if
223
-
executed through the Cargo's formatting tool `cargo fmt`. Otherwise, the edition
224
-
needs to be specified in `rustfmt.toml`, e.g., with `edition = "2018"`.
225
-
226
236
## Tips
227
237
228
238
* For things you do not want rustfmt to mangle, use `#[rustfmt::skip]`
0 commit comments