]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/CHANGELOG.md
Rollup merge of #96719 - mbartlett21:patch-4, r=Dylan-DPC
[rust.git] / src / tools / rustfmt / CHANGELOG.md
1 # Changelog
2
3 ## [Unreleased]
4
5 ## [1.5.0] 2022-06-13
6
7 ### Changed
8
9 - Simplify the rustfmt help text by eliding the full path to the rustfmt binary path from the usage string when running `rustfmt --help` [#5214](https://github.com/rust-lang/rustfmt/issues/5214)
10
11 ### Fixed
12
13 - Remove duplicate imports when `imports_granularity` is set to `Item` [#4725](https://github.com/rust-lang/rustfmt/issues/4725)
14 - Properly handle stdin input containing an inner skip attribute [#5368](https://github.com/rust-lang/rustfmt/issues/5368)
15 - Maintain attributes on imports when `imports_granularity` is set to `Item` [#5030](https://github.com/rust-lang/rustfmt/issues/5030)
16 - Format empty trait definitions as a single line when both `empty_item_single_line` is enabled and `brace_style` is set to `AlwaysNextLine` [#5047](https://github.com/rust-lang/rustfmt/issues/5047)
17 - Don't change granularity of imports containing comments with `imports_granularity` if doing so could lose or misplace those comments [#5311](https://github.com/rust-lang/rustfmt/pull/5311)
18 - Prevent rustfmt from removing trailing comments at the end of files annotated with inner `#![rustfmt::skip]` attributes [#5033](https://github.com/rust-lang/rustfmt/issues/5033)
19 - Fixed various `error[internal]: left behind trailing whitespace"` issues:
20   - Remove trailing whitespace when formatting a where clause who's bounds have an empty right hand side [#5012](https://github.com/rust-lang/rustfmt/issues/5012) [#4850](https://github.com/rust-lang/rustfmt/issues/4850)
21   - Prevent rustfmt from adding an empty comment line when rewriting markdown lists at the start of doc comments. This issue was triggered when `wrap_comments=true` [#5088](https://github.com/rust-lang/rustfmt/issues/5088)
22 - Prevent adding a block indented newline before a function parameter with a complex type that was formatted over multiple lines [#5125](https://github.com/rust-lang/rustfmt/issues/5125)
23 - Fix various module resolution issues preventing rustfmt from finding modules that should be formatted:
24   - Handle external mods imported via external->inline load hierarchy [#5063](https://github.com/rust-lang/rustfmt/issues/5063)
25   - Resolve sub modules of integration tests [#5119](https://github.com/rust-lang/rustfmt/issues/5119)
26   - Module resolution will fallback to the current search directory if a relative directory search results in a `FileNotFound` error [#5198](https://github.com/rust-lang/rustfmt/issues/5198)
27 - Give users a clearer error message when resolving a module who's file path is ambiguous (e.g `x.rs` and `x/mod.rs`). Before users were given a `File not found` error message which was confusing [#5167](https://github.com/rust-lang/rustfmt/issues/5167)
28 - Fix various issues related to type aliases:
29   - Prevent rustfmt from adding `= impl` to associated types defined in macro bodies [#4823](https://github.com/rust-lang/rustfmt/issues/4823)
30   - Properly block indent type alias impl traits (TAITs) that wrap to the next line when `version=Two` is set. Before any trait bounds that wrapped to the next line would not be indented [#5027](https://github.com/rust-lang/rustfmt/issues/5027)
31   - Prevent rustfmt from adding an `impl Trait` definition into types [#5086](https://github.com/rust-lang/rustfmt/issues/5086)
32 - Fix cases where `normalize_comments=true` would de-normalizes some comments by changing inline comments into block comments [#4909](https://github.com/rust-lang/rustfmt/issues/4909)
33 - Prevent rustfmt from wrapping the content of markdown [reference-style links](https://www.markdownguide.org/basic-syntax/#reference-style-links) in doc comments [#5095](https://github.com/rust-lang/rustfmt/issues/5095) [#4933](https://github.com/rust-lang/rustfmt/issues/4933)
34 - Don't format files annotated with inner `#![rustfmt::skip]` attribute [PR #5094](https://github.com/rust-lang/rustfmt/pull/5094)
35 - Prevent duplicate comma when struct pattern ends with `..` and `trailing_comma=Always`. For example, `let Foo { a, .. } = b;` would become `let Foo { a,, .. } = b;` [#5066](https://github.com/rust-lang/rustfmt/issues/5066)
36 - Fix the order of `static` and `async` keywords when rewriting static async closures. The correct order is `static` and then `async` (e.g `static async || {}`) [#5149](https://github.com/rust-lang/rustfmt/issues/5149)
37 - Retain the fully qualified path segment when rewriting struct literals in expression position. Now `<Struct as Trait>::Type` is not rewritten as `Trait::Type` [#5151](https://github.com/rust-lang/rustfmt/issues/5151)
38 - Do not remove match arm braces from a match arm with a single `ast::ExprKind::Block` that has leading attributes. Removing the braces could lead to code that does not compile. Now rustfmt will leave the outer `{}` in place when formatting `=> {#[allow(unsafe_code)]unsafe {}}` [#4109](https://github.com/rust-lang/rustfmt/issues/4109)
39 - Backport json emitter and stdin changes [PR #5054](https://github.com/rust-lang/rustfmt/pull/5054)
40   - Make `--check` work when running rustfmt with input from stdin [PR #3896](https://github.com/rust-lang/rustfmt/pull/3896)
41   - Fix `--check` with the `--files-with-diff` flag [PR #3910](https://github.com/rust-lang/rustfmt/pull/3910)
42   - Produce valid JSON when using the JSON emitter [PR #3953](https://github.com/rust-lang/rustfmt/pull/3953)
43   - Fix newlines in JSON output [PR #4262](https://github.com/rust-lang/rustfmt/pull/4262)
44   - Use `<stdin>` when emitting stdin as filename [PR #4298](https://github.com/rust-lang/rustfmt/pull/4298)
45 - Always generate some output when formatting `@generated` files via stdin even when `format_generated_files=false`. Not producing output caused rust-analyzer to delete the file content [rust-lang/rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/11285) [#5172](https://github.com/rust-lang/rustfmt/issues/5172)
46 - Properly block indent multi-line comments in empty struct definitions. Previously, only the first comment line would be block indented. All other comment lines would be aligned with the struct definition [#4854](https://github.com/rust-lang/rustfmt/issues/4854)
47 - Prevent rustfmt from wrapping a comment at a byte position inside a non-ascii character when `wrap_comments=true`. This prevents rustfmt from panicking when breaking on the invalid position [#5023](https://github.com/rust-lang/rustfmt/issues/5023)
48 - Prevent rustfmt from removing commented out trailing separators (e.g commas) when rewriting lists. For example, remove the comma from a comment like this `// ...,` would lead to a scenario where the entire list could not be rewritten because the content of the comment changed [#5042](https://github.com/rust-lang/rustfmt/issues/5042)
49 - Fix panic when `import_granularity` was set to `Module`, `One`, or `Crate` and the import use declaration contained an alias `use crate a::b as b1` [#5131](https://github.com/rust-lang/rustfmt/issues/5131)
50 - Add a newline between generic parameters and their doc comments to prevent the generic parameters from being merged into their doc comments [#5122](https://github.com/rust-lang/rustfmt/issues/5122)
51 - Fixes indentation issue where string literals manually broken with line continuation characters (`\`) would be incorrectly indented in macro definitions when setting `format_strings=true`[#4036](https://github.com/rust-lang/rustfmt/issues/4036)
52 - Properly wrap and format long markdown block quotes when `wrap_comments=true` [#5157](https://github.com/rust-lang/rustfmt/issues/5157)
53 - Prevent rustfmt from wrapping markdown headers even when `wrap_comments=true`. Wrapping the markdown headers would prevent them from being properly rendered with rustdoc [#5238](https://github.com/rust-lang/rustfmt/issues/5238)
54 - Prevent rustfmt from removing commas between struct fields when those fields were also separated by an empty line [#4791](https://github.com/rust-lang/rustfmt/issues/4791) [#4928](https://github.com/rust-lang/rustfmt/issues/4928)
55 - Fix compiler error caused when formatting imports with `imports_granularity=Module` and a path containing `self`. Given the following import `use crate::lexer::{self, tokens::TokenData};`, rustfmt would transform the `self` import into `use crate::lexer::self;`. Now rustfmt produces `use crate::lexer::{self};` [#4681](https://github.com/rust-lang/rustfmt/issues/4681)
56 - Prevent rustfmt from breaking long type links in doc comments on namespace qualifiers (`::`) when `wrap_comments=true`. Breaking these long type links over multiple lines prevented them from being properly rendered in rustdoc [#5260](https://github.com/rust-lang/rustfmt/issues/5260)
57 - Correctly find the start of struct bodies after any generic `const` parameters. Naively searching for an opening `{` lead to issues since generic `const` parameters are also defined with `{}` (e.g. `struct Example<const N: usize = { 1048576 }> {}`) [#5273](https://github.com/rust-lang/rustfmt/issues/5273)
58 - Prevent rustfmt from merging derives when using inner or outer `rustfmt::skip::attributes` attributes. For example, `#[rustfmt::skip::attributes(derive)]` [#5270](https://github.com/rust-lang/rustfmt/issues/5270)
59 - Retain trailing `;` when rewriting macro calls in extern blocks. For example, `extern "C" { x!(-); }`[#5281](https://github.com/rust-lang/rustfmt/issues/5281)
60 - Add a newline when formatting struct fields preceded by both doc comments and inline comments to prevent the field from being merged into the inline comment. This was not an issue when a struct was preceded by just a doc comment or just an inline comment [#5215](https://github.com/rust-lang/rustfmt/issues/5215)
61
62 ### Added
63
64 - Added `One` as a new [group_imports](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#group_imports) option to create a single group for all imports [PR #4966](https://github.com/rust-lang/rustfmt/pull/4966)
65 - Add [short_array_element_width_threshold](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#short_array_element_width_threshold) config option to give users more control over when `Mixed` list formatting is used [PR #5228](https://github.com/rust-lang/rustfmt/pull/5228)
66
67 ### Removed
68
69 - Removed unstable, nightly-only config option `report_todo` [#5101](https://github.com/rust-lang/rustfmt/issues/5101)
70 - Removed unstable, nightly-only config option `report_fixme` [#5102](https://github.com/rust-lang/rustfmt/issues/5102)
71 - Removed unstable, nightly-only config option `license_template_path` [#5103](https://github.com/rust-lang/rustfmt/issues/5103)
72
73 ### Misc
74
75 - Improved performance when formatting large and deeply nested expression trees, often found in generated code, which have many expressions that exceed `max_width` [#5128](https://github.com/rust-lang/rustfmt/issues/5128), [#4867](https://github.com/rust-lang/rustfmt/issues/4867), [#4476](https://github.com/rust-lang/rustfmt/issues/4476), [#5139](https://github.com/rust-lang/rustfmt/pull/5139)
76
77 ### Install/Download Options
78 - **rustup (nightly)** - *pending*
79 - **GitHub Release Binaries** - [Release v1.5.0](https://github.com/rust-lang/rustfmt/releases/tag/v1.5.0)
80 - **Build from source** - [Tag v1.5.0](https://github.com/rust-lang/rustfmt/tree/v1.5.0), see instructions for how to [install rustfmt from source][install-from-source]
81
82 ## [1.4.38] 2021-10-20
83
84 ### Changed
85
86 - Switched from `rustc-ap-*` crates to `rustc_private` for consumption model of rustc internals
87 - `annotate-snippets` updated to v0.8 [PR #4762](https://github.com/rust-lang/rustfmt/pull/4762)
88 - Greatly improved the performance of `cargo fmt` in large workspaces utilizing the `--all` flag by updating to a newer version of `cargo_metadata` that leverages updated `cargo` output from v1.51+ [PR #4997](https://github.com/rust-lang/rustfmt/pull/4997)
89 - Improved formatting of long slice patterns [#4530](https://github.com/rust-lang/rustfmt/issues/4530)
90   - **Note you must have `version = Two` in your configuration to take advantage of the new formatting**
91 - Stabilized `match_block_trailing_comma` configuration option [#3380](https://github.com/rust-lang/rustfmt/issues/3380) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma)
92 - Stabilized `disable_all_formatting` configuration option [#5026](https://github.com/rust-lang/rustfmt/pull/5026) - [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting)
93 - Various improvements to the configuration documentation website [https://rust-lang.github.io/rustfmt/?version=v1.4.38]([https://rust-lang.github.io/rustfmt/?version=v1.4.38])
94 - Addressed various clippy and rustc warnings
95
96
97 ### Fixed
98
99 - Resolved issue where specious whitespace would be inserted when a block style comment was terminated within string literal processing [#4312](https://github.com/rust-lang/rustfmt/issues/4312)
100 - Nested out-of-line mods are again parsed and formatted [#4874](https://github.com/rust-lang/rustfmt/issues/4874)
101 - Accepts `2021` for edition value from rustfmt command line [PR #4847](https://github.com/rust-lang/rustfmt/pull/4847)
102 - Unstable command line options are no longer displayed in `--help` text on stable [PR #4798](https://github.com/rust-lang/rustfmt/issues/4798)
103 - Stopped panicking on patterns in match arms which start with non-ascii characters [#4868](https://github.com/rust-lang/rustfmt/issues/4868)
104 - Stopped stripping defaults on const params [#4816](https://github.com/rust-lang/rustfmt/issues/4816)
105 - Fixed issue with dropped content with GAT aliases with self bounds in impls [#4911](https://github.com/rust-lang/rustfmt/issues/4911)
106 - Stopped removing generic args on associated type constraints [#4943](https://github.com/rust-lang/rustfmt/issues/4943)
107 - Stopped dropping visibility on certain trait and impl items [#4960](https://github.com/rust-lang/rustfmt/issues/4960)
108 - Fixed dropping of qualified paths in struct patterns [#4908](https://github.com/rust-lang/rustfmt/issues/4908) and [#5005](https://github.com/rust-lang/rustfmt/issues/5005)
109 - Fixed bug in line width calculation that was causing specious formatting of certain patterns [#4031](https://github.com/rust-lang/rustfmt/issues/4031)
110   - **Note that this bug fix may cause observable formatting changes in cases where code had been formatted with prior versions of rustfmt that contained the bug**
111 - Fixed bug where rustfmt would drop parameter attributes if they were too long in certain cases [#4579](https://github.com/rust-lang/rustfmt/issues/4579)
112 - Resolved idempotency issue with extern body elements [#4963](https://github.com/rust-lang/rustfmt/issues/4963)
113 - rustfmt will now handle doc-style comments on function parameters, since they could appear with certain macro usage patterns even though it's generally invalid syntax [#4936](https://github.com/rust-lang/rustfmt/issues/4936)
114 - Fixed bug in `match_block_trailing_comma` where commas were not added to the blocks of bodies whose arm had a guard that did not fit on the same line as the pattern [#4998](https://github.com/rust-lang/rustfmt/pull/4998)
115 - Fixed bug in cases where derive attributes started with a block style comment [#4984](https://github.com/rust-lang/rustfmt/issues/4984)
116 - Fixed issue where the struct rest could be lost when `struct_field_align_threshold` was enabled [#4926](https://github.com/rust-lang/rustfmt/issues/4926)
117 - Handles cases where certain control flow type expressions have comments between patterns/keywords and the pattern ident contains the keyword [#5009](https://github.com/rust-lang/rustfmt/issues/5009)
118 - Handles tuple structs that have explicit visibilities and start with a block style comment [#5011](https://github.com/rust-lang/rustfmt/issues/5011)
119 - Handles leading line-style comments in certain types of macro calls [#4615](https://github.com/rust-lang/rustfmt/issues/4615)
120
121
122 ### Added
123 - Granular width heuristic options made available for user control [PR #4782](https://github.com/rust-lang/rustfmt/pull/4782). This includes the following:
124   - [`array_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#array_width)
125   - [`attr_fn_like_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#attr_fn_like_width)
126   - [`chain_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#chain_width)
127   - [`fn_call_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#fn_call_width)
128   - [`single_line_if_else_max_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#single_line_if_else_max_width)
129   - [`struct_lit_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_lit_width)
130   - [`struct_variant_width`](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#struct_variant_width)
131
132 Note this hit the rustup distributions prior to the v1.4.38 release as part of an out-of-cycle updates, but is listed in this version because the feature was not in the other v1.4.37 releases. See also the `use_small_heuristics` section on the configuration site for more information
133 [https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics](https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics)
134
135 - New `One` variant added to `imports_granularity` configuration option which can be used to reformat all imports into a single use statement [#4669](https://github.com/rust-lang/rustfmt/issues/4669)
136 - rustfmt will now skip files that are annotated with `@generated` at the top of the file [#3958](https://github.com/rust-lang/rustfmt/issues/3958)
137   if `format_generated_files` option is set to `false` (by default `@generated` files are formatted)
138 - New configuration option `hex_literal_case` that allows user to control the casing utilized for hex literals [PR #4903](https://github.com/rust-lang/rustfmt/pull/4903)
139
140 See the section on the configuration site for more information
141 https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#hex_literal_case
142
143 - `cargo fmt` now directly supports the `--check` flag, which means it's now possible to run `cargo fmt --check` instead of the more verbose `cargo fmt -- --check` [#3888](https://github.com/rust-lang/rustfmt/issues/3888)
144
145 ### Install/Download Options
146 - **rustup (nightly)** - *pending*
147 - **GitHub Release Binaries** - [Release v1.4.38](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.38)
148 - **Build from source** - [Tag v1.4.38](https://github.com/rust-lang/rustfmt/tree/v1.4.38), see instructions for how to [install rustfmt from source][install-from-source]
149
150 ## [1.4.37] 2021-04-03
151
152 ### Changed
153
154 - `rustc-ap-*` crates updated to v712.0.0
155
156 ### Fixed
157 - Resolve idempotence issue related to indentation of macro defs that contain or-patterns with inner comments ([#4603](https://github.com/rust-lang/rustfmt/issues/4603))
158 - Addressed various clippy and rustc warnings
159
160 ### Install/Download Options
161 - **crates.io package** - *pending*
162 - **rustup (nightly)** - *pending*
163 - **GitHub Release Binaries** - [Release v1.4.37](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.37)
164 - **Build from source** - [Tag v1.4.37](https://github.com/rust-lang/rustfmt/tree/v1.4.37), see instructions for how to [install rustfmt from source][install-from-source]
165
166 ## [1.4.36] 2021-02-07
167
168 ### Changed
169
170 - `rustc-ap-*` crates updated to v705.0.0
171
172 ### Install/Download Options
173 - **crates.io package** - *pending*
174 - **rustup (nightly)** - *pending*
175 - **GitHub Release Binaries** - [Release v1.4.36](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.36)
176 - **Build from source** - [Tag v1.4.36](https://github.com/rust-lang/rustfmt/tree/v1.4.36), see instructions for how to [install rustfmt from source][install-from-source]
177
178 ## [1.4.35] 2021-02-03
179
180 ### Changed
181
182 - `rustc-ap-*` crates updated to v702.0.0
183
184 ### Install/Download Options
185 - **crates.io package** - *pending*
186 - **rustup (nightly)** - *n/a (superseded by [v1.4.36](#1436-2021-02-07))
187 - **GitHub Release Binaries** - [Release v1.4.35](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.35)
188 - **Build from source** - [Tag v1.4.35](https://github.com/rust-lang/rustfmt/tree/v1.4.35), see instructions for how to [install rustfmt from source][install-from-source]
189
190 ## [1.4.34] 2021-01-28
191
192 ### Fixed
193 - Don't insert trailing comma on (base-less) rest in struct literals within macros ([#4675](https://github.com/rust-lang/rustfmt/issues/4675))
194
195 ### Install/Download Options
196 - **crates.io package** - *pending*
197 - **rustup (nightly)** - Starting in `2021-01-31`
198 - **GitHub Release Binaries** - [Release v1.4.34](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.34)
199 - **Build from source** - [Tag v1.4.34](https://github.com/rust-lang/rustfmt/tree/v1.4.34), see instructions for how to [install rustfmt from source][install-from-source]
200
201 ## [1.4.33] 2021-01-27
202
203 ### Changed
204 - `merge_imports` configuration has been deprecated in favor of the new `imports_granularity` option. Any existing usage of `merge_imports` will be automatically mapped to the corresponding value on `imports_granularity` with a warning message printed to encourage users to update their config files.
205
206 ### Added
207 - New `imports_granularity` option has been added which succeeds `merge_imports`. This new option supports several additional variants which allow users to merge imports at different levels (crate or module), and even flatten imports to have a single use statement per item. ([PR #4634](https://github.com/rust-lang/rustfmt/pull/4634), [PR #4639](https://github.com/rust-lang/rustfmt/pull/4639))
208
209 See the section on the configuration site for more information
210 https://rust-lang.github.io/rustfmt/?version=v1.4.33&search=#imports_granularity
211
212 ### Fixed
213 - Fix erroneous removal of `const` keyword on const trait impl ([#4084](https://github.com/rust-lang/rustfmt/issues/4084))
214 - Fix incorrect span usage wit const generics in supertraits ([#4204](https://github.com/rust-lang/rustfmt/issues/4204))
215 - Use correct span for const generic params ([#4263](https://github.com/rust-lang/rustfmt/issues/4263))
216 - Correct span on const generics to include type bounds ([#4310](https://github.com/rust-lang/rustfmt/issues/4310))
217 - Idempotence issue on blocks containing only empty statements ([#4627](https://github.com/rust-lang/rustfmt/issues/4627) and [#3868](https://github.com/rust-lang/rustfmt/issues/3868))
218 - Fix issue with semicolon placement on required functions that have a trailing comment that ends in a line-style comment before the semicolon ([#4646](https://github.com/rust-lang/rustfmt/issues/4646))
219 - Avoid shared interned cfg_if symbol since rustfmt can re-initialize the rustc_ast globals on multiple inputs ([#4656](https://github.com/rust-lang/rustfmt/issues/4656))
220
221 ### Install/Download Options
222 - **crates.io package** - *pending*
223 - **rustup (nightly)** - n/a (superseded by [v1.4.34](#1434-2021-01-28))
224 - **GitHub Release Binaries** - [Release v1.4.33](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.33)
225 - **Build from source** - [Tag v1.4.33](https://github.com/rust-lang/rustfmt/tree/v1.4.33), see instructions for how to [install rustfmt from source][install-from-source]
226
227 ## [1.4.32] 2021-01-16
228
229 ### Fixed
230 - Indentation now correct on first bound in cases where the generic bounds are multiline formatted and the first bound itself is multiline formatted ([#4636](https://github.com/rust-lang/rustfmt/issues/4636))
231
232 ### Install/Download Options
233 - **crates.io package** - *pending*
234 - **rustup (nightly)** - Starting in `2021-01-18`
235 - **GitHub Release Binaries** - [Release v1.4.32](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.32)
236 - **Build from source** - [Tag v1.4.32](https://github.com/rust-lang/rustfmt/tree/v1.4.32), see instructions for how to [install rustfmt from source][install-from-source]
237
238 ## [1.4.31] 2021-01-09
239
240 ### Changed
241
242 - `rustc-ap-*` crates updated to v697.0.0
243
244 ### Added
245 - Support for 2021 Edition [#4618](https://github.com/rust-lang/rustfmt/pull/4618))
246
247 ### Install/Download Options
248 - **crates.io package** - *pending*
249 - **rustup (nightly)** - Starting in `2021-01-16`
250 - **GitHub Release Binaries** - [Release v1.4.31](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.31)
251 - **Build from source** - [Tag v1.4.31](https://github.com/rust-lang/rustfmt/tree/v1.4.31), see instructions for how to [install rustfmt from source][install-from-source]
252
253 ## [1.4.30] 2020-12-20
254
255 ### Fixed
256 - Last character in derive no longer erroneously stripped when `indent_style` is overridden to `Visual`. ([#4584](https://github.com/rust-lang/rustfmt/issues/4584))
257 - Brace wrapping of closure bodies maintained in cases where the closure has an explicit return type and the body consists of a single expression statement. ([#4577](https://github.com/rust-lang/rustfmt/issues/4577))
258 - No more panics on invalid code with `err` and `typeof` types ([#4357](https://github.com/rust-lang/rustfmt/issues/4357), [#4586](https://github.com/rust-lang/rustfmt/issues/4586))
259
260 ### Install/Download Options
261 - **crates.io package** - *pending*
262 - **rustup (nightly)** - Starting in `2020-12-25`
263 - **GitHub Release Binaries** - [Release v1.4.30](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.30)
264 - **Build from source** - [Tag v1.4.30](https://github.com/rust-lang/rustfmt/tree/v1.4.30), see instructions for how to [install rustfmt from source][install-from-source]
265
266 ## [1.4.29] 2020-12-04
267
268 ### Fixed
269 - Negative polarity on non-trait impl now preserved. ([#4566](https://github.com/rust-lang/rustfmt/issues/4566))
270
271 ### Install/Download Options
272 - **crates.io package** - *pending*
273 - **rustup (nightly)** - Starting in `2020-12-07`
274 - **GitHub Release Binaries** - [Release v1.4.29](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.29)
275 - **Build from source** - [Tag v1.4.29](https://github.com/rust-lang/rustfmt/tree/v1.4.29), see instructions for how to [install rustfmt from source][install-from-source]
276
277 ## [1.4.28] 2020-11-29
278
279 ### Changed
280
281 - `rustc-ap-*` crates updated to v691.0.0
282 - In the event of an invalid inner attribute on a `cfg_if` condition, rustfmt will now attempt to continue and format the imported modules. Previously rustfmt would emit the parser error about an inner attribute being invalid in this position, but for rustfmt's purposes the invalid attribute doesn't prevent nor impact module formatting.
283
284 ### Added
285
286 - [`group_imports`][group-imports-config-docs] - a new configuration option that allows users to control the strategy used for grouping imports ([#4107](https://github.com/rust-lang/rustfmt/issues/4107))
287
288 [group-imports-config-docs]: https://github.com/rust-lang/rustfmt/blob/v1.4.28/Configurations.md#group_imports
289
290 ### Fixed
291 - Formatting of malformed derived attributes is no longer butchered. ([#3898](https://github.com/rust-lang/rustfmt/issues/3898), [#4029](https://github.com/rust-lang/rustfmt/issues/4029), [#4115](https://github.com/rust-lang/rustfmt/issues/4115), [#4545](https://github.com/rust-lang/rustfmt/issues/4545))
292 - Correct indentation used in macro branches when `hard_tabs` is enabled. ([#4152](https://github.com/rust-lang/rustfmt/issues/4152))
293 - Comments between the visibility modifier and item name are no longer dropped. ([#2781](https://github.com/rust-lang/rustfmt/issues/2781))
294 - Comments preceding the assignment operator in type aliases are no longer dropped. ([#4244](https://github.com/rust-lang/rustfmt/issues/4244))
295 - Comments between {`&` operator, lifetime, `mut` kw, type} are no longer dropped. ([#4245](https://github.com/rust-lang/rustfmt/issues/4245))
296 - Comments between type bounds are no longer dropped. ([#4243](https://github.com/rust-lang/rustfmt/issues/4243))
297 - Function headers are no longer dropped on foreign function items. ([#4288](https://github.com/rust-lang/rustfmt/issues/4288))
298 - Foreign function blocks are no longer dropped. ([#4313](https://github.com/rust-lang/rustfmt/issues/4313))
299 - `where_single_line` is no longer incorrectly applied to multiline function signatures that have no `where` clause. ([#4547](https://github.com/rust-lang/rustfmt/issues/4547))
300 - `matches!` expressions with multiple patterns and a destructure pattern are now able to be formatted. ([#4512](https://github.com/rust-lang/rustfmt/issues/4512))
301
302 ### Install/Download Options
303 - **crates.io package** - *pending*
304 - **rustup (nightly)** - n/a (superseded by [v1.4.29](#1429-2020-12-04))
305 - **GitHub Release Binaries** - [Release v1.4.28](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.28)
306 - **Build from source** - [Tag v1.4.28](https://github.com/rust-lang/rustfmt/tree/v1.4.28), see instructions for how to [install rustfmt from source][install-from-source]
307
308 ## [1.4.27] 2020-11-16
309
310 ### Fixed
311
312 - Leading comments in an extern block are no longer dropped (a bug that exists in v1.4.26). ([#4528](https://github.com/rust-lang/rustfmt/issues/4528))
313
314 ### Install/Download Options
315 - **crates.io package** - *pending*
316 - **rustup (nightly)** - Starting in `2020-11-18`
317 - **GitHub Release Binaries** - [Release v1.4.27](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.27)
318 - **Build from source** - [Tag v1.4.27](https://github.com/rust-lang/rustfmt/tree/v1.4.27), see instructions for how to [install rustfmt from source][install-from-source]
319
320 ## [1.4.26] 2020-11-14
321
322 ### Changed
323
324 - Original comment indentation for trailing comments within an `if` is now taken into account when determining the indentation level to use for the trailing comment in formatted code. This does not modify any existing code formatted with rustfmt; it simply gives the programmer discretion to specify whether the comment is associated to the `else` block, or if the trailing comment is just a member of the `if` block. ([#1575](https://github.com/rust-lang/rustfmt/issues/1575), [#4120](https://github.com/rust-lang/rustfmt/issues/4120), [#4506](https://github.com/rust-lang/rustfmt/issues/4506))
325
326 In this example the `// else comment` refers to the `else`:
327 ```rust
328 // if comment
329 if cond {
330     "if"
331 // else comment
332 } else {
333     "else"
334 }
335 ```
336
337 Whereas in this case the `// continue` comments are members of their respective blocks and do not refer to the `else` below.
338 ```rust
339 if toks.eat_token(Token::Word("modify"))? && toks.eat_token(Token::Word("labels"))? {
340     if toks.eat_token(Token::Colon)? {
341         // ate the token
342     } else if toks.eat_token(Token::Word("to"))? {
343         // optionally eat the colon after to, e.g.:
344         // @rustbot modify labels to: -S-waiting-on-author, +S-waiting-on-review
345         toks.eat_token(Token::Colon)?;
346     } else {
347         // It's okay if there's no to or colon, we can just eat labels
348         // afterwards.
349     }
350     1 + 2;
351     // continue
352 } else if toks.eat_token(Token::Word("label"))? {
353     // continue
354 } else {
355     return Ok(None);
356 }
357 ```
358
359 ### Fixed
360 - Formatting of empty blocks with attributes which only contained comments is no longer butchered.([#4475](https://github.com/rust-lang/rustfmt/issues/4475), [#4467](https://github.com/rust-lang/rustfmt/issues/4467), [#4452](https://github.com/rust-lang/rustfmt/issues/4452#issuecomment-705886282), [#4522](https://github.com/rust-lang/rustfmt/issues/4522))
361 - Indentation of trailing comments in non-empty extern blocks is now correct. ([#4120](https://github.com/rust-lang/rustfmt/issues/4120#issuecomment-696491872))
362
363 ### Install/Download Options
364 - **crates.io package** - *pending*
365 - **rustup (nightly)** - Starting in `2020-11-16`
366 - **GitHub Release Binaries** - [Release v1.4.26](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.26)
367 - **Build from source** - [Tag v1.4.26](https://github.com/rust-lang/rustfmt/tree/v1.4.26), see instructions for how to [install rustfmt from source][install-from-source]
368
369 ## [1.4.25] 2020-11-10
370
371 ### Changed
372
373 - Semicolons are no longer automatically inserted on trailing expressions in macro definition arms ([#4507](https://github.com/rust-lang/rustfmt/pull/4507)). This gives the programmer control and discretion over whether there should be semicolons in these scenarios so that potential expansion issues can be avoided.
374
375 ### Install/Download Options
376 - **crates.io package** - *pending*
377 - **rustup (nightly)** - Starting in `2020-11-14`
378 - **GitHub Release Binaries** - [Release v1.4.25](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.25)
379 - **Build from source** - [Tag v1.4.25](https://github.com/rust-lang/rustfmt/tree/v1.4.25), see instructions for how to [install rustfmt from source][install-from-source]
380
381 ## [1.4.24] 2020-11-05
382
383 ### Changed
384
385 - Block wrapped match arm bodies containing a single macro call expression are no longer flattened ([#4496](https://github.com/rust-lang/rustfmt/pull/4496)). This allows programmer discretion so that the block wrapping can be preserved in cases where needed to prevent issues in expansion, such as with trailing semicolons, and aligns with updated [Style Guide guidance](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/expressions.md#macro-call-expressions) for such scenarios.
386
387 ### Fixed
388 - Remove useless `deprecated` attribute on a trait impl block in the rustfmt lib, as these now trigger errors ([rust-lang/rust/#78626](https://github.com/rust-lang/rust/pull/78626))
389
390 ### Install/Download Options
391 - **crates.io package** - *pending*
392 - **rustup (nightly)** - Starting in `2020-11-09`
393 - **GitHub Release Binaries** - [Release v1.4.24](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.24)
394 - **Build from source** - [Tag v1.4.24](https://github.com/rust-lang/rustfmt/tree/v1.4.24), see instructions for how to [install rustfmt from source][install-from-source]
395
396 ## [1.4.23] 2020-10-30
397
398 ### Changed
399
400 - Update `rustc-ap-*` crates to v686.0.0
401
402 ### Added
403 - Initial support for formatting new ConstBlock syntax ([#4478](https://github.com/rust-lang/rustfmt/pull/4478))
404
405 ### Fixed
406 - Handling of unclosed delimiter-only parsing errors in input files ([#4466](https://github.com/rust-lang/rustfmt/issues/4466))
407 - Misc. minor parser bugs ([#4418](https://github.com/rust-lang/rustfmt/issues/4418) and [#4431](https://github.com/rust-lang/rustfmt/issues/4431))
408 - Panic on nested tuple access ([#4355](https://github.com/rust-lang/rustfmt/issues/4355))
409 - Unable to disable license template path via cli override ([#4487](https://github.com/rust-lang/rustfmt/issues/4487))
410 - Preserve comments in empty statements [#4018](https://github.com/rust-lang/rustfmt/issues/4018))
411 - Indentation on skipped code [#4398](https://github.com/rust-lang/rustfmt/issues/4398))
412
413 ### Install/Download Options
414 - **crates.io package** - *pending*
415 - **rustup (nightly)** - n/a (superseded by [v1.4.24](#1424-2020-11-05))
416 - **GitHub Release Binaries** - [Release v1.4.23](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.23)
417 - **Build from source** - [Tag v1.4.23](https://github.com/rust-lang/rustfmt/tree/v1.4.23), see instructions for how to [install rustfmt from source][install-from-source]
418
419
420
421 ## [1.4.22] 2020-10-04
422
423 ### Changed
424
425 - Update `rustc-ap-*` crates to v679.0.0
426 - Add config option to allow control of leading match arm pipes
427 - Support `RUSTFMT` environment variable in `cargo fmt` to run specified `rustfmt` instance
428
429 ### Fixed
430
431 - Fix preservation of type aliases within extern blocks
432
433
434 ## [1.4.9] 2019-10-07
435
436 ### Changed
437
438 - Update `rustc-ap-*` crates to 606.0.0.
439
440 ### Fixed
441
442 - Fix aligning comments of different group
443 - Fix flattening imports with a single `self`.
444 - Fix removing attributes on function parameters.
445 - Fix removing `impl` keyword from opaque type.
446
447 ## [1.4.8] 2019-09-08
448
449 ### Changed
450
451 - Update `rustc-ap-*` crates to 583.0.0.
452
453 ## [1.4.7] 2019-09-06
454
455 ### Added
456
457 - Add `--config` command line option.
458
459 ### Changed
460
461 - Update `rustc-ap-*` crates to 581.0.0.
462 - rustfmt now do not warn against trailing whitespaces inside macro calls.
463
464 ### Fixed
465
466 - Fix `merge_imports` generating invalid code.
467 - Fix removing discriminant values on enum variants.
468 - Fix modules defined inside `cfg_if!` not being formatted.
469 - Fix minor formatting issues.
470
471 ## [1.4.6] 2019-08-28
472
473 ### Added
474
475 - Add `--message-format` command line option to `cargo-fmt`.
476 - Add `-l,--files-with-diff` command line option to `rustfmt`.
477 - Add `json` emit mode.
478
479 ### Fixed
480
481 - Fix removing attributes on struct pattern's fields.
482 - Fix non-idempotent formatting of match arm.
483 - Fix `merge_imports` generating invalid code.
484 - Fix imports with `#![macro_use]` getting reordered with `reorder_imports`.
485 - Fix calculation of line numbers in checkstyle output.
486 - Fix poor formatting of complex fn type.
487
488 ## [1.4.5] 2019-08-13
489
490 ### Fixed
491
492 - Fix generating invalid code when formatting an impl block with const generics inside a where clause.
493 - Fix adding a trailing space after a `dyn` keyword which is used as a macro argument by itself.
494
495 ## [1.4.4] 2019-08-06
496
497 ### Fixed
498
499 - Fix `cargo fmt` incorrectly formatting crates that is not part of the workspace or the path dependencies.
500 - Fix removing a trailing comma from a tuple pattern.
501
502 ## [1.4.3] 2019-08-02
503
504 ### Changed
505
506 - Update `rustc-ap-*` crates to 546.0.0.
507
508 ### Fixed
509
510 - Fix an underscore pattern getting removed.
511
512 ## [1.4.2] 2019-07-31
513
514 ### Changed
515
516 - Explicitly require the version of `rustfmt-config_proc_macro` to be 0.1.2 or later.
517
518 ## [1.4.1] 2019-07-30
519
520 ### Changed
521
522 - Update `rustc-ap-*` crates to 542.0.0.
523
524 ## [1.4.0] 2019-07-29
525
526 ### Added
527
528 - Add new attribute `rustfmt::skip::attributes` to prevent rustfmt
529 from formatting an attribute #3665
530
531 ### Changed
532
533 - Update `rustc-ap-*` crates to 541.0.0.
534 - Remove multiple semicolons.
535
536 ## [1.3.3] 2019-07-15
537
538 ### Added
539
540 - Add `--manifest-path` support to `cargo fmt` (#3683).
541
542 ### Fixed
543
544 - Fix `cargo fmt -- --help` printing nothing (#3620).
545 - Fix inserting an extra comma (#3677).
546 - Fix incorrect handling of CRLF with `file-lines` (#3684).
547 - Fix `print-config=minimal` option (#3687).
548
549 ## [1.3.2] 2019-07-06
550
551 ### Fixed
552
553 - Fix rustfmt crashing when `await!` macro call is used in a method chain.
554 - Fix rustfmt not recognizing a package whose name differs from its directory's name.
555
556 ## [1.3.1] 2019-06-30
557
558 ### Added
559
560 - Implement the `Display` trait on the types of `Config`.
561
562 ### Changed
563
564 - `ignore` configuration option now only supports paths separated by `/`. Windows-style paths are not supported.
565 - Running `cargo fmt` in a sub-directory of a project is now supported.
566
567 ### Fixed
568
569 - Fix bugs that may cause rustfmt to crash.
570
571 ## [1.3.0] 2019-06-09
572
573 ### Added
574
575 - Format modules defined inside `cfg_if` macro calls #3600
576
577 ### Changed
578
579 - Change option `format_doc_comment` to `format_code_in_doc_comment`.
580 - `use_small_heuristics` changed to be an enum and stabilised. Configuration
581   options are now ready for 1.0.
582 - Stabilise `fn_args_density` configuration option and rename it to `fn_args_layout` #3581
583 - Update `rustc-ap-*` crates to 486.0.0
584 - Ignore sub-modules when skip-children is used #3607
585 - Removed bitrig support #3608
586
587 ### Fixed
588
589 - `wrap_comments` should not imply `format_doc_comments` #3535
590 - Incorrect handling of const generics #3555
591 - Add the handling for `vec!` with paren inside macro #3576
592 - Format trait aliases with where clauses #3586
593 - Catch panics from the parser while rewriting macro calls #3589
594 - Fix erasing inner attributes in struct #3593
595 - Inline the attribute with its item even with the `macro_use` attribute or when `reorder_imports` is disabled #3598
596 - Fix the bug add unwanted code to impl #3602
597
598 ## [1.2.2] 2019-04-24
599
600 ### Fixed
601
602 - Fix processing of `ignore` paths #3522
603 - Attempt to format attributes if only they exist #3523
604
605 ## [1.2.1] 2019-04-18
606
607 ### Added
608
609 - Add `--print-config current` CLI option b473e65
610 - Create GitHub [page](https://rust-lang.github.io/rustfmt/) for Configuration.md #3485
611
612 ### Fixed
613
614 - Keep comment appearing between parameter's name and its type #3491
615 - Do not delete semicolon after macro call with square brackets #3500
616 - Fix `--version` CLI option #3506
617 - Fix duplication of attributes on a match arm's body #3510
618 - Avoid overflowing item with attributes #3511
619
620 ## [1.2.0] 2019-03-27
621
622 ### Added
623
624 - Add new attribute `rustfmt::skip::macros` to prevent rustfmt from formatting a macro #3454
625
626 ### Changed
627
628 - Discard error report in silent_emitter #3466
629
630 ### Fixed
631
632 - Fix bad performance on deeply nested binary expressions #3467
633 - Use BTreeMap to guarantee consistent ordering b4d4b57
634
635 ## [1.1.1] 2019-03-21
636
637 ### Fixed
638
639 - Avoid panic on macro inside deeply nested block c9479de
640 - Fix line numbering in missed spans and handle file_lines in edge cases cdd08da
641 - Fix formatting of async blocks 1fa06ec
642 - Avoid duplication on the presence of spaces between macro name and `!` #3464
643
644 ## [1.1.0] 2019-03-17
645
646 ### Added
647
648 - Add `inline_attribute_width` configuration option to write an item and its attribute on the same line if their combined width is below a threshold #3409
649 - Support `const` generics f0c861b
650 - Support path clarity module #3448
651
652 ### Changed
653
654 - Align loop and while formatting 7d9a2ef
655 - Support `EmitMode::ModifiedLines` with stdin input #3424
656 - Update `rustc-ap-*` crates to 407.0.0
657 - Remove trailing whitespaces in missing spans 2d5bc69
658
659 ### Fixed
660
661 - Do not remove comment in the case of no arg 8e3ef3e
662 - Fix `Ident of macro+ident gets duplicated` error 40ff078
663 - Format the if expression at the end of the block in a single line 5f3dfe6
664
665 ## [1.0.3] 2019-02-14
666
667 ### Added
668
669 - Point unstable options to tracking issues 412dcc7
670
671 ### Changed
672
673 - Update `rustc-ap-*` crates to 373.0.0
674
675 ## [1.0.2] 2019-02-12
676
677 ### Added
678
679 - Add a [section](https://github.com/rust-lang/rustfmt/blob/ae331be/Contributing.md#version-gate-formatting-changes) to the Contributing.md file about version-gating formatting changes 36e2cb0
680 - Allow specifying package with `-p` CLI option a8d2591
681 - Support `rustfmt::skip` on imports #3289
682 - Support global `rustfmt.toml` to be written in user config directory #3280
683 - Format visibility on trait alias 96a3df3
684
685 ### Changed
686
687 - Do not modify original source code inside macro call #3260
688 - Recognize strings inside comments in order to avoid indenting them baa62c6
689 - Use Unicode-standard char width to wrap comments or strings a01990c
690 - Change new line point in the case of no args #3294
691 - Use the same formatting rule between functions and macros #3298
692 - Update rustc-ap-rustc_target to 366.0.0, rustc-ap-syntax to 366.0.0, and rustc-ap-syntax_pos to 366.0.0
693
694 ### Fixed
695
696 - rewrite_comment: fix block fallback when failing to rewrite an itemized block ab7f4e1
697 - Catch possible tokenizer panics #3240
698 - Fix macro indentation on Windows #3266
699 - Fix shape when formatting return or break expr on statement position #3259
700 - rewrite_comment: fix block fallback when failing to rewrite an itemized block
701 - Keep leading double-colon to respect the 2018 edition of rust's paths a2bfc02
702 - Fix glob and nested global imports 2125ad2
703 - Do not force trailing comma when using mixed layout #3306
704 - Prioritize `single_line_fn` and `empty_item_single_line` over `brace_style` #3308
705 - Fix `internal error: left behind trailing whitespace` with long lines c2534f5
706 - Fix attribute duplication #3325
707 - Fix formatting of strings within a macro 813aa79
708 - Handle a macro argument with a single keyword 9a7ea6a
709
710 ## [1.0.1] 2018-12-09
711
712 ### Added
713
714 - Add a `version` option 378994b
715
716 ### Changed
717
718 - End expressions like return/continue/break with a semicolon #3223
719 - Update rustc-ap-rustc_target to 306.0.0, rustc-ap-syntax to 306.0.0, and rustc-ap-syntax_pos to 306.0.0
720
721 ### Fixed
722
723 - Allow to run a rustfmt command from cargo-fmt even when there is no target a2da636
724 - Fix `un-closed delimiter` errors when formatting break labels 40174e9
725
726 ## [1.0.0] 2018-11-19
727
728 ### Changed
729
730 - Preserve possibly one whitespace for brace macros 1a3bc79
731 - Prefer to break arguments over putting output type on the next line 1dd54e6
732
733 ## [0.99.9] 2018-11-15
734
735 ### Changed
736
737 - Update rustc-ap-rustc_target to 297.0.0, rustc-ap-syntax to 297.0.0, to rustc-ap-syntax_pos to 297.0.0
738 - Don't align comments on `extern crate`s dd7add7
739
740 ## [0.99.8] 2018-11-14
741
742 ### Added
743
744 - Add `overflow_delimited_expr` config option to more aggressively allow overflow #3175
745
746 ### Fixed
747
748 - Fix the logic for retaining a comment before the arrow in a match #3181
749 - Do not wrap comments in doctest to avoid failing doctest runs #3183
750 - Fix comment rewriting that was wrapping code into a line comment #3188
751 - Fix formatting of unit-struct with `where`-clause #3200
752
753 ## [0.99.7] 2018-11-07
754
755 ### Changed
756
757 - Force a newline after the `if` condition if there is a different indentation level #3109
758 - Use correct width when formatting type on local statement #3126
759 - Treat crates non-alphabetically when ordering 799005f
760 - Fix formatting of code that is annotated with rustfmt::skip #3113
761 - Stabilize `edition` configuration option 9c3ae2d
762 - cargo-fmt: detect Rust edition in use #3129
763 - Trim the indentation on macros which heuristically appear to use block-style indentation #3178
764
765 ### Fixed
766
767 - Do not remove path disambiugator inside macro #3142
768 - Improve handling of Windows newlines #3141
769 - Fix alignment of a struct's fields (`struct_field_align_threshold` option) with the Visual `indent_style` #3165
770 - Fix a bug in formatting markdown lists within comments #3172
771
772 ## [0.99.6] 2018-10-18
773
774 ### Added
775
776 - Add `enum_discrim_align_threshold` option to vertically align enum discriminants cc22869
777 - Add `println!`-like heuristic to the `fail` attribute #3067
778 - Handle itemized items inside comments #3083
779 - Add `format_doc_comments` configuration option to control the formatting of code snippets inside comments #3089
780
781 ### Changed
782
783 - Makes brace behavior consistent with empty bodies for traits and impls 2727d41
784 - Consider a multi-lined array as a block-like expression #3969
785 - Improve formatting of strings #3073
786 - Get rid of extra commas in Visual struct literal formatting #3077
787 - Update rustc-ap-rustc_target to 274.0.0, rustc-ap-syntax to 274.0.0, and rustc-ap-syntax_pos to 274.0.0
788 - Format macro calls with item-like arguments #3080
789 - Avoid control flow expressions conditions to go multi line ef59b34
790 - Simplify multi-lining binop expressions #3101
791
792 ### Fixed
793
794 - Do not format a code block in documentation if it is annotated with ignore or text 2bcc3a9
795 - Fix inconsistent overflow behavior in Visual style #3078
796 - Fix corner cases of the string formatting implementation #3083
797 - Do not add parens around lifetimes 0ac68c9
798 - Catch parser panic in format_snippet 8c4e92a
799
800 ## [0.99.5] 2018-09-25
801
802 ### Added
803
804 - Handle leading module separator for 2018 Edition #2952
805 - Add configuration option `normalize_doc_attributes`: convert doc attributes to comments #3002
806
807 ### Changed
808
809 - Accept 2015 and 2018 instead of Edition2015 and Edition2018 for edition option eec7436
810 - Support platforms without a timer 46e2a2e
811 - Update rustc-ap-rustc_target to 263.0.0, rustc-ap-syntax to 263.0.0, and rustc-ap-syntax_pos to 263.0.0
812
813 ### Fixed
814
815 - Format of attributes with commas #2971
816 - Fix optional arg condensing #2972
817 - Improve formatting of long function parameters #2981
818 - Fix formatting of raw string literals #2983
819 - Handle chain with try operators with spaces #2986
820 - Use correct shape in Visual tuple rewriting #2987
821 - Impove formatting of arguments with `visual_style = "Visual"` option #2988
822 - Change `print_diff` to output the correct line number 992b179
823 - Propagate errors about failing to rewrite a macro 6f318e3
824 - Handle formatting of long function signature #3010
825 - Fix indent computation of a macro with braces c3edf6d
826 - Format generics on associated types #3035
827 - Incorrect indentation of multiline block match expression #3042
828 - Fix bug in import where two consecutive module separators were possible 98a0ef2
829 - Prevent right-shifting of block comments with bare lines 5fdb6db
830
831 ## [0.99.4] 2018-08-27
832
833 ### Added
834
835 - Handle formatting of underscore imports #2951
836 - Handle formatting of try blocks #2965
837
838 ### Changed
839
840 - Update rustc-ap-rustc_target to 237.0.0, rustc-ap-syntax to 237.0.0, and rustc-ap-syntax_pos to 237.0.0 ca19c9a
841 - Consider `dev` channel as nightly for unstable features #2948
842
843 ### Fixed
844
845 - Fix formatting of patterns with ellipsis # 2942
846
847 ## [0.99.3] 2018-08-23
848
849 ### Added
850
851 - Use path attribute when searching for modules #2901
852 - Expose FileLines JSON representation to allow external libraries to use the file_lines option #2915
853
854 ### Changed
855
856 - Replace '--conifig-help' with '--config=help' cb10e06
857 - Improve formatting of slice patterns #2912
858
859 ### Fixed
860
861 - Format chains with comment #2899
862 - Fix indentation of formatted macro body #2920
863 - Fix indentation of block comments f23e6aa
864
865 ## [0.99.2] 2018-08-07
866
867 ### Changed
868
869 - Update rustc-ap-rustc_target to 218.0.0, rustc-ap-syntax to 218.0.0, and rustc-ap-syntax_pos to 218.0.0 5c9a2b6
870 - Combine function-like attributes #2900
871
872 ### Fixed
873
874 - Explicitly handle semicolon after the item in statement position d96e3ca
875 - Fix parsing '#'-hiding of rustdoc 2eca09e
876
877 ## [0.99.1] 2018-08-04
878
879 ### Fixed
880
881 - fix use statements ordering when a number is present 1928ae7
882
883 ## [0.99.0] 2018-08-03
884
885 - 1.0 RC release
886
887 ### Changed
888
889 - Clarification in README.md 30fe66b
890
891 ## [0.9.0] 2018-08-01
892
893 ### Added
894
895 - Handle raw identifiers 3027c21
896 - Format async closure 60ce411
897 - Add max_width option for all heuristics c2ae39e
898 - Add config option `format_macro_matchers` to format the metavariable matching patterns in macros 79c5ee8
899 - Add config option `format_macro_bodies` to format the bodies of macros 79c5ee8
900 - Format exitential type fc307ff
901 - Support raw identifiers in struct expressions f121b1a
902 - Format Async block and async function 0b25f60
903
904 ### Changed
905
906 - Update rustc-ap-rustc_target to 211.0.0, rustc-ap-syntax to 211.0.0, and rustc-ap-syntax_pos to 211.0.0
907 - Put each nested import on its own line while putting non-nested imports on the same line as much as possible 42ab258
908 - Respect `empty_item_single_line` config option when formatting empty impls. Put the `where` on its own line to improve readability #2771
909 - Strip leading `|` in match arm patterns 1d4b988
910 - Apply short function call heuristic to attributes 3abebf9
911 - Indent a match guard if the pattern is multiline be4d37d
912 - Change default newline style to `Native` 9d8f381
913 - Improve formatting of series of binop expressions a4cdb68
914 - Trigger an internal error if we skip formatting due to a lost comment b085113
915 - Refactor chain formatting #2838
916
917 ### Fixed
918
919 - Do not insert spaces around braces with empty body or multiple lines 2f65852
920 - Allow using mixed layout with comments #2766
921 - Handle break labels #2726
922 - fix rewrite_string when a line feed is present 472a2ed
923 - Fix an anomaly with comments and array literals b28a0cd
924 - Check for comments after the `=>` in a match arm 6899471
925
926 ## [0.8.0,0.8.1,0.8.2] 2018-05-28
927
928 ### Added
929
930 - Use scoped attributes for skip attribute https://github.com/rust-lang/rustfmt/pull/2703
931
932 ### Changed
933
934 - Comment options `wrap_comments` and `normalize_comments` are reverted back to unstable 416bc4c
935 - Stabilise `reorder_imports` and `reorder_modules` options 7b6d2b4
936 - Remove `spaces_within_parens_and_brackets` option d726492
937 - Stabilise shorthand options: `use_try_shorthand`, `use_field_init_shorthand`, and `force_explicit_abi` 8afe367
938 - Stabilise `remove_nested_parens` and set default to true a70f716
939 - Unstabilise `unstable_features` dd9c15a
940 - Remove `remove_blank_lines_at_start_or_end_of_block` option 2ee8b0e
941 - Update rustc-ap-syntax to 146.0.0 and rustc-ap-rustc_target to 146.0.0 2c275a2
942 - Audit the public API #2639
943
944 ### Fixed
945
946 - Handle code block in doc comment without rust prefix f1974e2
947
948 ## [0.7.0] 2018-05-14
949
950 ### Added
951
952 - Add integration tests against crates in the rust-lang-nursery c79f39a
953
954 ### Changed
955
956 - Update rustc-ap-syntax to 128.0.0 and ustc-ap-rustc_target to 128.0.0 195395f
957 - Put operands on its own line when each fits in a single line f8439ce
958 - Improve CLI options 55ac062 1869888 798bffb 4d9de48 eca7796 8396da1 5d9f5aa
959
960 ### Fixed
961
962 - Use correct line width for list attribute 61a401a
963 - Avoid flip-flopping impl items when reordering them 37c216c
964 - Formatting breaks short lines when max_width is less than 100 9b36156
965 - Fix variant "Mixed" of imports_layout option 8c8676c
966 - Improve handling of long lines f885039
967 - Fix up lines exceeding max width 51c07f4
968 - Fix handling of modules in non_modrs_mods style cf573e8
969 - Do not duplicate attributes on use items e59ceaf
970 - Do not insert an extra brace in macros with native newlines 4c9ef93
971
972 ## [0.6.1] 2018-05-01
973
974 ### Changed
975
976 - Change the default value of imports_indent to IndentStyle::Block https://github.com/rust-lang/rustfmt/pull/2662
977
978 ### Fixed
979
980 - Handle formatting of auto traits 5b5a72c
981 - Use consistent formatting for empty enum and struct https://github.com/rust-lang/rustfmt/pull/2656
982
983 ## [0.6.0] 2018-04-20
984
985 ### Changed
986
987 - Improve public API 8669004
988
989 ## [0.5.0] 2018-04-20
990
991 ### Added
992
993 - Add `verbose-diff` CLI option 5194984
994
995 ### Changed
996
997 - Update rustc-ap-syntax to 103.0.0 dd807e2
998 - Refactor to make a sensible public API ca610d3
999
1000 ### Fixed
1001
1002 - Add spaces between consecutive `..` `..=` 61d29eb
1003
1004 ## [0.4.2] 2018-04-12
1005
1006 ### Added
1007
1008 - Handle binary operators and lifetimes 0fd174d
1009 - Add reorder_impl_items config option 94f5a05
1010 - Add `--unstable-features` CLI option to list unstable options from the `--help` output 8208f8a
1011 - Add merge_imports config option 5dd203e
1012
1013 ### Changed
1014
1015 - Format macro arguments with vertical layout ec71459
1016 - Reorder imports by default 164cf7d
1017 - Do not collapse block around expr with condition on match arm 5b9b7d5
1018 - Use vertical layout for complex attributes c77708f
1019 - Format array using heuristics for function calls 98c6f7b
1020 - Implement stable ordering for impl items with the the following item priority: type, const, macro, then method fa80ddf
1021 - Reorder imports by default 164cf7d
1022 - Group `extern crate` by default 3a138a2
1023 - Make `error_on_line_overflow` false by default f146711
1024 - Merge imports with the same prefix into a single nested import 1954513
1025 - Squash the various 'reorder imports' option into one 911395a
1026
1027 ### Fixed
1028
1029 - Print version is missing the channel ca6fc67
1030 - Do not add the beginning vert to the match arm 1e1d9d4
1031 - Follow indent style config when formatting attributes efd295a
1032 - Do not insert newline when item is empty a8022f3
1033 - Do not indent or unindent inside string literal ec1907b
1034
1035 ## [0.4.1] 2018-03-16
1036
1037 ### Added
1038
1039 - Add `ignore` configuration option.
1040 - Add `license_template_path` configuration option.
1041 - Format `lazy_static!`.
1042
1043 ### Fixed
1044
1045 - Fix formatting bugs.
1046 - Fix setting `reorder_modules` removing inline modules.
1047 - Format attributes on block expressions.
1048 - Support `dyn trait` syntax.
1049 - Support multiple patterns in `if let` and `while let`.
1050 - Support a pattern with parentheses.
1051
1052 ## [0.4.0] 2018-03-02
1053
1054 ### Changed
1055
1056 - Do not print verbose outputs when formatting with stdin.
1057 - Preserve trailing whitespaces in doc comments.
1058 - Scale the values of width heuristics by `max_width`.
1059
1060 ### Fixed
1061
1062 - Do not reorder items with `#[macro_use]`.
1063 - Fix formatting bugs.
1064 - Support the beginning `|` on a match arm.
1065
1066 ## [0.3.8] 2018-02-04
1067
1068 ### Added
1069
1070 - Format (or at least try to format) `macro_rules!`.
1071
1072 ## [0.3.7] 2018-02-01
1073
1074 ### Added
1075
1076 - Add `use_field_init_shorthand` config option.
1077 - Add `reorder_modules` configuration option.
1078
1079 ## [0.3.6] 2018-01-18
1080
1081 ### Fixed
1082
1083 - Fix panicking on formatting certain macros (#2371).
1084
1085 ## [0.3.5] 2018-01-15
1086
1087 ### Changed
1088
1089 - Format code block in comments when `wrap_comments` is set to `true`.
1090 - Remove `same_line_attributes` configuration option.
1091 - Rename `git-fmt` to `git-rustfmt`.
1092
1093 ### Fixed
1094
1095 - Rustup to `rustc 1.25.0-nightly (e6072a7b3 2018-01-13)`.
1096 - Fix formatting bugs.
1097
1098 ## [0.3.4] 2017-12-23
1099
1100 ### Added
1101
1102 - Add `--version` flag to `cargo-fmt`, allow `cargo fmt --version`.
1103
1104 ### Fixed
1105
1106 - Rustup to `rustc 1.24.0-nightly (5165ee9e2 2017-12-22)`.
1107
1108 ## [0.3.3] 2017-12-22
1109
1110 ### Added
1111
1112 - Format trait aliases.
1113
1114 ### Changed
1115
1116 - `cargo fmt` will format every workspace member.
1117
1118 ### Fixed
1119
1120 - Rustup to `rustc 1.24.0-nightly (250b49205 2017-12-21)`
1121 - Fix formatting bugs.
1122
1123 ## [0.3.2] 2017-12-15
1124
1125 ### Changed
1126
1127 - Warn when unknown configuration option is used.
1128
1129 ### Fixed
1130
1131 - Rustup to `rustc 1.24.0-nightly (0077d128d 2017-12-14)`.
1132
1133 ## [0.3.1] 2017-12-11
1134
1135 ### Added
1136
1137 - Add `error_on_unformatted` configuration option.
1138 - Add `--error-on-unformatted` command line option.
1139
1140 ### Changed
1141
1142 - Do not report formatting errors on comments or strings by default.
1143 - Rename `error_on_line_overflow_comments` to `error_on_unformatted`.
1144
1145 ### Fixed
1146
1147 - Fix formatting bugs.
1148 - Fix adding a trailing whitespace inside code block when `wrap_comments = true`.
1149
1150 ## [0.3.0] 2017-12-11
1151
1152 ### Added
1153
1154 - Support nested imports.
1155
1156 ### Changed
1157
1158 - Do not report errors on skipped items.
1159 - Do not format code block inside comments when `wrap_comments = true`.
1160 - Keep vertical spaces between items within range.
1161 - Format `format!` and its variants using compressed style.
1162 - Format `write!` and its variants using compressed style.
1163 - Format **simple** array using compressed style.
1164
1165 ### Fixed
1166
1167 - Fix `rustfmt --package package_name` not working properly.
1168 - Fix formatting bugs.
1169
1170 ## [0.2.17] 2017-12-03
1171
1172 ### Added
1173
1174 - Add `blank_lines_lower_bound` and `blank_lines_upper_bound` configuration options.
1175
1176 ### Changed
1177
1178 - Combine configuration options related to width heuristic into `width_heuristic`.
1179 - If the match arm's body is `if` expression, force to use block.
1180
1181 ### Fixed
1182
1183 - Fix `cargo fmt --all` being trapped in an infinite loop.
1184 - Fix many formatting bugs.
1185
1186 ### Removed
1187
1188 - Remove legacy configuration options.
1189
1190 ## [0.2.16] 2017-11-21
1191
1192 ### Added
1193
1194 - Remove empty lines at the beginning of the file.
1195 - Soft wrapping on doc comments.
1196
1197 ### Changed
1198
1199 - Break before `|` when using multiple lines for match arm patterns.
1200 - Combine `control_style`, `where_style` and `*_indent` config options into `indent_style`.
1201 - Combine `item_brace_style` and `fn_brace_style` config options into `brace_style`.
1202 - Combine config options related spacing around colons into `space_before_colon` and `space_after_colon`.
1203
1204 ### Fixed
1205
1206 - Fix many bugs.
1207
1208 ## [0.2.15] 2017-11-08
1209
1210 ### Added
1211
1212 - Add git-fmt tool
1213 - `where_single_line` configuration option.
1214
1215 ### Changed
1216
1217 - Rename `chain_one_line_max` to `chain_width`.
1218 - Change the suffix of indent-related configuration options to `_indent`.
1219
1220 ## [0.2.14] 2017-11-06
1221
1222 ### Fixed
1223
1224 - Rustup to the latest nightly.
1225
1226 ## [0.2.13] 2017-10-30
1227
1228 ### Fixed
1229
1230 - Rustup to the latest nightly.
1231
1232 ## [0.2.12] 2017-10-29
1233
1234 ### Fixed
1235
1236 - Fix a bug that `cargo fmt` hangs forever.
1237
1238 ## [0.2.11] 2017-10-29
1239
1240 ### Fixed
1241
1242 - Fix a bug that `cargo fmt` crashes.
1243
1244 ## [0.2.10] 2017-10-28
1245
1246 ## [0.2.9] 2017-10-16
1247
1248 ## [0.2.8] 2017-09-28
1249
1250 ## [0.2.7] 2017-09-21
1251
1252 ### Added
1253
1254 - `binop_separator` configuration option (#1964).
1255
1256 ### Changed
1257
1258 - Use horizontal layout for function call with a single argument.
1259
1260 ### Fixed
1261
1262 - Fix panicking when calling `cargo fmt --all` (#1963).
1263 - Refactorings & faster rustfmt.
1264
1265 ## [0.2.6] 2017-09-14
1266
1267 ### Fixed
1268
1269 - Fix a performance issue with nested block (#1940).
1270 - Refactorings & faster rustfmt.
1271
1272 ## [0.2.5] 2017-08-31
1273
1274 ### Added
1275
1276 - Format and preserve attributes on statements (#1933).
1277
1278 ### Fixed
1279
1280 - Use getters to access `Span` fields (#1899).
1281
1282 ## [0.2.4] 2017-08-30
1283
1284 ### Added
1285
1286 - Add support for `Yield` (#1928).
1287
1288 ## [0.2.3] 2017-08-30
1289
1290 ### Added
1291
1292 - `multiline_closure_forces_block` configuration option (#1898).
1293 - `multiline_match_arm_forces_block` configuration option (#1898).
1294 - `merge_derives` configuration option (#1910).
1295 - `struct_remove_empty_braces` configuration option (#1930).
1296 - Various refactorings.
1297
1298 ### Changed
1299
1300 - Put single-lined block comments on the same line with list-like structure's item (#1923).
1301 - Preserve blank line between doc comment and attribute (#1925).
1302 - Put the opening and the closing braces of enum and struct on the same line, even when `item_brace_style = "AlwaysNextLine"` (#1930).
1303
1304 ### Fixed
1305
1306 - Format attributes on `ast::ForeignItem` and take max width into account (#1916).
1307 - Ignore empty lines when calculating the shortest indent width inside macro with braces (#1918).
1308 - Handle tabs properly inside macro with braces (#1918).
1309 - Fix a typo in `compute_budgets_for_args()` (#1924).
1310 - Recover comment between keyword (`impl` and `trait`) and `{` which used to get removed (#1925).
1311
1312
1313 [install-from-source]: https://github.com/rust-lang/rustfmt#installing-from-source