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
Caleb Cartwright
e131797b62
deps: bump rustc-ap to v686
2020-11-02 18:31:51 -06:00
Michael Müller
fa9d97499e
Fix overriding license header bug ( #4488 )
...
* Override header to None when path len = 0
* Add regression test
* Ensure nightly
2020-10-24 11:14:52 -05:00
hafiz
6a7824787e
Preserve comments in empty statements ( #4180 )
...
* Preserve comments in empty statements
Closes #4018
* fixup! Preserve comments in empty statements
2020-10-24 11:13:00 -05:00
Ayaz Hafiz
e70343a5f5
Correctly indent skipped-over code
...
Closes #4398
2020-10-24 11:13:00 -05:00
Caleb Cartwright
2866634baf
deps: bump rustc-ap to v684
2020-10-24 11:13:00 -05:00
Caleb Cartwright
31cef56779
feat: add initial support for ConstBlock expressions
2020-10-24 11:13:00 -05:00
Caleb Cartwright
c89638ae55
deps: update macro parsing
2020-10-24 11:13:00 -05:00
Caleb Cartwright
d95a2875f7
deps: bump rustc-ap to v683
2020-10-24 11:13:00 -05:00
Caleb Cartwright
97d0301011
Release v1.4.22
2020-10-04 16:58:34 -05:00
Caleb Cartwright
bdb1c44986
refactor: move env/osstr imports to avoid warnings
2020-10-04 16:58:34 -05:00
David Tolnay
14d53f75c9
Use rustfmt given by RUSTFMT env var ( #4419 )
2020-10-04 16:58:34 -05:00
Ayaz Hafiz
2a8ff209f6
fixup! Preserve and format type aliases in extern blocks
2020-10-01 19:12:22 -05:00