Commit Graph

528 Commits

Author SHA1 Message Date
Nick Cameron
96566276e3 Fix build
Fixes #2096
2017-10-30 07:39:28 +13:00
Nick Cameron
5233f9cde0 Add support for crate shorthand for pub(crate) 2017-10-28 18:41:58 +13:00
Nick Cameron
e2a5c78e4b
Merge pull request #2043 from sunjay/lift_generics
Lifted generics to account for changes in rust-lang/rust#44766
2017-10-28 18:14:13 +13:00
Nick Cameron
0a59654b41 Merge pull request #2084 from topecongiro/issue-2081
Use rewrite_assign_rhs when rewriting unit variant
2017-10-27 02:15:22 +05:30
Nick Cameron
038f711c6e Merge pull request #2083 from topecongiro/issue-2082
Use a correct span for fn with pub(crate) syntax
2017-10-27 02:14:29 +05:30
topecongiro
a67b8b0bbb Use rewrite_assign_rhs when rewriting unit variant 2017-10-25 01:08:32 +09:00
topecongiro
7b9a4e6a06 Use a correct span for fn with pub(crate) syntax 2017-10-25 00:51:04 +09:00
topecongiro
0d359eacd7 Cargo fmt 2017-10-18 22:23:25 +09:00
Sunjay Varma
3f11c4b93a Updated rustfmt to account for changes from rust-lang/rust#44766 2017-10-17 15:37:07 -04:00
Seiichi Uchida
530a845d2f Simplify multiline case in rewrite_struct_field() 2017-10-08 22:36:03 +09:00
Seiichi Uchida
55fc5b5ec2 Get rid of rewrite_struct_field_type() 2017-10-08 22:35:45 +09:00
Nick Cameron
802df67c2f Merge pull request #2035 from topecongiro/deprecate-try_opt!
Replace `try_opt!` macro with a `?` operator
2017-10-05 20:45:52 +08:00
Nick Cameron
99f14a87ae Merge pull request #2029 from wada314/fix-crlf
Fix broken tests under CRLF environment.
2017-10-05 20:07:29 +08:00
topecongiro
fe69dde96b Replace 'try_opt!' macro with a '?' operator 2017-10-05 20:50:19 +09:00
Nick Cameron
69ab2b5f5e Merge pull request #2023 from topecongiro/issue-2020
Use a correct budget for where predicate
2017-10-05 18:09:49 +08:00
Shohei Wada
25d2671c55 Fix broken tests under CRLF env. 2017-10-05 00:23:17 +09:00
Nick Cameron
c31c24de36 Merge pull request #2014 from topecongiro/fn-sig
Reduce number of arguments in rewrite_fn()
2017-10-04 20:18:02 +08:00
Nick Cameron
2aa2d4ebe3 Merge pull request #2011 from topecongiro/rewrite_call_inner
Change return type of rewrite_call_inner() to Option<String>
2017-10-04 20:14:10 +08:00
Seiichi Uchida
eebad40932 Use a correct budget for where predicate 2017-10-02 00:04:48 +09:00
Nick Cameron
6e41100725 Merge pull request #2005 from topecongiro/issue-2003
Put the opening brace of fn body on the next line if it exceeds max width
2017-09-29 21:27:37 +08:00
topecongiro
921e0c22ab Factor out FnSig::to_str() 2017-09-29 15:09:13 +09:00
topecongiro
62e38860b9 Handle 'extern "Rust"' in format_abi() 2017-09-29 15:08:48 +09:00
topecongiro
9537437e52 Use is_empty_block() 2017-09-29 12:51:06 +09:00
topecongiro
d8fc9ec05e Remove has_braces from argument 2017-09-29 12:50:35 +09:00
topecongiro
2e6825cc8c Use FnSig in rewrite_fn() and rewrite_fn_base() 2017-09-29 12:49:39 +09:00
topecongiro
7d448c2b26 Implement FnSig type 2017-09-29 12:45:42 +09:00
topecongiro
ee2b3b1529 Put the opening brace of fn body on the next line if it exceeds max width 2017-09-28 20:12:04 +09:00
topecongiro
436a083fce Change return type of rewrite_call_inner() to Option<String> 2017-09-28 16:33:30 +09:00
topecongiro
dd0dcdf1ac Fix a budget bug in Arg::rewrite() 2017-09-26 11:20:47 +09:00
topecongiro
b751030640 Remove unnecessary wrap_str() 2017-09-19 11:40:20 +09:00
Seiichi Uchida
32fa51a6a9 Move Spanned to spanned.rs from lib.rs 2017-09-19 10:04:35 +09:00
Seiichi Uchida
df7d2be562 Move Indent and Shape to shape.rs from lib.rs 2017-09-19 10:04:35 +09:00
Seiichi Uchida
18cd19673d Remove wrap_str() from recover_comment_removed()
since we will be using the original snippet no matter what.
2017-09-18 23:30:59 +09:00
Nick Cameron
cccb7f681e Merge pull request #1966 from topecongiro/string-to-cow
Refactoring: use Cow and etc.
2017-09-18 12:45:25 +12:00
topecongiro
0b5d524486 Remove unnecessary references 2017-09-15 17:09:30 +09:00
topecongiro
f51261e93e Cargo fmt 2017-09-15 12:10:58 +09:00
Seiichi Uchida
e6e696f7b0 Avoid cloning String 2017-09-05 01:04:08 +09:00
Nick Cameron
d08405eed6 Merge pull request #1931 from topecongiro/cargo-clippy
Apply refactoring from cargo clippy
2017-08-31 17:18:45 +12:00
Seiichi Uchida
4b79055a15 Apply refactoring from cargo clippy 2017-08-31 12:49:12 +09:00
topecongiro
4ad81d0bd9 Refactoring: use context.budget() 2017-08-31 12:44:40 +09:00
topecongiro
16894b9cd2 Put the closing brace of empty enum on the same line with the opening brace 2017-08-31 12:44:40 +09:00
Nick Cameron
39a91ba292 Fixup warnings and test formatting 2017-08-31 14:20:47 +12:00
Vadim Petrochenkov
6e5c6f5ba3 Use getters to access Span fields 2017-08-31 14:14:13 +12:00
topecongiro
979d131c5d Format and preserve attributes on ast::Stmt 2017-08-30 19:27:36 +09:00
topecongiro
e31a48b4d9 Refactoring: remove duplicates 2017-08-30 19:26:45 +09:00
Nick Cameron
7298ce9d52 Merge pull request #1925 from topecongiro/enhance-comment
Enhance comment formatting
2017-08-28 09:33:08 +12:00
topecongiro
1015dd8860 Use String::with_capacity() instead of String::new() 2017-08-28 00:24:10 +09:00
topecongiro
c4c55285da Recover comments between 'trait' and the opening brace 2017-08-28 00:17:19 +09:00
topecongiro
fa7c4d5030 Recover comments between 'impl' and the opening brace 2017-08-28 00:16:54 +09:00
topecongiro
6bbc6b54de Refactor - remove duplicates
replacing some functions with recover_missing_comments() and
rewrite_missing_comments().
2017-08-28 00:13:42 +09:00
topecongiro
ef84319e47 Fix a typo in calculating overhead for fn args 2017-08-27 14:57:21 +09:00
topecongiro
1f9e7c25c9 Implement Rewrite trait for ast::ForeignItem 2017-08-25 08:19:51 +09:00
Nick Cameron
7e171836c6 Merge pull request #1900 from spinda/attributes-on-same-line
Add attributes_on_same_line_as_{field,variant} configs
2017-08-21 11:26:36 +12:00
Nick Cameron
88cb142173 Merge pull request #1895 from topecongiro/configs-match_pattern_separator_break_point
Add mach_pattern_separator_break_point config option
2017-08-21 09:30:34 +12:00
Michael Smith
baafa4f011
Fix wrapping of bounds in associated types
Bounds were wrapped to the full width of the line rather then the width
available after the "type ...: ", resulting in rustfmt unnecessarily producing
lines that were longer than the maximum width.
2017-08-19 15:30:53 -07:00
Michael Smith
1c9d044c05
Add attributes_on_same_line_as_{field,variant} 2017-08-19 15:09:10 -07:00
Seiichi Uchida
63ac49638b Support match_pattern_separator_break_point config option 2017-08-18 23:19:47 +09:00
topecongiro
a4e0fe2b02 Allow attributes to stay on the same line with fields 2017-08-11 17:52:49 +09:00
topecongiro
0bb998685d Cover comments between function args and the brace 2017-08-10 23:11:18 +09:00
topecongiro
be38606c77 Add leave_last field to ListItems 2017-08-09 16:37:21 +09:00
Seiichi Uchida
a5a7cc7643 Insert newline between type alias with where clause 2017-08-02 23:27:33 +09:00
Seiichi Uchida
c0c27761b4 Simplify comments separator 2017-08-02 23:27:19 +09:00
Seiichi Uchida
d955497751 Factor out boolean flags for rewrite_where_clause() 2017-08-02 23:26:35 +09:00
Nick Cameron
9ae00a4498 Merge pull request #1847 from topecongiro/issue-1843
Implement single-line where
2017-08-02 14:28:48 +12:00
Seiichi Uchida
659d325982 Implement compressed where clause with Rfc style 2017-08-01 22:27:12 +09:00
Seiichi Uchida
ec6c2d6e99 Refactor compute_budgets_for_args() 2017-08-01 22:27:12 +09:00
Seiichi Uchida
c67f729205 Refactoring 2017-08-01 22:27:12 +09:00
topecongiro
e636fe732e Use Span from ast::WhereClause 2017-08-01 18:36:36 +09:00
Nick Cameron
c283d3e643 Merge pull request #1840 from topecongiro/match-with-max-width
Match with max width
2017-08-01 13:51:23 +12:00
Seiichi Uchida
e588f2fd7b Make definitive_tactic more generic via enum Separator 2017-07-31 16:23:42 +09:00
Seiichi Uchida
570a3505b9 Make definitive_tactic more generic with separator length 2017-07-29 22:13:23 +09:00
topecongiro
5aff5beb2a More fine-grained file-lines 2017-07-29 16:11:36 +09:00
Nick Cameron
74f5a515ef Merge pull request #1831 from topecongiro/trait-associated-type-with-default
Fix a typo in rewrite_associated_type
2017-07-29 12:31:36 +12:00
Nick Cameron
19bd5ea7b3 Merge pull request #1826 from topecongiro/issue-1824
Use correct BytePos for where when rewriting trait
2017-07-29 12:11:17 +12:00
topecongiro
462530cb7e Fix a typo in rewrite_associated_type 2017-07-28 06:27:34 +09:00
topecongiro
5a81c7d4b0 Use correct BytePos for where when rewriting trait 2017-07-27 14:21:14 +09:00
topecongiro
c3cc8fcb13 Format defaultness 2017-07-27 09:43:35 +09:00
Nick Cameron
1f991d00e0 Merge pull request #1822 from topecongiro/issue-1172
Remove newlines between list elements for expressions
2017-07-27 11:15:53 +12:00
Seiichi Uchida
261865ecc9 Remove newlines between list elements for expressions 2017-07-26 22:43:36 +09:00
topecongiro
e523f053a3 Format source codes and update tests 2017-07-26 16:30:58 +09:00
Nick Cameron
8b5831b501 Merge pull request #1818 from topecongiro/issue-1194
Put braces on the next line if it exceeds max width
2017-07-26 11:40:41 +12:00
topecongiro
65ad7d3bb0 Put braces on the next line if it exceeds max width 2017-07-25 18:51:14 +09:00
topecongiro
a17993c14a Force vertical layout when struct_variant_width is 0 2017-07-25 15:19:09 +09:00
Seiichi Uchida
8b970fcc9f Format inner attributes wherever possible 2017-07-25 00:55:55 +09:00
topecongiro
68c6fe70fd Format source codes and update tests 2017-07-21 17:57:31 +09:00
topecongiro
db5f77b7d0 Consider max_width when rewriting struct in single-line 2017-07-21 07:17:49 +09:00
Seiichi Uchida
a8b0a6e4c5 Format source codes and update tests 2017-07-20 00:42:00 +09:00
Seiichi Uchida
de403f4f65 Use offset_left instead of shrink_left 2017-07-20 00:41:36 +09:00
topecongiro
dcb953b901 Add trailing comma when using Mixed indent style with newline 2017-07-13 20:32:46 +09:00
topecongiro
6fd291981e Sort imports in alphabetical and consistent order 2017-07-13 18:42:14 +09:00
topecongiro
2fb66cd1d3 Add trailing_semicolon config option
trailing_semicolon controls whether to add a trailing semicolon after break,
continue and return.
2017-07-12 14:16:06 +09:00
topecongiro
e3310a6a18 Format source codes 2017-07-11 21:53:10 +09:00
Seiichi Uchida
bc90a12b8d Format union 2017-07-10 17:26:55 +09:00
topecongiro
65790f2b2a Cover missing comments before and after where 2017-07-10 14:38:16 +09:00
Seiichi Uchida
bc63d69c3f Format source codes 2017-07-10 02:24:59 +09:00
topecongiro
2dd8d6d097 Add Clone trait bound to write_list 2017-07-07 09:04:06 +09:00
Nick Cameron
cfec7ad593 Merge pull request #1745 from topecongiro/assignment
Put rhs of assignment on the next line if it fits in a single line
2017-07-07 11:54:06 +12:00
topecongiro
cb48435ff3 Format source codes 2017-07-05 18:31:37 +09:00
topecongiro
101df143cf Refactor rewrite_static 2017-07-05 18:25:50 +09:00
topecongiro
6a7f866cfe Format source codes 2017-07-05 18:12:43 +09:00
topecongiro
f8586bac2a Handle comment at the last element in write_list 2017-07-05 18:01:34 +09:00
topecongiro
be5c40cbb9 Handle very long struct 2017-07-05 18:00:36 +09:00
topecongiro
332cc97986 Use block indent style for struct tuple 2017-07-05 18:00:36 +09:00
topecongiro
34b4a9d3c4 Add struct_field_align_threshold for vertical alignment 2017-07-03 18:54:41 +09:00
topecongiro
fb1225a8af Use format_expr wherever single-lined block is not allowed 2017-06-20 22:35:16 +09:00
topecongiro
512c8c1edf Apply config.trailing_comma wherever possible 2017-06-19 16:00:04 +09:00
topecongiro
91bd1fdc86 Format source codes 2017-06-18 14:29:17 +09:00
Nick Cameron
be18e7af90 Merge pull request #1717 from topecongiro/type-and-generics
Refactor format against types and generics
2017-06-18 15:57:34 +12:00
Seiichi Uchida
38c30a3e06 Refactor format against types and generics
Previous implementation relied on the fact that rustfmt used visual indent
style as a default. However, since now rustfmt uses block indent style against
most part of the code, we need some refactorings.
2017-06-18 02:00:58 +09:00
topecongiro
54233acc8e Format source codes 2017-06-17 16:56:54 +09:00
topecongiro
e31f5eceac Use correct span for Infer type inside closure header 2017-06-17 15:35:29 +09:00
topecongiro
b048fe6b35 Format source codes 2017-06-17 15:26:59 +09:00
topecongiro
208ff15954 Format source codes 2017-06-16 08:49:49 +09:00
topecongiro
8a6e9f689b Format source codes 2017-06-15 16:26:41 +09:00
topecongiro
b8f11a4e3c Format source codes 2017-06-14 20:39:07 +09:00
topecongiro
c06d487712 Add offset wherever necessary 2017-06-14 20:37:54 +09:00
topecongiro
c4d84b44ba Avoid overflow 2017-06-14 00:06:48 +09:00
Nick Cameron
18ccd0190e Rebasing 2017-06-13 14:49:47 +12:00
Nick Cameron
6f30d9e7c9 Reformat tests 2017-06-13 14:42:54 +12:00
Nick Cameron
1f512948a0 Reformat source code using new defaults 2017-06-13 14:41:49 +12:00
topecongiro
f084a8af96 Fix excessive indentation in trait where clause when using Rfc style 2017-06-13 10:18:55 +09:00
Nick Cameron
5d78d1fe00 Merge pull request #1655 from topecongiro/issue-1652
Use correct indent for return type when it goes multi line
2017-06-13 11:57:30 +12:00
Nick Cameron
c07925f498 Merge pull request #1647 from topecongiro/refactor-impl-format
Refactor impl format
2017-06-13 11:55:33 +12:00
topecongiro
d269189f19 Use correct indent for return type when it goes multi line 2017-06-12 16:23:10 +09:00
topecongiro
62e9473d07 Update rewrite_trait_ref to return Option<String> 2017-06-12 08:53:19 +09:00
topecongiro
f135641cc8 Use multi line when type bounds does not fit in a single line 2017-06-11 23:26:49 +09:00
topecongiro
9b195ae228 Refactor format_impl 2017-06-11 14:32:44 +09:00
topecongiro
bd80077be8 Add format_trait_ref_then_update_result 2017-06-10 21:07:38 +09:00
topecongiro
88e522f921 Use multiline in generics rather than fail 2017-06-10 19:45:23 +09:00
topecongiro
9eefc6fc8d Share codes when rewriting generics 2017-06-10 18:31:01 +09:00
topecongiro
c92064c30a Force brace on new line if the signature ends with comment 2017-06-09 16:15:31 +09:00
est31
727963afe4 Update syntex_syntax
Bases on commit to switch to libsyntax by @nrc
2017-06-06 07:31:47 +02:00
Nick Cameron
6a9d7dab0d Merge pull request #1637 from est31/master
Add config options for spaces around the colon in struct literal fields
2017-06-06 16:20:16 +12:00
Nick Cameron
130aa70e3a Merge pull request #1621 from topecongiro/combining
Combine more expressions
2017-06-06 14:52:48 +12:00
est31
aa4cd311bb Add config options for spaces around the colon in struct literal fields
In Rust, colons are used for three purposes:

