Kamal Marhubi
14dbac5fd7
config: Use write_mode from config
...
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
2016-02-08 22:52:44 -05:00
Jeremy Wazny
7297bc320f
Limit when we emit a trailing where clause comma.
2016-01-26 16:39:00 +11:00
Jeremy Wazny
d82d3b2cd1
Added where_trailing_comma option.
...
The default is 'false', since a lot of the time there's only a single
predicate.
2016-01-26 12:42:11 +11:00
Nick Cameron
f0ca7aec24
Fix an off-by-one error due to the comma in a struct lit field
...
Also allows splitting the field expression on a new line after the field name.
Fixes #698
2016-01-14 20:26:15 +13:00
Marcus Klaas de Vries
b99e8eda29
Merge pull request #757 from ConnorGBrewster/fix-#650
...
Fix for #650
2016-01-12 21:17:45 +01:00
Connor Brewster
d7a3256d40
If where is on the same line as the impl, { is put on the same line fixes #650
...
factored if clause into a separate function
2016-01-11 21:26:45 -07:00
Connor Brewster
749697d845
Changed is_block_empty to has_body
2016-01-11 14:47:56 -07:00
Connor Brewster
6b741a7194
Where clause is on same line as fn if fn is empty fix-#760
...
only applies if fn_empty_single_line is set to true
2016-01-10 22:06:06 -07:00
Manish Goregaokar
ffe9c9d834
Clippy rustfmt
2016-01-07 12:17:22 +05:30
Marcus Klaas
291aa1b228
Make fn argument formatting more resilient for complex self types
2015-12-27 14:25:37 +01:00
Marcus Klaas
2069abcca4
Reduce dependency on pprust
2015-12-25 20:59:46 +01:00
Marcus Klaas
954dd0869e
Preserve mutability for typed self arguments
2015-12-25 19:07:51 +01:00
Marcus Klaas
2636fed5f3
Don't panic on function return type rewrite failure
2015-12-12 15:41:10 +01:00
Nick Cameron
585b071aa1
Merge pull request #678 from marcusklaas/length-one-tuplez
...
Fixed named arguments in bare function types
2015-12-07 09:01:38 +13:00
Nick Cameron
f569144bbf
Merge pull request #666 from marcusklaas/matches-5000
...
Break function headers earlier
2015-12-07 08:07:23 +13:00
Marcus Klaas
97e4e7e5ba
Fixed named arguments in bare function types
2015-12-06 01:11:26 +01:00
Markus Westerlind
a6b0d475f4
Don't remove where clauses in type aliases
2015-12-02 20:11:17 +01:00
Markus Westerlind
ae9ad7b288
Fix formatting of type aliases where '=' is at or close to the max width
2015-12-02 20:11:10 +01:00
Marcus Klaas
76f303f369
Break function headers earlier
...
Closes rustfmt#295.
2015-12-01 22:09:37 +01:00
Markus Westerlind
17fd2d073b
Add a BraceStyle parameter to rewrite_where_clause
...
This allow it to exactly calculate if it needs to break the where clause into multiple lines
2015-12-01 19:51:49 +01:00
Markus Westerlind
052fddd4dd
Use the BraceStyle config to calculate the width for braces in where clasues
2015-11-28 13:59:14 +01:00
Markus Westerlind
937467c358
Fix where clauses not taking the width of the line into account
...
Fixes #630
2015-11-27 09:27:41 +01:00
Markus Westerlind
0021001a07
Use utils::last_line_width in rewrite_type_alias
2015-11-26 21:28:00 +01:00
Markus Westerlind
c61d6d4c3a
Format type aliases
...
Fixes #486
2015-11-26 21:04:49 +01:00
Nick Cameron
68bc387925
Merge pull request #655 from kyeah/impl-comments
...
Keep comments in empty impl body
2015-11-26 17:59:22 +13:00
Seo Sanghyeon
2b11d84119
Apply Clippy
2015-11-25 15:39:15 +09:00
Kevin Yeh
b6dc8a3f76
Keep comments in empty impl bodies
2015-11-24 12:55:32 -06:00
Nick Cameron
d405fdc236
Fix a bug with nested impls
2015-11-24 09:37:52 +13:00
Marcus Klaas de Vries
5a3f5bc1f6
Merge pull request #646 from rust-lang-nursery/mulit-file
...
Handle multiply-referenced files
2015-11-23 21:35:09 +01:00
Nick Cameron
40eb3ea857
Merge pull request #641 from marcusklaas/fix-doc-commentz
...
Correct doc comment indentation for struct fields
2015-11-23 13:58:19 +13:00
Nick Cameron
9cf8529e33
Implement formatting for impls
...
Fixes #614
2015-11-23 13:09:00 +13:00
Marcus Klaas
4b4dd170d8
Correct doc comment indentation for struct fields
...
Fix https://github.com/rust-lang-nursery/rustfmt/issues/572 .
2015-11-22 22:55:57 +01:00
Marcus Klaas
840012b5e0
Format bare function types
...
Fix https://github.com/rust-lang-nursery/rustfmt/issues/616 .
Fix https://github.com/rust-lang-nursery/rustfmt/issues/276 .
Close https://github.com/rust-lang-nursery/rustfmt/issues/350 .
2015-11-22 16:07:38 +01:00
Marcus Klaas
559f00ba99
Fix up indentation of function style paths
...
Fixes https://github.com/rust-lang-nursery/rustfmt/issues/105 .
2015-11-22 14:48:30 +01:00
Marcus Klaas
1b0ae00488
Extract fn rewrite methods from RewriteVisitor
2015-11-22 13:45:51 +01:00
Marcus Klaas
7b0cceafee
Force chains to adhere to restrictions
2015-11-20 21:09:34 +01:00
Marcus Klaas
6e1f77664d
Unwrap match arms that are simple blocks
2015-11-20 21:05:18 +01:00
Marcus Klaas
8f3a29d1a7
Blockify multiline match arms
2015-11-20 21:05:10 +01:00
Kevin Yeh
2e9b6dfab4
Combine rewrite_single_line_fn and rewrite_fn
2015-11-19 20:49:24 -06:00
Kevin Yeh
15ec5b2912
Fix empty body format, add fn_empty_single_line option, refactor block tests
2015-11-19 20:45:02 -06:00
Kevin Yeh
fbd1398c92
Implement Rewrite for ast::Stmt
2015-11-19 14:23:56 -06:00
Kevin Yeh
22837b0748
Combine block utilities
2015-11-19 14:23:56 -06:00
Kevin Yeh
4d7de5a16e
Support single-line functions
...
By default, places functions with empty bodies on one line.
If the function has only one expression or statement that fits on one line, the 'fn_single_line' option can be used.
2015-11-19 14:23:56 -06:00
Nick Cameron
f09aa85798
Merge pull request #619 from SiegeLord/item_brace_style_1
...
Implement initial option for brace style for non-fn items.
2015-11-20 07:41:12 +13:00
Pavel Sountsov
1056006790
Properly follow the brace styles.
2015-11-18 22:34:14 -08:00
Nick Cameron
56a765ef05
Rustup
2015-11-16 14:16:46 +13:00
Pavel Sountsov
8658774ad2
Implement initial option for brace style for non-fn items.
2015-11-15 11:55:18 -08:00
Marcus Klaas
d32245a13d
Fix brace indentation after where clause
2015-11-13 14:31:20 +01:00
Nick Cameron
bcda2824a2
Format tuple structs better
...
closes #546
2015-11-09 19:00:04 +13:00
Florian Zeitz
2aa35f0f6d
Honor "enum_trailing_comma" option. Fixes #556
2015-11-03 23:57:31 +01:00
Marcus Klaas
d122ad5adc
Address some issues with multiline patterns in let statements
2015-10-24 13:13:15 +02:00
Marcus Klaas
e8447a8210
Fix large block comments
2015-10-19 23:06:36 +02:00
Marcus Klaas
11756d2ef8
Refactor enum formatting
2015-10-19 21:28:05 +02:00
Marcus Klaas de Vries
754925e132
Merge pull request #484 from marcusklaas/patternz
...
Format some patterns
2015-10-19 20:20:29 +02:00
Marcus Klaas
ca023ba9b7
Format some patterns
2015-10-19 20:15:36 +02:00
Marcus Klaas
7e0456b852
Format visibility for statics and consts
2015-10-19 20:08:03 +02:00
Marcus Klaas de Vries
8a9bbd9d7c
Merge pull request #487 from marcusklaas/konsts-n-statix
...
Format constants and static variables
2015-10-18 23:03:01 +02:00
Marcus Klaas
3ce425c9ed
Factor out common item indentation idiom
2015-10-18 22:59:39 +02:00
Marcus Klaas
8e2a910021
Fix indentation for function arguments
2015-10-18 22:22:41 +02:00
Marcus Klaas
1a7d39041e
Format constants and static variables
2015-10-18 21:36:26 +02:00
Nick Cameron
d326a29b4b
Merge pull request #479 from marcusklaas/moar-types
...
Format more type variants
2015-10-18 15:40:11 +13:00
Marcus Klaas
01937061a9
Format more type variants
2015-10-17 16:05:59 +02:00
Marcus Klaas
5407202fdf
Properly indent pub fns in extern blocks
2015-10-16 23:05:11 +02:00
Marcus Klaas
5ca9381d74
Adjust for unified enum variants and structs
2015-10-15 20:37:36 +02:00
Marcus Klaas
b768d27f03
Format variadic arguments
2015-10-11 20:57:44 +02:00
Nick Cameron
aed558fce4
Handle multi-line return types and multi-line tuples
...
Closes #409
2015-10-10 14:55:31 +13:00
mwiczer
5162282b60
Support pre- and post-comments for enums
...
Use lists to format enum variants rather than special formatting.
Add tests for enums mostly around block comments.
2015-10-08 17:22:57 -04:00
Marcus Klaas de Vries
5eeae3944e
Merge pull request #404 from marcusklaas/rewrite-list-fmt
...
List formatting refactoring
2015-10-06 22:29:52 +02:00
Marcus Klaas
199d40fa55
Increase default function call width limit
2015-10-06 22:27:11 +02:00
Marcus Klaas
a76df6b4d9
Make listItem contain option
2015-10-04 20:40:14 +02:00
Marcus Klaas
965ea09664
Split ListTactic decision logic from write_list
2015-10-04 20:40:14 +02:00
Marcus Klaas
84718b5b90
Format rustfmt's own indices
2015-10-02 11:48:52 +02:00
Nick Cameron
840af4f84d
Option for putting the where clause on the same line as the function if the body is empty.
2015-09-28 08:46:05 +13:00
Nick Cameron
9139a8040c
Merge pull request #379 from marcusklaas/enum-quik-fix
...
Fix variant name duplication on rewrite failure
2015-09-28 07:51:09 +13:00
Marcus Klaas
a673fef844
Fix variant name duplication on rewrite failure
2015-09-27 17:23:37 +02:00
Marcus Klaas de Vries
0f485aabd6
Merge pull request #374 from nrc/fix-fn
...
Use max width for function decls, not ideal width
2015-09-27 14:52:08 +02:00
Nick Cameron
bc59f83f02
Use max width for function decls, etc.
...
We were using ideal width + leeway before. This means we can remove leeway from the config. We could remove ideal_width too, but I want to use it for comments.
2015-09-27 19:34:35 +13:00
Nick Cameron
224eecce50
Minor refactoring in compute_budgets_for_args
2015-09-27 19:25:04 +13:00
Marcus Klaas
078fff068a
Improve heuristics for match arm body placement
2015-09-26 22:35:53 +02:00
Nick Cameron
99d71a164a
Changes to source formatting
2015-09-26 13:58:12 +12:00
Nick Cameron
ebf64ca35d
Heuristic max width for function calls
2015-09-26 13:54:22 +12:00
Marcus Klaas
5db17ca703
Use the maximum available width in struct formatting
...
Previously, we'd use an approximation for the maximum width since the configuration wasn't available in `write_list`.
2015-09-25 16:56:22 +02:00
Marcus Klaas
71faa8984d
Format foreign functions and statics
2015-09-21 20:02:45 +02:00
Pavel Sountsov
01bdcd0014
Remove unnecessary config parameter from format_missing_with_indent.
2015-09-19 10:44:28 -07:00
Pavel Sountsov
03e1b27826
Add Indent::none(), remove make_indent.
2015-09-19 10:36:45 -07:00
Pavel Sountsov
d4108a3029
Initial implementation of hard tab indentation.
2015-09-19 10:36:45 -07:00
Sebastian Ullrich
3da7adbc3f
rustc update: Remove variant visibility
...
https://github.com/rust-lang/rust/pull/28440
2015-09-19 17:46:25 +02:00
Marcus Klaas
e72d488281
Refactor test code
...
No longer use callbacks or thread::catch_panic; reduce stdout spew; guard against rustfmt breaking the column limit.
2015-09-18 22:34:46 +02:00
Marcus Klaas
f751356910
Format macro invocations
2015-09-16 20:26:14 +02:00
Marcus Klaas
623d6c972a
Rewrite types in function arguments
2015-09-11 12:32:34 +02:00
Marcus Klaas
7f576b0602
General cleanup after rebase
2015-09-11 00:53:21 +02:00
Marcus Klaas
03c660633f
Refine chain breaking heuristics
...
Don't make a single line chain when it is was multi line in the source; allow overflow of the last chain element onto the next lines without breaking the chain.
2015-09-11 00:53:01 +02:00
Marcus Klaas
a9814149c9
Align dots in chained expressions
2015-09-11 00:53:01 +02:00
Marcus Klaas
659c9b9037
Update indentation heuristics for single arg functions
2015-09-11 00:52:20 +02:00
Marcus Klaas
c680bb4030
Implement basic chain formatting
2015-09-11 00:52:16 +02:00
Marcus Klaas
582aa4f2fe
Format closures' return types
2015-09-08 20:56:33 +02:00
Marcus Klaas
d05a41c773
Add failure mode to write_list
2015-09-07 20:35:25 +02:00
Nick Cameron
fb9e051fd8
Format <foo + 'bar> nicely
2015-09-04 17:04:54 +12:00
Nick Cameron
97e92b35cc
Preserve some whitespace between struct fields etc.
2015-09-02 14:11:19 +12:00
Nick Cameron
fae93abbda
Support struct-like layouts for fn args
2015-09-02 09:41:08 +12:00
Nick Cameron
f81485d9d6
Rename fn_args_layout to fn_args_density
2015-09-02 08:56:37 +12:00
Nick Cameron
8d81aa1991
Support where clauses on the same line as the function decl where it all fits on one line.
2015-09-02 07:59:54 +12:00
Nick Cameron
6216dce14e
Support where clause predicates at different indentations
2015-09-01 19:04:41 +12:00
Nick Cameron
02a01350ff
Support where predicates on the same line
2015-09-01 18:53:16 +12:00
Nick Cameron
6f3c329500
Support non-indented where clauses
2015-09-01 18:38:12 +12:00
Nick Cameron
fc2fb8be43
Support different indent styles for generics
2015-09-01 18:20:17 +12:00
Nick Cameron
0413c47a09
Support different tabbing of function args
...
(Although, frankly anything other than visual is deeply wrong).
2015-09-01 17:22:00 +12:00
Nick Cameron
89cda8d43a
Option to pack fn args on fewer lines
2015-09-01 17:06:41 +12:00
Gaëtan Cassiers
5e445697ce
Implement Rewrite for [ast::Attribute]
2015-08-27 22:29:07 +02:00
Marcus Klaas
120fd2426e
Format assignment
2015-08-25 21:43:13 +02:00
Ivan Apachev
c7e6d0b54a
Replace uses of x.len() == 0 by x.is_empty() #187
2015-08-25 01:07:48 +03:00
Marcus Klaas
5fcd313b08
Format closures
2015-08-19 23:15:56 +02:00
Nick Cameron
a43e2b5ae8
Formatting
2015-08-20 08:11:14 +12:00
Marcus Klaas
4e0a8da447
Refactor itemize list so that it produces an iterator
2015-08-19 18:40:02 +02:00
Marcus Klaas
41bca58100
Format paths
2015-08-16 22:53:06 +02:00
Marcus Klaas
82b27fc4ab
Correctly format typed self in function arguments
2015-08-14 11:56:27 +02:00
Gaëtan Cassiers
0eab4bf430
Remove ChangeSet of FmtVisitor
2015-08-02 13:12:51 +02:00
Marcus Klaas
54a96355dd
Phase out token::get_ident in favour of ToString
...
token::get_ident was removed in rust commit 00a5e66f81
2015-07-31 13:10:19 +02:00
Nick Cameron
8461e8a0a8
Merge pull request #147 from marcusklaas/even-more-expr
...
Format if expressions & loops
2015-07-25 09:51:59 +12:00
Marcus Klaas
500fb78a33
Format unnamed function arguments
2015-07-20 20:07:54 +02:00
Marcus Klaas
b161815fe0
Format if-else expressions
2015-07-19 23:42:54 +02:00
Nick Cameron
c3375078e5
Merge pull request #137 from nrc/struct-lit-opt
...
Options for formatting struct literals
2015-07-17 06:57:01 +12:00
Nick Cameron
f2bcee9d87
Tidy up some overrunning lines
2015-07-16 14:23:48 +12:00
Nick Cameron
018fa85453
Reformat code to new struct lit style
2015-07-16 14:05:10 +12:00
Gaëtan Cassiers
990a123e1c
Run rustfmt on the code
2015-07-03 11:13:28 +02:00
Gaëtan Cassiers
83290f15ad
Add comma after struct-like enum variant
...
This is mandatory.
2015-07-03 10:30:42 +02:00
Gaëtan Cassiers
fc4483748c
Fix fn decl rewriting in case of generics
...
An opening paren in generics caused a false-positive detection of args
beginning. The result was the creation of comments with some code into
it.
2015-07-03 10:30:42 +02:00
Marcus Klaas
28f7bd4205
Fixup comment wrapping in lists
2015-06-24 21:14:08 +02:00
Marcus Klaas
9f3ab0b5fe
Format comments in struct literals
2015-06-24 01:11:29 +02:00
Marcus Klaas
0ef5db9496
Format tuple-like structs
2015-06-23 16:54:42 +02:00
Marcus Klaas
d7b49fd76c
Remove global mutable config to allow for concurrency
2015-06-23 13:26:04 +02:00
Marcus Klaas
b17c920e46
Deal with problematic characters in comments
2015-06-15 15:07:47 +02:00
Marcus Klaas
13141e261b
Remove duplicate statement in make_comments_for_list
2015-06-04 15:05:50 +02:00
Marcus Klaas
90bc40a111
Implement basic enum formatting
2015-06-02 15:52:07 +02:00
Nick Cameron
90494132c2
Merge pull request #81 from tdudziak/issue_31
...
Optionally put the opening paren on the previous line for args (Issue #31 )
2015-05-29 11:59:37 +12:00
Tomasz Dudziak
1bb3c9e555
Use config!(tab_spaces) instead of hardcoded 4
.
2015-05-26 09:31:16 +02:00
Tomasz Dudziak
21a0f1b787
Clarify indent calcs in compute_budget_for_args
2015-05-25 21:29:02 +02:00
Tomasz Dudziak
fdd7baeae9
Optionally put the opening paren on the previous line for args
2015-05-25 16:39:19 +02:00
Gaëtan Cassiers
113bdaa119
Fix #79
2015-05-25 13:22:10 +02:00
Nick Cameron
972f494e4e
Pref for comma on the last field
2015-05-25 17:14:39 +12:00
Nick Cameron
e7adf64155
Format structs
2015-05-25 17:07:55 +12:00