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, round 2
This time we try to clean up a lot of the README, after its structure
was reorged in #4345.
cc @calebcartwrightCloses#4336
* fixup! Update documentation, round 2
directory and it will apply the options in that file. See the [config website](https://rust-lang.github.io/rustfmt/)
136
+
for all available options.
116
137
117
138
By default, Rustfmt uses a style which conforms to the [Rust style guide][style
118
139
guide] that has been formalized through the [style RFC
119
-
process][fmt rfcs].
140
+
process][fmt RFCs].
120
141
121
142
Configuration options are either stable or unstable. Stable options can always
122
143
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).
@@ -125,6 +146,28 @@ Unstable options are not available on stable/beta with Rustfmt v1.x.
125
146
126
147
See the configuration documentation on the Rustfmt [GitHub page](https://rust-lang.github.io/rustfmt/) for details (look for the `unstable_features` section).
127
148
149
+
### Differences in rustfmt versions
150
+
151
+
#### Default formatting of submodules
152
+
153
+
On an invocation `rustfmt lib.rs`, rustfmt 1.x would format both "lib.rs" and any out-of-file
154
+
submodules referenced in "lib.rs", unless the `skip_children` configuration option was true.
155
+
156
+
With rustfmt 2.x, this behavior requires the `--recursive` flag (#3587). By default, out-of-file
157
+
submodules of given files are not formatted.
158
+
159
+
Note that this only applies to the `rustfmt` binary, and does not impact `cargo fmt`.
160
+
161
+
#### Construction of config options
162
+
163
+
Rustfmt 1.x uses only the configuration options declared in the rustfmt configuration file nearest
164
+
the directory `rustfmt` is invoked.
165
+
166
+
Rustfmt 2.x merges configuration options from all configuration files in all parent directories,
167
+
with configuration files nearer the current directory having priority.
168
+
169
+
Please see [Configurations](https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#configuration-file-resolution) for more information and #3881 for the motivating issue.
170
+
128
171
### Rust's Editions
129
172
130
173
Rustfmt is able to pick up the edition used by reading the `Cargo.toml` file if
@@ -134,28 +177,13 @@ needs to be specified in `rustfmt.toml`, e.g., with `edition = "2018"`.
134
177
## Limitations
135
178
136
179
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.
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
180
+
doesn't even need to compile! However, there are some things that
181
+
Rustfmt can't do or can't do well. The following list enumerates such limitations:
182
+
183
+
* A program where any part of the program does not parse (parsing is an early
149
184
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
185
* Any fragment of a program (i.e., stability guarantees only apply to whole
156
186
programs, even where fragments of a program can be formatted today).
0 commit comments