* Type annotations, including type ascription
* Trait bounds
* Struct literal fields

This commit adds options for the last missing of the three purposes,
struct literal fields.
2017-06-06 03:50:58 +02:00
Nick Cameron
d04ab9e5ba Merge pull request #1630 from topecongiro/issue-1115
Allow comments after attributes on enum fields
2017-06-05 11:41:52 +12:00
topecongiro
d7de5b7656 Allow comments after attributes on enum fields 2017-06-04 23:27:21 +09:00
topecongiro
dcc7f32152 Format source codes 2017-06-04 19:37:24 +09:00
topecongiro
a9f529cba4 Format source codes 2017-06-04 19:35:29 +09:00
topecongiro
d54634bd7c Use recover_comment_removed in rewrite_static 2017-06-04 18:44:08 +09:00
Nick Cameron
6f1cb950d6 Merge pull request #1628 from topecongiro/issue-1113
Preserve the layout of comment after return type
2017-06-04 11:40:37 +12:00
Nick Cameron
3090086000 Merge pull request #1627 from topecongiro/issue-1624
Refactor vertical layout of function definition with options
2017-06-04 11:34:25 +12:00
topecongiro
15e936bfc7 Preserve the layout of comment after return type 2017-06-04 06:59:55 +09:00
Seiichi Uchida
dd13761f85 Organize vertical layout of function definition 2017-06-03 23:18:39 +09:00
Seiichi Uchida
9b7ba980cf Use correct budget 2017-06-03 23:17:30 +09:00
Seiichi Uchida
d21792a730 Put opening paren next to multi line generic 2017-06-03 23:16:29 +09:00
Seiichi Uchida
08b5375776 Forbid trailing comma at the end of args of variadic functions 2017-06-03 15:03:08 +09:00
Seiichi Uchida
4402412b78 Allow attributes in generics of impl 2017-05-27 23:59:29 +09:00
Nick Cameron
8ac3fc36cc Merge pull request #1597 from topecongiro/comments-after-attributes
Allow comments after attributes of struct fields
2017-05-27 13:47:42 +12:00
Nick Cameron
aad250e20e Merge pull request #1596 from topecongiro/issue-1595
Add a trailing comma if the last arg ends with comment
2017-05-27 13:38:14 +12:00