Changelog History
Page 1
-
v2.0.0-rc.2
May 25, 2020 -
v1.5.1 Changes
June 24, 2022N.B A bug was introduced in v1.5.0/nightly-2022-06-15 which modified formatting. If you happened to run rustfmt over your code with one of those ~10 nightlies it's possible you may have seen formatting changes, and you may see additional changes after this fix since that bug has now been reverted.
๐ Fixed
- Correct an issue introduced in v1.5.0 where formatting changes were unintentionally introduced in a few cases with a large/long construct in a right hand side position (e.g. a large chain on the RHS of a local/assignment statement)
cargo fmt --version
properly displays the version value again #5395
๐ Changed
- 0๏ธโฃ Properly sort imports containing raw identifiers #3791 (note this is change version gated, and not applied by default)
โ Added
- Add new configuration option,
doc_comment_code_block_width
, which allows for setting a shorter width limit to use for formatting code snippets in doc comments #5384
Install/Download Options
- rustup (nightly) - nightly-2022-06-24
- ๐ GitHub Release Binaries - Release v1.5.1
- ๐ Build from source - Tag v1.5.1, see instructions for how to [install rustfmt from source][install-from-source]
-
v1.5.0 Changes
June 14, 2022๐ Changed
- Simplify the rustfmt help text by eliding the full path to the rustfmt binary path from the usage string when running
rustfmt --help
#5214
๐ Fixed
- โ Remove duplicate imports when
imports_granularity
is set toItem
#4725 - Properly handle stdin input containing an inner skip attribute #5368
- Maintain attributes on imports when
imports_granularity
is set toItem
#5030 - Format empty trait definitions as a single line when both
empty_item_single_line
is enabled andbrace_style
is set toAlwaysNextLine
#5047 - Don't change granularity of imports containing comments with
imports_granularity
if doing so could lose or misplace those comments #5311 - Prevent rustfmt from removing trailing comments at the end of files annotated with inner
#![rustfmt::skip]
attributes #5033 - ๐ Fixed various
error[internal]: left behind trailing whitespace"
issues: - Prevent adding a block indented newline before a function parameter with a complex type that was formatted over multiple lines #5125
- ๐ Fix various module resolution issues preventing rustfmt from finding modules that should be formatted:
- Give users a clearer error message when resolving a module who's file path is ambiguous (e.g
x.rs
andx/mod.rs
). Before users were given aFile not found
error message which was confusing #5167 - ๐ Fix various issues related to type aliases:
- Prevent rustfmt from adding
= impl
to associated types defined in macro bodies #4823 - 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 - Prevent rustfmt from adding an
impl Trait
definition into types #5086
- Prevent rustfmt from adding
- ๐ Fix cases where
normalize_comments=true
would de-normalizes some comments by changing inline comments into block comments #4909 - ๐ Prevent rustfmt from wrapping the content of markdown reference-style links in doc comments #5095 #4933
- Don't format files annotated with inner
#![rustfmt::skip]
attribute PR #5094 - Prevent duplicate comma when struct pattern ends with
..
andtrailing_comma=Always
. For example,let Foo { a, .. } = b;
would becomelet Foo { a,, .. } = b;
#5066 - ๐ Fix the order of
static
andasync
keywords when rewriting static async closures. The correct order isstatic
and thenasync
(e.gstatic async || {}
) #5149 - Retain the fully qualified path segment when rewriting struct literals in expression position. Now
<Struct as Trait>::Type
is not rewritten asTrait::Type
#5151 - ๐ 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 - Backport json emitter and stdin changes PR #5054
- Always generate some output when formatting
@generated
files via stdin even whenformat_generated_files=false
. Not producing output caused rust-analyzer to delete the file content rust-lang/rust-analyzer #5172 - 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
- 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 - ๐ 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 - ๐ Fix panic when
import_granularity
was set toModule
,One
, orCrate
and the import use declaration contained an aliasuse crate a::b as b1
#5131 - โ Add a newline between generic parameters and their doc comments to prevent the generic parameters from being merged into their doc comments #5122
- ๐ Fixes indentation issue where string literals manually broken with line continuation characters (
\
) would be incorrectly indented in macro definitions when settingformat_strings=true
#4036 - Properly wrap and format long markdown block quotes when
wrap_comments=true
#5157 - 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 - Prevent rustfmt from removing commas between struct fields when those fields were also separated by an empty line #4791 #4928
- ๐ Fix compiler error caused when formatting imports with
imports_granularity=Module
and a path containingself
. Given the following importuse crate::lexer::{self, tokens::TokenData};
, rustfmt would transform theself
import intouse crate::lexer::self;
. Now rustfmt producesuse crate::lexer::{self};
#4681 - Prevent rustfmt from breaking long type links in doc comments on namespace qualifiers (
::
) whenwrap_comments=true
. Breaking these long type links over multiple lines prevented them from being properly rendered in rustdoc #5260 - Correctly find the start of struct bodies after any generic
const
parameters. Naively searching for an opening{
lead to issues since genericconst
parameters are also defined with{}
(e.g.struct Example<const N: usize = { 1048576 }> {}
) #5273 - ๐ Prevent rustfmt from merging derives when using inner or outer
rustfmt::skip::attributes
attributes. For example,#[rustfmt::skip::attributes(derive)]
#5270 - Retain trailing
;
when rewriting macro calls in extern blocks. For example,extern "C" { x!(-); }
#5281 - โ 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
โ Added
- Added
One
as a new group_imports option to create a single group for all imports PR #4966 - Add short_array_element_width_threshold config option to give users more control over when
Mixed
list formatting is used PR #5228
โ Removed
- โ Removed unstable, nightly-only config option
report_todo
#5101 - โ Removed unstable, nightly-only config option
report_fixme
#5102 - Removed unstable, nightly-only config option
license_template_path
#5103
Misc
- ๐ Improved performance when formatting large and deeply nested expression trees, often found in generated code, which have many expressions that exceed
max_width
#5128, #4867, #4476, #5139
Install/Download Options
- rustup (nightly) - nightly-2022-06-15
- ๐ GitHub Release Binaries - Release v1.5.0
- ๐ Build from source - Tag v1.5.0, see instructions for how to [install rustfmt from source][install-from-source]
- Simplify the rustfmt help text by eliding the full path to the rustfmt binary path from the usage string when running
-
v1.4.38 Changes
October 20, 2021๐ Changed
- Switched from
rustc-ap-*
crates torustc_private
for consumption model of rustc internals - โก๏ธ
annotate-snippets
updated to v0.8 PR #4762 - ๐ Greatly improved the performance of
cargo fmt
in large workspaces utilizing the--all
flag by updating to a newer version ofcargo_metadata
that leverages updatedcargo
output from v1.51+ PR #4997 - ๐ Improved formatting of long slice patterns #4530
- Note you must have
version = Two
in your configuration to take advantage of the new formatting
- Note you must have
- Stabilized
match_block_trailing_comma
configuration option #3380 - https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#match_block_trailing_comma - Stabilized
disable_all_formatting
configuration option #5026 - https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#disable_all_formatting - ๐ 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])
- โ Addressed various clippy and rustc warnings
๐ Fixed
- ๐ Resolved issue where specious whitespace would be inserted when a block style comment was terminated within string literal processing #4312
- ๐ Nested out-of-line mods are again parsed and formatted #4874
- ๐ป Accepts
2021
for edition value from rustfmt command line PR #4847 - ๐ป Unstable command line options are no longer displayed in
--help
text on stable PR #4798 - Stopped panicking on patterns in match arms which start with non-ascii characters #4868
- 0๏ธโฃ Stopped stripping defaults on const params #4816
- ๐ Fixed issue with dropped content with GAT aliases with self bounds in impls #4911
- Stopped removing generic args on associated type constraints #4943
- Stopped dropping visibility on certain trait and impl items #4960
- ๐ Fixed dropping of qualified paths in struct patterns #4908 and #5005
- ๐ Fixed bug in line width calculation that was causing specious formatting of certain patterns #4031
- 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
- ๐ Fixed bug where rustfmt would drop parameter attributes if they were too long in certain cases #4579
- Resolved idempotency issue with extern body elements #4963
- ๐ 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
- 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 - ๐ Fixed bug in cases where derive attributes started with a block style comment #4984
- Fixed issue where the struct rest could be lost when
struct_field_align_threshold
was enabled #4926 - ๐ Handles cases where certain control flow type expressions have comments between patterns/keywords and the pattern ident contains the keyword #5009
- ๐ Handles tuple structs that have explicit visibilities and start with a block style comment #5011
- ๐ Handles leading line-style comments in certain types of macro calls #4615
โ Added
- Granular width heuristic options made available for user control PR #4782. This includes the following:
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 https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics- ๐ New
One
variant added toimports_granularity
configuration option which can be used to reformat all imports into a single use statement #4669 - rustfmt will now skip files that are annotated with
@generated
at the top of the file #3958 ifformat_generated_files
option is set tofalse
(by default@generated
files are formatted) - New configuration option
hex_literal_case
that allows user to control the casing utilized for hex literals PR #4903
๐ See the section on the configuration site for more information https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#hex_literal_case
- ๐
cargo fmt
now directly supports the--check
flag, which means it's now possible to runcargo fmt --check
instead of the more verbosecargo fmt -- --check
#3888
Install/Download Options
- rustup (nightly) - pending
- ๐ GitHub Release Binaries - Release v1.4.38
- ๐ Build from source - Tag v1.4.38, see instructions for how to [install rustfmt from source][install-from-source]
- Switched from
-
v1.4.37 Changes
April 03, 2021๐ Changed
- โก๏ธ
rustc-ap-*
crates updated to v712.0.0
๐ Fixed
- Resolve idempotence issue related to indentation of macro defs that contain or-patterns with inner comments (#4603)
- โ Addressed various clippy and rustc warnings
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - pending
- ๐ GitHub Release Binaries - Release v1.4.37
- ๐ Build from source - Tag v1.4.37, see instructions for how to [install rustfmt from source][install-from-source]
- โก๏ธ
-
v1.4.36 Changes
February 07, 2021๐ Changed
- โก๏ธ
rustc-ap-*
crates updated to v705.0.0
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - pending
- ๐ GitHub Release Binaries - Release v1.4.36
- ๐ Build from source - Tag v1.4.36, see instructions for how to [install rustfmt from source][install-from-source]
- โก๏ธ
-
v1.4.35 Changes
February 03, 2021๐ Changed
- โก๏ธ
rustc-ap-*
crates updated to v702.0.0
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - *n/a (superseded by v1.4.36)
- ๐ GitHub Release Binaries - Release v1.4.35
- ๐ Build from source - Tag v1.4.35, see instructions for how to [install rustfmt from source][install-from-source]
- โก๏ธ
-
v1.4.34 Changes
January 28, 2021๐ Fixed
- Don't insert trailing comma on (base-less) rest in struct literals within macros (#4675)
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - Starting in
2021-01-31
- ๐ GitHub Release Binaries - Release v1.4.34
- ๐ Build from source - Tag v1.4.34, see instructions for how to [install rustfmt from source][install-from-source]
-
v1.4.33 Changes
January 27, 2021๐ Changed
- ๐ง
merge_imports
configuration has been deprecated in favor of the newimports_granularity
option. Any existing usage ofmerge_imports
will be automatically mapped to the corresponding value onimports_granularity
with a warning message printed to encourage users to update their config files.
โ Added
- ๐ New
imports_granularity
option has been added which succeedsmerge_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, PR #4639)
๐ See the section on the configuration site for more information https://rust-lang.github.io/rustfmt/?version=v1.4.33&search=#imports_granularity
๐ Fixed
- ๐ Fix erroneous removal of
const
keyword on const trait impl (#4084) - ๐ Fix incorrect span usage wit const generics in supertraits (#4204)
- ๐ Use correct span for const generic params (#4263)
- Correct span on const generics to include type bounds (#4310)
- Idempotence issue on blocks containing only empty statements (#4627 and #3868)
- ๐ Fix issue with semicolon placement on required functions that have a trailing comment that ends in a line-style comment before the semicolon (#4646)
- Avoid shared interned cfg_if symbol since rustfmt can re-initialize the rustc_ast globals on multiple inputs (#4656)
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - n/a (superseded by v1.4.34)
- ๐ GitHub Release Binaries - Release v1.4.33
- ๐ Build from source - Tag v1.4.33, see instructions for how to [install rustfmt from source][install-from-source]
- ๐ง
-
v1.4.32 Changes
January 16, 2021๐ Fixed
- Indentation now correct on first bound in cases where the generic bounds are multiline formatted and the first bound itself is multiline formatted (#4636)
Install/Download Options
- ๐ฆ crates.io package - pending
- rustup (nightly) - Starting in
2021-01-18
- ๐ GitHub Release Binaries - Release v1.4.32
- ๐ Build from source - Tag v1.4.32, see instructions for how to [install rustfmt from source][install-from-source]