Commit graph

4929 commits

Author SHA1 Message Date
Caleb Cartwright
70ce18255f meta: bump to v1.4.29 2020-12-04 22:27:48 -06:00
David Tolnay
c40a8c1ecc Add negative impl test 2020-11-30 23:24:36 -06:00
David Tolnay
96ee060529 Preserve polarity on negative non-trait impl 2020-11-30 23:24:36 -06:00
Caleb Cartwright
29f33eb7d6 meta: bump to v1.4.28 2020-11-29 13:26:58 -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
Caleb Cartwright
823c4f820a fix: backport some imports for cherry-picked commit 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
Caleb Cartwright
ea712f1a2c fix: apply rustc-ap updates to backported commit 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
Adam H. Leventhal
3df383aa3c fixes #4115, #4029, #3898 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
Ayaz Hafiz
5ffccbb627 Properly format function signature in extern blocks
Closes #4288

And we get to drop a method, which I think is a win :)
2020-11-28 21:59:30 -06:00
topecongiro
8e46225547 Add a test 2020-11-28 21:59:30 -06:00
Caleb Cartwright
48d30a4f71 chore: run rustfmt against source 2020-11-28 17:41:21 -06:00
Caleb Cartwright
4d9fa00fd5 feat: support underscore expressions 2020-11-28 17:41:21 -06:00
Caleb Cartwright
5c0673c371 refactor: update cfg_if attr parsing 2020-11-28 17:41:21 -06:00
Caleb Cartwright
4f32ce8434 feat: support struct/slice destructuring 2020-11-28 17:41:21 -06:00
Caleb Cartwright
5b216029b5 deps: minor rustc_ast changes for v691 2020-11-28 17:41:21 -06:00
Caleb Cartwright
baee271013 deps: bump rustc-ap crates to v691 2020-11-28 17:41:21 -06:00
Caleb Cartwright
581da523db deps: bump rustc-ap to v687 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
580d826e9b meta: bump to v1.4.27 2020-11-16 15:48:20 -06:00
Caleb Cartwright
d003e3b97b ci: update GHA workflows 2020-11-16 15:48:20 -06:00
Caleb Cartwright
89f38304a7 fix: don't drop leading comments in extern 2020-11-16 15:48:20 -06:00
Caleb Cartwright
293d7d0111 meta: bump version to v1.4.26 2020-11-14 11:50:28 -06:00
Caleb Cartwright
77c8c9093b ci: restrict GHA workflow triggers on push 2020-11-14 11:50:28 -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
ce13ff15c3 Correctly create artificial span for formatting closure body
This commit partially reverts #3934, opting to create a span that covers
the entire body of a closure when formatting a closure body with a
block-formatting strategy, rather than having the block-formatting code
determine if the visitor pointer should be rewound. The problem with
rewinding the visitor pointer is it may be incorrect for other (i.e.
non-artificial) AST nodes, as in the case of #4382.

Closes #4382
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
0f29ff6da0 meta: release v1.4.25 2020-11-11 18:26:13 -06:00
Caleb Cartwright
a613c57521 feat: don't insert semi in macro_rules arm body 2020-11-11 18:26:13 -06:00
Caleb Cartwright
eb894d5370 meta: release v1.4.24 2020-11-05 20:45:11 -06:00
Caleb Cartwright
ae6b40e2f9 fix: remove ignored depr attribute which now errors 2020-11-05 20:45:11 -06:00
Caleb Cartwright
1139e6e5cc fix: remove comment from cherry-pick that v1.x doesn't handle 2020-11-05 20:45:11 -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
ea97ec5a4e meta: bump rustfmt version to 1.4.23 2020-11-02 19:19:21 -06:00
Caleb Cartwright
fb517f45c6 ci: fix asset upload workflow 2020-11-02 18:31:51 -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
98975e1a64 tests: adjust some cherry-picekd tests 2020-11-02 18:31:51 -06:00
Caleb Cartwright
2b6226ce49 fix: resolve some parser related bugs 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