]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agosome minor clippy fixes
Matthias Krüger [Wed, 5 Jan 2022 20:19:36 +0000 (21:19 +0100)]
some minor clippy fixes

2 years agoUse <stdin> when emitting stdin as filename (#4298)
Seiichi Uchida [Fri, 3 Jul 2020 02:13:16 +0000 (11:13 +0900)]
Use <stdin> when emitting stdin as filename (#4298)

# Conflicts:
# src/config/file_lines.rs
# src/rustfmt/main.rs
# src/test/mod.rs

2 years agoFix newlines in JSON output (#4262)
Tim [Tue, 23 Jun 2020 00:20:29 +0000 (01:20 +0100)]
Fix newlines in JSON output (#4262)

* Fix newlines in JSON output

This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line.

When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too).

Fixes #4259

* Update tests
# Conflicts:
# tests/writemode/target/output.json

2 years agorefactor: update json emitter to better handle errors (#3953)
Caleb Cartwright [Mon, 9 Dec 2019 10:41:16 +0000 (04:41 -0600)]
refactor: update json emitter to better handle errors (#3953)

2 years agoFix --check -l with stdin. (#3910)
Chris Emerson [Tue, 12 Nov 2019 02:55:04 +0000 (02:55 +0000)]
Fix --check -l with stdin. (#3910)

* Fix some possible panics when using `--check` with stdin.

One case which doesn't work is when there are only line ending fixes;
with stdin rustfmt is unable to detect the difference as it stores
the input with Unix line endings.

* Add test for `rustfmt --check -l` with stdin.

2 years agoMake `--check` work when running from stdin. (#3896)
Chris Emerson [Wed, 6 Nov 2019 10:15:34 +0000 (10:15 +0000)]
Make `--check` work when running from stdin. (#3896)

# Conflicts:
# src/bin/main.rs

2 years agoImprove out of line module resolution
Yacin Tmimi [Mon, 20 Dec 2021 02:27:25 +0000 (21:27 -0500)]
Improve out of line module resolution

Fixes 5119

When the directory structure was laid out as follows:

```
dir
 |---mod_a
 |    |---sub_mod_1.rs
 |    |---sub_mod_2.rs
 |---mod_a.rs
```

And ``mod_a.rs`` contains the following content:

```rust
mod mod_a {
    mod sub_mod_1;
    mod sub_mod_2;
}
```

rustfmt previously tried to find ``sub_mod_1.rs`` and ``sub_mod_2.rs``
in ``./mod_a/mod_a/``. This directory does not exist and this caused
rustfmt to fail with the error message:

    Error writing files: failed to resolve mod

Now, both ``sub_mod_1.rs`` and ``sub_mod_2.rs`` are resolved correctly
and found at ``mod_a/sub_mod_1.rs`` and ``mod_a/sub_mod_2.rs``.

2 years agoDo not flatten match arm block with leading attributes
David Lattimore [Wed, 29 Dec 2021 23:13:45 +0000 (10:13 +1100)]
Do not flatten match arm block with leading attributes

This is a backport of #4124.

Fixes #4109

2 years agofeat: support parsing asm! args
Caleb Cartwright [Wed, 29 Dec 2021 01:23:51 +0000 (19:23 -0600)]
feat: support parsing asm! args

2 years agochore: bump toolchain
Caleb Cartwright [Wed, 29 Dec 2021 01:23:31 +0000 (19:23 -0600)]
chore: bump toolchain

2 years agochore: reduce some vis. for updated unreachable_pub lint
Caleb Cartwright [Mon, 27 Dec 2021 23:42:48 +0000 (17:42 -0600)]
chore: reduce some vis. for updated unreachable_pub lint

2 years agoRetain qualified path when rewriting struct literals
Yacin Tmimi [Fri, 24 Dec 2021 01:22:09 +0000 (20:22 -0500)]
Retain qualified path when rewriting struct literals

Fixes 5151

Details about the qualified path are now passed along so that rustfmt
can include them when formatting struct literals.

2 years agoFix static async closure qualifier order
David Tolnay [Thu, 23 Dec 2021 22:23:51 +0000 (14:23 -0800)]
Fix static async closure qualifier order

2 years agochore: cleanup unused imports
Caleb Cartwright [Tue, 21 Dec 2021 02:33:20 +0000 (20:33 -0600)]
chore: cleanup unused imports

2 years agorefactor: encapsulate cfg_if parsing within parse mod
Caleb Cartwright [Tue, 21 Dec 2021 02:28:55 +0000 (20:28 -0600)]
refactor: encapsulate cfg_if parsing within parse mod

2 years agorefactor: extract final rustc_parse touchpoint from macros.rs
Caleb Cartwright [Tue, 21 Dec 2021 01:44:23 +0000 (19:44 -0600)]
refactor: extract final rustc_parse touchpoint from macros.rs

2 years agorefactor: move lazy_static parsing to parse mod
Caleb Cartwright [Tue, 21 Dec 2021 01:38:00 +0000 (19:38 -0600)]
refactor: move lazy_static parsing to parse mod

2 years agorefactor: move macro arg parsing to parse mod
Caleb Cartwright [Tue, 21 Dec 2021 00:59:01 +0000 (18:59 -0600)]
refactor: move macro arg parsing to parse mod

2 years agorefactor: rename syntux mod to parse
Caleb Cartwright [Mon, 20 Dec 2021 23:55:48 +0000 (17:55 -0600)]
refactor: rename syntux mod to parse

2 years agoMerge pull request #5140 from calebcartwright/subtree-sync-2021-12-19
Caleb Cartwright [Mon, 20 Dec 2021 22:40:50 +0000 (16:40 -0600)]
Merge pull request #5140 from calebcartwright/subtree-sync-2021-12-19

Subtree sync

2 years agochore: bump toolchain
Caleb Cartwright [Mon, 20 Dec 2021 17:58:27 +0000 (11:58 -0600)]
chore: bump toolchain

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19
Caleb Cartwright [Sun, 19 Dec 2021 21:22:45 +0000 (15:22 -0600)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19

2 years agoRemove unnecessary sigils around `Ident::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 05:13:11 +0000 (16:13 +1100)]
Remove unnecessary sigils around `Ident::as_str()` calls.

2 years agoRemove unnecessary sigils around `Symbol::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 03:39:23 +0000 (14:39 +1100)]
Remove unnecessary sigils around `Symbol::as_str()` calls.

2 years agoRemove `SymbolStr`.
Nicholas Nethercote [Tue, 14 Dec 2021 21:32:21 +0000 (08:32 +1100)]
Remove `SymbolStr`.

By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!

2 years agoPrevent duplicate comma when formatting struct pattern with ".."
Yacin Tmimi [Thu, 18 Nov 2021 01:46:48 +0000 (20:46 -0500)]
Prevent duplicate comma when formatting struct pattern with ".."

Fixes 5066

When a struct pattern that contained a ".." was formatted, it was
assumed that a trailing comma should always be added if the struct
fields weren't formatted vertically.

Now, a trailing comma is only added if not already included in the
reformatted struct fields.

2 years agoclippy fixes
Matthias Krüger [Sun, 12 Dec 2021 19:15:08 +0000 (20:15 +0100)]
clippy fixes

2 years agoBackport: Do not touch module with #![rustfmt::skip] (4297)
Yacin Tmimi [Wed, 24 Nov 2021 23:47:37 +0000 (18:47 -0500)]
Backport: Do not touch module with #![rustfmt::skip] (4297)

Although the implementation is slightly different than the original PR,
the general idea is the same. After collecting all modules we want to
exclude formatting those that contain the #![rustfmt::skip] attribute.

2 years agoMerge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree
Caleb Cartwright [Fri, 3 Dec 2021 03:35:30 +0000 (21:35 -0600)]
Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree

2 years agoMerge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
Caleb Cartwright [Fri, 3 Dec 2021 03:29:47 +0000 (21:29 -0600)]
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02

subtree sync

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02
Caleb Cartwright [Fri, 3 Dec 2021 03:02:14 +0000 (21:02 -0600)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02

2 years agoDetermine when new comment lines are needed for itemized blocks
Yacin Tmimi [Fri, 19 Nov 2021 23:52:52 +0000 (18:52 -0500)]
Determine when new comment lines are needed for itemized blocks

Fixes 5088

Previously, rustfmt would add a new comment line anytime it reformatted
an itemized block within a comment when ``wrap_comments=true``. This
would lead to rustfmt adding empty comments with trailing whitespace.

Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.

2 years agoUpdate nightly only test with #[nightly_only_test] attribute
Yacin Tmimi [Mon, 29 Nov 2021 04:39:31 +0000 (23:39 -0500)]
Update nightly only test with #[nightly_only_test] attribute

2 years agorefactor: maintain more AST info when formatting a RHS
Caleb Cartwright [Sun, 28 Nov 2021 21:22:49 +0000 (15:22 -0600)]
refactor: maintain more AST info when formatting a RHS

2 years agoConditionally compile tests based on CFG_RELEASE_CHANNEL env var
Yacin Tmimi [Sat, 27 Nov 2021 22:14:15 +0000 (17:14 -0500)]
Conditionally compile tests based on CFG_RELEASE_CHANNEL env var

Adds the ``nightly_only_test`` and ``stable_only_test`` attribute macros
that prevent or allow certain tests to compile on nightly and stable
respectively. This is achieved through conditionally outputting the
tests TokenStream.

If CFG_RELEASE_CHANNEL is not set, it's assumed that we're running in a
nightly environment.

To mark a test as nightly only:

    #[nightly_only_test]
    #[test]
    fn only_run_on_nightly() {
        ...
    }

To mark a test a stable only:

    #[stable_only_test]
    #[test]
    fn only_run_on_stable() {
        ...
    }

2 years agoRun Windows, Linux, and Mac CI tests with nightly and stable channels
Yacin Tmimi [Wed, 24 Nov 2021 08:35:01 +0000 (03:35 -0500)]
Run Windows, Linux, and Mac CI tests with nightly and stable channels

2 years agoAdd more tests for comments in lists
mujpao [Wed, 24 Nov 2021 23:05:23 +0000 (15:05 -0800)]
Add more tests for comments in lists

2 years agoUpdate README.md
Fabian Keller [Wed, 24 Nov 2021 09:38:55 +0000 (10:38 +0100)]
Update README.md

2 years agoChange how the fn params span is calculated
Esteban Kuber [Wed, 24 Nov 2021 17:11:15 +0000 (17:11 +0000)]
Change how the fn params span is calculated

Use the available Generics span field to avoid issues with `T: Fn()` bounds.

This is necessary to land #85346.

2 years agofix: do not wrap reference-style doc links
Dom [Fri, 19 Nov 2021 19:15:33 +0000 (20:15 +0100)]
fix: do not wrap reference-style doc links

Prevents wrap_comments from incorrectly wrapping reference-style doc
links.

2 years agoAdd a few missing tracking issues in Configurations.md (#5084)
Johannes Linke [Sat, 20 Nov 2021 01:22:50 +0000 (02:22 +0100)]
Add a few missing tracking issues in Configurations.md (#5084)

* Add a few missing tracking issues in Configurations.md

* fix: tracking issue for imports_granularity stabilization

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2 years agoPreserve normalized comments after last list item
mujpao [Fri, 19 Nov 2021 01:06:49 +0000 (17:06 -0800)]
Preserve normalized comments after last list item

2 years agofix: correct some type alias issues
Caleb Cartwright [Thu, 18 Nov 2021 18:39:38 +0000 (12:39 -0600)]
fix: correct some type alias issues

2 years agotests: add cases for type alias issues
Caleb Cartwright [Thu, 18 Nov 2021 18:38:34 +0000 (12:38 -0600)]
tests: add cases for type alias issues

2 years agorefactor: cleanup duplicative Impl handling code
Caleb Cartwright [Wed, 17 Nov 2021 18:51:37 +0000 (12:51 -0600)]
refactor: cleanup duplicative Impl handling code

2 years agoLink tracking issues in Configurations.md (#4096)
Wu Yu Wei [Tue, 31 Mar 2020 06:36:12 +0000 (14:36 +0800)]
Link tracking issues in Configurations.md (#4096)

# Conflicts:
# Configurations.md

2 years agoMerge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
Caleb Cartwright [Mon, 8 Nov 2021 02:37:34 +0000 (20:37 -0600)]
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync

2 years agoMerge pull request #5070 from calebcartwright/rustup-2021-11-s1
Caleb Cartwright [Mon, 8 Nov 2021 01:40:15 +0000 (19:40 -0600)]
Merge pull request #5070 from calebcartwright/rustup-2021-11-s1

subtree sync

2 years agochore: bump toolchain
Caleb Cartwright [Mon, 8 Nov 2021 01:06:24 +0000 (19:06 -0600)]
chore: bump toolchain

2 years agoMerge remote-tracking branch 'upstream/master' into rustup-2021-11-s1
Caleb Cartwright [Sun, 7 Nov 2021 20:44:33 +0000 (14:44 -0600)]
Merge remote-tracking branch 'upstream/master' into rustup-2021-11-s1

2 years agorefactor: dedupe associated item visitation
Caleb Cartwright [Sat, 6 Nov 2021 22:12:25 +0000 (17:12 -0500)]
refactor: dedupe associated item visitation

2 years agoast: Fix naming conventions in AST structures
Vadim Petrochenkov [Sun, 7 Nov 2021 08:43:49 +0000 (16:43 +0800)]
ast: Fix naming conventions in AST structures

TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn

All `*Kind`s in AST are supposed to be enums.

Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.

Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.

2 years agorefactor: dedupe & simplify ty alias formatting
Caleb Cartwright [Sat, 6 Nov 2021 17:59:06 +0000 (12:59 -0500)]
refactor: dedupe & simplify ty alias formatting

2 years agoPut empty trait braces on same line if possible
mujpao [Tue, 2 Nov 2021 06:13:30 +0000 (23:13 -0700)]
Put empty trait braces on same line if possible

2 years agoUpdate IntelliJ Integration (#4238)
Dmitry Murzin [Sat, 6 Jun 2020 14:19:50 +0000 (17:19 +0300)]
Update IntelliJ Integration (#4238)

2 years agofix: handle external mods imported via external->inline load hierarchy
Caleb Cartwright [Thu, 4 Nov 2021 23:00:22 +0000 (18:00 -0500)]
fix: handle external mods imported via external->inline load hierarchy

2 years agoci: drop appveyor
Caleb Cartwright [Thu, 4 Nov 2021 02:10:01 +0000 (21:10 -0500)]
ci: drop appveyor

2 years ago Remove grave accent that shouldn't be there
r00ster [Mon, 1 Nov 2021 18:53:35 +0000 (19:53 +0100)]
 Remove grave accent that shouldn't be there

2 years agoUse a custom env var for log settings intead of default RUST_LOG
Peter Hall [Wed, 7 Oct 2020 11:55:01 +0000 (12:55 +0100)]
Use a custom env var for log settings intead of default RUST_LOG

# Conflicts:
# src/rustfmt/main.rs

2 years agoPrevent trailing whitespace in where clause bound predicate
Yacin Tmimi [Fri, 8 Oct 2021 23:22:12 +0000 (19:22 -0400)]
Prevent trailing whitespace in where clause bound predicate

resolves 5012
resolves 4850

This behavior was noticed when using the ``trailing_comma = "Never"``
configuration option (5012).

This behavior was also noticed when using default configurations (4850).

rustfmt would add a trailing space to where clause bounds that had an
empty right hand side.

Now no trailing space is added to the end of these where clause bounds.

2 years agoDocument RUSTFMT environment variable (#4464)
Jonathan [Sun, 11 Oct 2020 16:28:45 +0000 (16:28 +0000)]
Document RUSTFMT environment variable (#4464)

* Document RUSTFMT env var

* Move documentation up

* Apply suggestions from code review

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
* Fix accedental removal

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
# Conflicts:
# README.md

2 years agoFix MSRV
chansuke [Wed, 25 Nov 2020 10:31:02 +0000 (19:31 +0900)]
Fix MSRV

2 years agoREADME grammar fix (#3926)
enterprisey [Thu, 14 Nov 2019 14:44:59 +0000 (09:44 -0500)]
README grammar fix (#3926)

Remove comma splice

2 years agorefactor: minor parser cleanup
Caleb Cartwright [Sat, 30 Oct 2021 15:10:08 +0000 (10:10 -0500)]
refactor: minor parser cleanup

2 years agoRetain trailing comments in module when using rustfmt::skip attribute
Yacin Tmimi [Tue, 19 Oct 2021 05:14:51 +0000 (01:14 -0400)]
Retain trailing comments in module when using rustfmt::skip attribute

Resolves 5033

Trailing comments at the end of the root Module were removed because the
module span did not extend until the end of the file.

The root Module's span now encompasses the entire file, which ensures
that no comments are lost when using ``#![rustfmt::skip]``

2 years agoRemove legacy-rustfmt.toml (#4169)
Seiichi Uchida [Mon, 11 May 2020 00:50:41 +0000 (09:50 +0900)]
Remove legacy-rustfmt.toml (#4169)

2 years agofix a bunch of the other clippy warnings that look interesting
Matthias Krüger [Sat, 23 Oct 2021 21:21:52 +0000 (23:21 +0200)]
fix a bunch of the other clippy warnings that look interesting

2 years agofix clippy::needless_borrow
Matthias Krüger [Sat, 23 Oct 2021 21:07:57 +0000 (23:07 +0200)]
fix clippy::needless_borrow

2 years agoAdd rustdoc CI check
Yacin Tmimi [Sat, 23 Oct 2021 21:18:47 +0000 (17:18 -0400)]
Add rustdoc CI check

Resolves 5038

rust-lang/rust builds now document rustfmt (rust-lang/rust#87119). The
build process is updated with doc checks to ensure that rustfmt doesn't
introduce warnings.

Warnings are treated as hard errors in rust-lang/rust and won't show
until bors tests the changes (refs rust-lang/rust#90087).

2 years agoMerge pull request #5043 from calebcartwright/another-subtree-sync
Caleb Cartwright [Sun, 24 Oct 2021 19:56:55 +0000 (14:56 -0500)]
Merge pull request #5043 from calebcartwright/another-subtree-sync

sync subtree

2 years agoMerge remote-tracking branch 'upstream/master' into another-subtree-sync
Caleb Cartwright [Sun, 24 Oct 2021 18:45:19 +0000 (13:45 -0500)]
Merge remote-tracking branch 'upstream/master' into another-subtree-sync

2 years agoAdd One option to group_imports (#4966)
Martinez [Sat, 23 Oct 2021 16:01:48 +0000 (19:01 +0300)]
Add One option to group_imports (#4966)

* Add Together option to group_imports

* Rename option to One

* Rename files from Together to One

2 years agofix doc issue in rustfmt
Caleb Cartwright [Thu, 21 Oct 2021 22:22:54 +0000 (17:22 -0500)]
fix doc issue in rustfmt

2 years agoensure cargo-fmt tests are excluded from root workspace
Caleb Cartwright [Wed, 20 Oct 2021 15:12:22 +0000 (10:12 -0500)]
ensure cargo-fmt tests are excluded from root workspace

2 years agoMerge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
Caleb Cartwright [Wed, 20 Oct 2021 05:11:59 +0000 (00:11 -0500)]
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree

2 years agochore: bump version and changelog
Caleb Cartwright [Wed, 20 Oct 2021 05:00:30 +0000 (00:00 -0500)]
chore: bump version and changelog

2 years agoMerge pull request #5036 from calebcartwright/1.4.38-subtree
Caleb Cartwright [Wed, 20 Oct 2021 04:38:47 +0000 (23:38 -0500)]
Merge pull request #5036 from calebcartwright/1.4.38-subtree

sync subtree

2 years agochore: bump toolchain, fix conflict
Caleb Cartwright [Wed, 20 Oct 2021 04:13:06 +0000 (23:13 -0500)]
chore: bump toolchain, fix conflict

2 years agoMerge branch 'master' into 1.4.38-subtree
Caleb Cartwright [Wed, 20 Oct 2021 04:01:25 +0000 (23:01 -0500)]
Merge branch 'master' into 1.4.38-subtree

2 years agoReplace match expression with match! macro
Yacin Tmimi [Tue, 19 Oct 2021 00:48:58 +0000 (20:48 -0400)]
Replace match expression with match! macro

This is a follow up to 5f4811ed7bc600e0cbe40c962e8933adb9baaddf

The matches! macro expresses the condition more succinctly and avoids
the extra level of indentation introduced with the match arm body.

2 years agoHandle DefinitiveListTactic::SpecialMacro when writing pre-comments
Yacin Tmimi [Thu, 14 Oct 2021 21:16:28 +0000 (17:16 -0400)]
Handle DefinitiveListTactic::SpecialMacro when writing pre-comments

Resolves 4615

Previously only Vertical and Mixed enum variants of DefinitiveListTactic
were considered when rewriting pre-comments for inner items in
lists::write_list.

Because we failed to considering the SpecialMacro variant we ended up in
a scenario where a ListItem with a pre_comment and a pre_comment_style
of ListItemCommentStyle::DifferentLine was written on the same line as the
list item itself.

Now we apply the same pre-comment formatting to SpecialMacro, Vertical,
and Mixed variants of DefinitiveListTactic.

2 years agoci: fix release asset upload job
Caleb Cartwright [Thu, 14 Oct 2021 02:41:50 +0000 (21:41 -0500)]
ci: fix release asset upload job

2 years agofeat: stabilize disable_all_formatting
Caleb Cartwright [Thu, 14 Oct 2021 02:22:34 +0000 (21:22 -0500)]
feat: stabilize disable_all_formatting

2 years agoUpdate connector search in ControlFlow::rewrite_pat_expr for for loops
Yacin Tmimi [Wed, 6 Oct 2021 17:09:24 +0000 (13:09 -0400)]
Update connector search in ControlFlow::rewrite_pat_expr for for loops

Resolves 5009

For loops represented by a ControlFlow object use " in" as their connector.
rustfmt searches for the first uncommented occurrence of the word "in" within the
current span and adjusts it's starting point to look for comments right after that.
visually this looks like this:

    rustfmt starts looking for comments here
            |
            V
    for x in /* ... */ 0..1 {}

This works well in most cases, however when the pattern also contains
the word "in", this leads to issues.

    rustfmt starts looking for comments here
          |
          V
    for in_here in /* ... */ 0..1 {}
        -------
        pattern

In order to correctly identify the connector, the new approach first
updates the span to start after the pattern and then searches for the
first uncommented occurrence of "in".

2 years agoAdjust non-empty tuple struct span to start before fields
Yacin Tmimi [Tue, 5 Oct 2021 05:24:10 +0000 (01:24 -0400)]
Adjust non-empty tuple struct span to start before fields

Resolves 5011

Tuple structs with visibility modifiers and comments before the first
field were incorrectly formatted. Comments would duplicate part of the
visibility modifier and struct name.

When trying to parse the tuple fields the ``items::Context`` searches
for the opening '(', but because the visibility modifier introduces
another '(' -- for example ``pub(crate)`` -- the parsing gets messed up.

Now the span is adjusted to start after the struct identifier, or after
any generics. Adjusting the span in this way ensures that the
``items::Contex`` will correctly find the tuple fields.

2 years agoPrevent structs with ".." from being rewritten with alignment
Yacin Tmimi [Mon, 11 Oct 2021 22:30:35 +0000 (18:30 -0400)]
Prevent structs with ".." from being rewritten with alignment

 rustfmt should only support rewriting a struct in an expression
 position with alignment (non-default behavior) when there is no rest
 (with or without a base) and all of the fields are non-shorthand.

2 years agoStabilize match_block_trailing_comma. (#4145)
Emilio Cobos Álvarez [Sat, 16 May 2020 20:20:51 +0000 (22:20 +0200)]
Stabilize match_block_trailing_comma. (#4145)

Servo has used this since forever, and it'd be useful to be able to use
rustfmt stable there so that we can use the same rustfmt version in
both Firefox and Servo.

Feel free to close this if there's any reason it shouldn't be done.

2 years agoAdd additional test cases for issue 4984
Yacin Tmimi [Wed, 29 Sep 2021 18:18:54 +0000 (14:18 -0400)]
Add additional test cases for issue 4984

2 years agoUpdate derive attibute span to start after opening '('
Yacin Tmimi [Fri, 24 Sep 2021 02:43:03 +0000 (22:43 -0400)]
Update derive attibute span to start after opening '('

Fixes 4984

When parsing derive attributes we're only concerned about the traits
and comments listed between the opening and closing parentheses.

Derive attribute spans currently start at the '#'.

    Span starts here
    |
    v
    #[derive(...)]

After this update the derive spans start after the opening '('.

    Span starts here
             |
             V
    #[derive(...)]

2 years agoWrap long array and slice patterns.
Patrick Walton [Sat, 18 Sep 2021 01:56:30 +0000 (18:56 -0700)]
Wrap long array and slice patterns.

Closes #4530.

2 years agoAdd tests for binop_separator = Back
Ulyssa [Mon, 20 Sep 2021 23:29:28 +0000 (16:29 -0700)]
Add tests for binop_separator = Back

2 years agoPrevent removal of qualified path for tuple struct inside macro
Yacin Tmimi [Mon, 27 Sep 2021 20:55:23 +0000 (16:55 -0400)]
Prevent removal of qualified path for tuple struct inside macro

fixes 5005

This was very similar to 4964 and the fix was to extract and pass along
the qself of the ``PatKind::TupleStruct``

2 years agoIn Configurations.md demonstrate both cases for noop selections
Lucas Kent [Fri, 10 Sep 2021 07:50:40 +0000 (17:50 +1000)]
In Configurations.md demonstrate both cases for noop selections

2 years agorefactor: simplify local dep lookups
Caleb Cartwright [Tue, 21 Sep 2021 00:09:16 +0000 (19:09 -0500)]
refactor: simplify local dep lookups

2 years agotests: restructure and extend cargo-fmt tests
Caleb Cartwright [Mon, 20 Sep 2021 23:58:38 +0000 (18:58 -0500)]
tests: restructure and extend cargo-fmt tests

2 years agodeps: update cargo_metadata to include 'path'
Caleb Cartwright [Mon, 20 Sep 2021 03:15:50 +0000 (22:15 -0500)]
deps: update cargo_metadata to include 'path'

2 years agoMigrate to 2021
Mark Rousskov [Sun, 19 Sep 2021 16:49:55 +0000 (12:49 -0400)]
Migrate to 2021

2 years agoTrailing comma on match block goes missing when guard is on its own line
Ulyssa [Wed, 15 Sep 2021 15:58:23 +0000 (08:58 -0700)]
Trailing comma on match block goes missing when guard is on its own line

2 years agorefactor: use iter workaround for contains() gap
Caleb Cartwright [Fri, 17 Sep 2021 02:25:09 +0000 (21:25 -0500)]
refactor: use iter workaround for contains() gap

2 years agofeat: add --check flag to cargo fmt (#3890)
Caleb Cartwright [Sun, 27 Oct 2019 02:07:04 +0000 (21:07 -0500)]
feat: add --check flag to cargo fmt (#3890)