Commit Graph

3070 Commits

Author SHA1 Message Date
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
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
89f38304a7 fix: don't drop leading comments in extern 2020-11-16 15:48:20 -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
Caleb Cartwright
a613c57521 feat: don't insert semi in macro_rules arm body 2020-11-11 18:26:13 -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
15854e5fd3 feat: v2 support for nested tuples w/o spaces 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
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
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
Ayaz Hafiz
92ab76cfa7 fixup! Preserve and format type aliases in extern blocks 2020-10-01 19:12:22 -05:00
Ayaz Hafiz
a9b0b057eb fixup! Preserve and format type aliases in extern blocks 2020-10-01 19:12:22 -05:00
Ayaz Hafiz
a15800a327 Preserve and format type aliases in extern blocks
Previously, non-trivial type aliases in extern blocks were dropped by
rustfmt because only the type alias name would be passed to a rewritter.
This commit fixes that by passing all type information (generics,
bounds, and assignments) to a type alias rewritter, and consolidates
`rewrite_type_alias` and `rewrite_associated_type` as one function.
2020-10-01 19:12:22 -05:00
Caleb Cartwright
d6a220b70a feat: support config. of leading match arm pipe 2020-09-24 09:43:31 -05:00
David Tolnay
8635a5ca44 deps: bump rustc-ap to v679 2020-09-23 00:45:18 -05:00
Caleb Cartwright
9ba373f822 deps: bump rustc-ap to v678 2020-09-23 00:45:18 -05:00
Caleb Cartwright
62dc7c5c6b fix: inner attribute formatting 2020-09-04 19:01:18 -05:00
mahkoh
89b7f5f382 Fix module resolution in inner modules with paths (#4194) 2020-09-04 19:01:18 -05:00
Caleb Cartwright
aa11c27490 chore: run rustfmt 2020-09-04 19:01:18 -05:00
Caleb Cartwright
637ddfb6da deps: bump rustc-ap to v673 2020-09-04 19:01:18 -05:00
Caleb Cartwright
e4617e0e61 deps: bump rustc-ap to v672 2020-09-04 19:01:18 -05:00
Caleb Cartwright
a17803127f fix: inverted span on attrs within closure 2020-08-09 14:32:34 -05:00
Caleb Cartwright
bf359c6ebc chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf 2020-07-15 09:19:21 -05:00
Caleb Cartwright
391cd3e324 deps: bump rustc-ap to v669 2020-07-14 21:36:24 -05:00
Caleb Cartwright
b243075d75 deps: bump rustc-ap-* to v668 2020-07-09 23:15:08 -05:00
Caleb Cartwright
da18032ba4 deps: bump rustc-ap* to v666 2020-06-27 13:15:54 -05:00
Seiichi Uchida
a36e7c7981 Use correct span for match arms with the leading pipe and attributes (#3975) 2020-06-27 12:55:15 -05:00
Caleb Cartwright
796d6eafa4 fix: backport fix for #4079 2020-06-11 23:29:51 -05:00
Caleb Cartwright
5db7152962 fix: backport fix for #4020 2020-06-11 23:17:38 -05:00
Caleb Cartwright
ce1a3efff0 fix: backport fix for submod parser errors 2020-06-11 21:49:40 -05:00
Caleb Cartwright
dead3a807d fix: backport mod resolution error handling 2020-06-11 21:11:18 -05:00
David Tolnay
bc9a0b2974 Switch to std::error::Error for errors (#3948) 2020-06-11 20:23:24 -05:00
Caleb Cartwright
b28fd5f91c deps: apply upstream rustc-* changes 2020-06-11 13:22:37 -05:00
topecongiro
08776ef3b4
Support module-level rustfmt::skip in sub-modules 2020-06-08 10:42:43 +09:00
Seiichi Uchida
577ef8136f
Update rustc-ap-* crates to 659.0.0 for rustfmt-1.4.15 (#4184) 2020-05-19 17:31:28 +09:00
Caleb Cartwright
c1267303bc
fix: formatting arbitrary extern abi (#4089) 2020-03-31 15:30:26 +09:00
Caleb Cartwright
00e199c974
backport new syntax to rustfmt 1.x (#4105)
* feat: support raw reference operator

* feat: support const opt-out syntax

* feat: support half open range syntax
2020-03-31 15:28:01 +09:00
Caleb Cartwright
9714a140c9 refactor: use ast::attr:HasAttrs 2020-03-30 13:11:00 -05:00
Caleb Cartwright
ac2d5b85a5 deps: bump rustc-ap* to v651 2020-03-30 12:02:39 -05:00
Caleb Cartwright
b173b42354 refactor: rename libsyntax --> rustc_ast 2020-03-27 22:29:12 -05:00
Caleb Cartwright
c1a66e1e22 fix: unreachable err on Fn with None block 2020-03-27 22:13:46 -05:00
Caleb Cartwright
537d746e08 fix: use correct ForeignItem span 2020-03-27 22:00:00 -05:00
Caleb Cartwright
bea7209d0a chore: fix src formatting 2020-03-27 21:53:40 -05:00
Caleb Cartwright
9b0ed57af6 refactor: parse & mod resolver for rustc-ap v650 2020-03-27 21:33:34 -05:00
Caleb Cartwright
bd5dff4012 refactor: backport syntux mod 2020-03-26 21:25:34 -05:00
Caleb Cartwright
9699c96cf1 deps: bump to rustc v647 2020-03-26 17:20:24 -05:00
Caleb Cartwright
7a76ec062d deps: bump to rustc v644 2020-03-26 15:26:58 -05:00
Caleb Cartwright
760bb29feb chore: fix compile warnings 2020-02-08 22:54:37 -06:00
Caleb Cartwright
e72f307f15 fix: backport parse bug fix
Backport the fix for the parser bug where the messages from
fatal/non-recoverable parser errors were being silently eaten by
rustfmt.
2020-02-08 22:47:48 -06:00
Caleb Cartwright
c60416ed21 deps: update rustc-ap to v642.0.0 2020-02-08 22:21:37 -06:00
Seiichi Uchida
731f15551b
Do not add block around async closure (#3946) 2019-12-03 08:47:25 +09:00
Chris Emerson
99f9f576d4 Return an error if --check or --emit json are used with stdin. (#3875) 2019-10-25 15:05:24 +09:00
Seiichi Uchida
69cf48344b
fix handling of nested comments in patterns and ControlFlows (#3869) 2019-10-25 15:04:33 +09:00
rChaser53
233497aceb fix Unparsable code when formmating (#3883) 2019-10-24 22:16:56 +09:00
Rui
69c7dbcd50 Try to solve issue3456. (#3556) 2019-10-19 18:19:47 +09:00
Caleb Cartwright
3a073f177c fix: handling of newline_style conflicts (#3850) 2019-10-19 17:15:13 +09:00
Stéphane Campinas
5327c3633f handle field attributes when aligning a struct's fields (#3513) 2019-10-19 16:56:32 +09:00
Caleb Cartwright
a5d16df9a4 feat: use offline by default with cargo fmt (#3830) 2019-10-19 16:35:33 +09:00
Caleb Cartwright
fd6e960648 fix: comments between lhs and rhs 2019-10-17 20:13:11 -05:00
Caleb Cartwright
28be77915f fix: nested comments in control flow condition pat 2019-10-17 19:58:08 -05:00
Stéphane Campinas
a15e97f1e9 do not indent impl generics (#3856) 2019-10-11 18:19:44 +09:00
Caleb Cartwright
8210cc1c13 fix: handle lhs unary in range expression (#3855) 2019-10-11 18:15:04 +09:00
rChaser53
396a2af181 fix to swallow attribute on brace expression (#3848) 2019-10-10 10:35:34 +09:00
Caleb Cartwright
207a58f365 fix panic on closure with empty block expr (#3846) 2019-10-08 11:00:31 +09:00
Caleb Cartwright
6dcbc5d78e fix: handle block comments with trailing line comments (#3842) 2019-10-08 10:12:21 +09:00
Stéphane Campinas
8073244420 improve detection of URL inside a string that is being rewritten. (#3809) 2019-10-07 16:43:50 +09:00
Stéphane Campinas
160c3aafc5 handle hard tabs when formatting trailing comments (#3836) 2019-10-07 16:40:27 +09:00
Caleb Cartwright
ba4bf03d84 don't fail on recoverable parser errors in ignored files (#3782) 2019-10-07 10:24:08 +09:00
Caleb Cartwright
ed697c9347 fix: support raw prefix identifiers in statics 2019-10-05 12:34:48 -05:00
Seiichi Uchida
383306e5fe
Update rustc-ap-* crates to 606.0.0 (#3835) 2019-10-05 23:40:24 +09:00
Stéphane Campinas
fb01dc857c do not force comments to be indented with a comment trailing a line of code (#3833) 2019-10-05 00:22:01 +09:00
rChaser53
7926851bb0 stop to strip 'impl' from impl trait type alias (#3816) 2019-10-04 11:25:16 +09:00
Matthew Pomes
e28ae8b4a3 Init Logger for unit tests (#3829)
Add `init_log()` function which attempts to init logger, and
ignores failure. The function is called at the beginning of
every test, and will fail if the logger is already initialized.
The logger must be initialized in every test, becuase cargo runs
the tests in parallel, with no garentees about the order and time
each starts.
2019-10-04 11:24:33 +09:00
Stéphane Campinas
dbd8936391 fix rust code in comment with a line containing only a hash sign (#3818) 2019-10-02 23:58:25 +09:00
Caleb Cartwright
f4bc494153 add --offline mode fallback to cargo fmt (#3813) 2019-10-02 23:56:20 +09:00
Caleb Cartwright
7c9c0d1a39 fix: merge_imports handling of ::{self} 2019-09-26 20:02:41 -05:00
Caleb Cartwright
9c2b375ba9 refactor to use param naming where appropriate (#3803) 2019-09-24 09:25:19 +09:00
Caleb Cartwright
3bb266180e fix: handling of empty str for license template path (#3804) 2019-09-24 09:24:05 +09:00
Caleb Cartwright
6b0a447150 feat: support parameter attributes (#3793) 2019-09-20 16:11:52 +09:00
rChaser53
4449250539 fix the error with long string in raw string (#3800) 2019-09-18 22:39:27 +09:00
Shotaro Yamada
ca78653d61 Use Cell instead of RefCell (#3798) 2019-09-18 22:37:08 +09:00
rChaser53
789a097a71 fix internal error when using rustfmt::skip with newline on stmt (#3785) 2019-09-15 23:45:46 +09:00
Caleb Cartwright
dfe87fe946 fix: async expression indentation (#3789) 2019-09-11 09:55:18 +09:00
Seiichi Uchida
ceca01465a
Update deps (#3788) 2019-09-08 23:33:21 +09:00