Commit graph

1748 commits

Author SHA1 Message Date
Caleb Cartwright
2a3635d5d1 tests: remove snippets with inner attrs on non-block expressions 2021-05-04 18:38:22 -05:00
ChinYing-Li
84ff0013c2 Add the case in duplicate issue (#4806) to the idempotent tests 2021-04-21 21:30:42 -05:00
ChinYing-Li
dac2423f3f Recognize when a block comment has been ended inside a string literal (#4312) 2021-04-21 21:30:42 -05:00
Joseph Birr-Pixton
58157bb4b7 Add some basic tests for chain_width use 2021-04-21 21:27:50 -05:00
Caleb Cartwright
a168d92f9a tests: augment heuristics tests 2021-04-21 21:27:50 -05:00
Caleb Cartwright
1bcc1f8df5 refactor: apply heuristic config changes in lib 2021-04-21 21:27:50 -05:00
David Bar-On
432e09e89f Add the use of rewrite_assign_rhs_with_comments to 1.x 2021-02-17 20:47:20 -06:00
David Bar-On
4b0ed96f2e Fix for issue 4603 about extra macro body indentation (third version) 2021-02-17 20:19:27 -06:00
Caleb Cartwright
d80a42fdd8 tests: add case for issue 4675 2021-01-28 22:01:50 -06:00
Caleb Cartwright
c13d2452c0 chore: backport some empty block check fixes 2021-01-27 20:58:42 -06:00
vallentin
1e2b0b7c72 Added 4646 test case 2021-01-27 20:58:42 -06:00
Michael Morgan
384ba68d64 Add imports_granularity="Item".
This option splits all imports into their own `use` statement.
2021-01-27 20:58:42 -06:00
Sean Klein
5e14f760c5 fix: Avoid incorrect global 'cfg_if' Symbol interning
Fixes #4656
2021-01-27 19:26:58 -06:00
Ayaz Hafiz
f8deed3a3a Include const generic type bounds in their spans
Closes #4310
2021-01-27 18:50:03 -06:00
topecongiro
152ccb5059 Do not duplicate const keyword on parameters 2021-01-27 18:50:03 -06:00
Seiichi Uchida
c0fede355c Use the span after generics and where clause (#4208) 2021-01-27 18:50:03 -06:00
hafiz
269584634a Include constness in impl blocks (#4215)
Closes #4084
2021-01-27 18:50:03 -06:00
Geoffry Song
71863753bd Rename merge_imports to imports_granularity and add a Module option.
This renames the existing `true`/`false` options to `Crate`/`Never`, then adds a
new `Module` option which causes imports to be grouped together by their
originating module.
2021-01-17 11:48:47 -06:00
Caleb Cartwright
b30cb24286 fix: indentation issue on generic bounds 2021-01-16 11:17:23 -06:00
Caleb Cartwright
3571c5d6f7 fix: maintain redundant semis on items in statement pos 2021-01-09 12:11:52 -06:00
Mara Bos
f0eaaeda9e Add 2021 test. 2021-01-09 12:11:52 -06:00
Mara Bos
b623eb324c Fix expected macro formatting test output. 2021-01-09 12:11:52 -06:00
Seiichi Uchida
0d022d08d8 Format error and typeof types (#4416)
* Add a test for #4357

* Format error and typeof types
2020-12-20 12:05:05 -06:00
Stéphane Campinas
c536d80dc1 Fix rewrite of closures with a return type
If the closure's body fits in a line, the block is removed but it is
necessary if the closure has a return type.
2020-12-20 12:05:05 -06:00
Caleb Cartwright
4cfb9ef8f4 fix: don't strip nonexistent comma in derive 2020-12-20 12:05:05 -06:00
David Tolnay
c40a8c1ecc Add negative impl test 2020-11-30 23:24:36 -06:00
WhizSid
7d9ee7558e Comment between typebounds (#4474)
* Test cases and get spans

* Fixed type bounds

* Fixed issue of test cases

* Fixed first test case issue

* Removed unwanted whitespaces

* Removed tmp files
2020-11-29 13:26:58 -06:00
WhizSid
b7c38c9d50 Fixed comment dropped between & and type issue (#4482)
* Fixed comment dropped between & and type issue

* Reduced nesting levels and avoided duplications

* Removed extra allocations
2020-11-29 13:26:58 -06:00
WhizSid
6455e9de0e Fixed 'Comment removed between type name and =' issue (#4448)
* Fixed Comment removed between type name and = issue

* Fixed where clause issue and pass the full span

* has_where condition inline

* Fixed indentation error on where clause

* Removed tmp file
2020-11-29 13:26:58 -06:00
hafiz
5e7fb45533 Pick up comments between visibility modifier and item name (#4239)
* Pick up comments between visibility modifier and item name

I don't think this hurts to fix. #2781, which surfaced this issue, has
a number of comments relating to similar but slightly different issues
(i.e. dropped comments in other places). I can mark #2781 as closed and
then will open new issues for the comments that are not already resolved
or tracked.

Closes #2781

* fixup! Pick up comments between visibility modifier and item name

* fixup! Pick up comments between visibility modifier and item name
2020-11-29 13:26:58 -06:00
Caleb Cartwright
fb7e604538 tests: backport an additional test case 2020-11-29 13:26:58 -06:00
Adam H. Leventhal
c7359945a4 tests 2020-11-29 13:26:58 -06:00
hafiz
c77c6a405d Compare code block line indentation with config whitespace (#4166)
Previously the indetation of a line was compared with the configured
number of spaces per tab, which could cause lines that were formatted
with hard tabs not to be recognized as indented ("\t".len() < "    ".len()).

Closes #4152
2020-11-29 13:26:58 -06:00
David Tolnay
e7ecdc1664 Remove async fn from extern block tests 2020-11-28 21:59:30 -06:00
Ayaz Hafiz
3bf67c175d Don't drop blocks on foreign functions
A code like

```rust
extern "C" {
    fn f() {
        fn g() {}
    }
}
```

is incorrect and does not compile. Today rustfmt formats this in a way
that is correct:

```rust
extern "C" {
    fn f();
}
```

But this loses information, and doesn't have to be done because we know
the content of the block if it is present. During development I don't
think rustfmt should drop the block in this context.

Closes #4313
2020-11-28 21:59:30 -06:00
topecongiro
8e46225547 Add a test 2020-11-28 21:59:30 -06:00
Caleb Cartwright
4d9fa00fd5 feat: support underscore expressions 2020-11-28 17:41:21 -06:00
Caleb Cartwright
4f32ce8434 feat: support struct/slice destructuring 2020-11-28 17:41:21 -06:00
meiomorphism
003786228d fix: don't force a newline after an empty where clause
Fixes #4547.
2020-11-25 21:32:46 -06:00
Matt
073cc3891f Option to create groups for std, external crates, and other imports
Backport of 17d90ca.
2020-11-18 21:37:42 -06:00
Caleb Cartwright
89f38304a7 fix: don't drop leading comments in extern 2020-11-16 15:48:20 -06:00
Caleb Cartwright
eed826f8a7 tests: attributed comment-only blocks 2020-11-14 11:50:28 -06:00
WhizSid
faf97a67d6 Fixed 'Incorrect comment indent inside if/else' issue. (#4459)
* Added test cases

* Fixed if condition comment issue

* Fixed extern C issue

* Removed previous test case

* Removed tmp file

* honor the authors intent

* Changed the file name to its original name

* Removed extra whitespace
2020-11-14 11:50:28 -06:00
Ayaz Hafiz
dd32de74ce fixup! Correctly create artificial span for formatting closure body 2020-11-14 11:50:28 -06:00
Caleb Cartwright
a613c57521 feat: don't insert semi in macro_rules arm body 2020-11-11 18:26:13 -06:00
Aaron Hill
46ab14437e Don't flatten a block containing a single macro call
We no longer flatten a block that looks like this:

```rust
match val {
    pat => { macro_call!() }
}
```

Currently, rust ignores trailing semicolons in macro expansion in
expression position (see https://github.com/rust-lang/rust/issues/33953)

If this is changed, flattening a block with a macro call may break the
user's code - the trailing semicolon will no longer parse if the macro
call occurs immediately on the right-hand side of the match arm
(e.g. `pat => macro_call!()`)
2020-11-05 20:45:11 -06:00
Caleb Cartwright
15854e5fd3 feat: v2 support for nested tuples w/o spaces 2020-11-02 18:31:51 -06:00
Scott McMurray
278e8da33b Add some basic tests for try{} expressions
They failed to parse in rustfmt on me in https://github.com/rust-lang/rust/pull/77877, which looks like it's since been fixed, but I figured I'd send in some tests anyway.
2020-11-02 18:31:51 -06:00
Caleb Cartwright
86a41bc80b tests: add test for panic on new_parser_from_file 2020-11-02 18:31:51 -06:00
Caleb Cartwright
9faba4539b fix(parser): better unclosed delims handling 2020-11-02 18:31:51 -06:00