Nick Cameron
d5478f7d45
Reformatting source code
2017-03-10 16:06:05 +13:00
Nick Cameron
22be93780c
block generics in traits
2017-03-10 16:04:08 +13:00
Nick Cameron
a1d94e545c
Attempt to fixup impls with long generics
2017-03-10 15:58:35 +13:00
Nick Cameron
c8af03f475
Block formatting for tuple structs
...
Follows the fn_args_layout option
2017-03-10 15:31:45 +13:00
Nick Cameron
7b901130cb
Insert a newline before block-formatted generics
...
Fixes #1359
2017-03-10 14:29:45 +13:00
Nick Cameron
4b60d94a99
Check we can put the where clause on one line when we think we can
...
Fixes #1362
2017-03-10 09:45:26 +13:00
Nick Cameron
70085fca84
Try harder to format function sigs
...
Fixes #1363
2017-03-10 09:26:14 +13:00
Nick Cameron
d107ca12b8
Use trailing commas if block formatting fn args
...
Fixes #1330
2017-03-09 14:47:29 +13:00
Nick Cameron
6025492245
Implement where_style Rfc
2017-03-09 14:21:20 +13:00
Nick Cameron
33b83ae7df
Formatting fallout
...
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-07 09:50:41 +13:00
Nick Cameron
f2eac0513f
Fix trailing comma tests
2017-03-02 14:27:33 +13:00
Nick Cameron
248f2aba56
Merge branch 'master' of github.com:rust-lang-nursery/rustfmt
2017-03-02 14:27:02 +13:00
David Wickes
371ffa4710
Small reformat
2017-02-26 22:28:53 +00:00
David Wickes
094c8898e1
Fix for #1255
...
Default annotation incorrectly removed on associated types
Fixed by adding a specific function to perform formatting on `ImplItems`.
2017-02-26 22:28:21 +00:00
Nick Cameron
6a58d91239
Coalesce trailing comma options
2017-02-24 10:31:23 +13:00
Nick Cameron
a7612cc773
more fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
d9d2423764
Tweak chain rules
2017-02-23 13:15:48 +13:00
Nick Cameron
9eb78a3333
Fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
b35906dbce
WIP
2017-02-21 16:35:05 +13:00
Nick Cameron
428339fdc3
Refactor indent and width into Shape struct
2017-01-31 08:35:23 +13:00
Nick Cameron
6054f28bd2
Some debugging stuff
2017-01-27 09:14:26 +13:00
Nick Cameron
309fb37f23
Allow some unused fields
2017-01-27 07:42:34 +13:00
Nick Cameron
6747cd721c
Start factoring out an abstract Item
2017-01-27 07:37:09 +13:00
Nick Cameron
3d3b6784d1
Nits
2017-01-26 15:44:54 +13:00
Nick Cameron
0b1d78bae1
Try hard to format impl signatures
...
Fixes #1249
2017-01-17 13:08:36 +13:00
sinkuu
7e2fcc27e1
Fix #1258 ( #1266 )
...
* Fix #1258
* Add test
2017-01-09 16:11:12 +13:00
sinkuu
1358f1ac80
Fix #1259 ( #1263 )
...
* Use `Indent::block_indent` instead of adding `config.tab_spaces`
* Fix #1259 impl block closing brace placement
2017-01-04 09:20:02 +13:00
Erick Tryzelaar
e67ffcfb21
Update to the latest syntex module
...
One notable feature is this this adds support for the experimental
`let x = loop { ... break $expr; }` syntax. This also includes a
test for formatting all the break and continue variations.
2016-12-23 11:20:07 -08:00
Luke Clifton
6bf1382927
Indent open brace for impl when nested. ( #1227 )
...
* Indent open brace for impl when nested.
Fixes #1226
* Added test case for indented impl with brace on newline
2016-11-28 13:47:07 +13:00
Nick Cameron
d3eba76e4d
update Serde, etc.
...
Lots of changes to how closures work
2016-11-21 11:02:18 +13:00
Mikko Rantanen
636a828772
Add support for spaces_within_angle_brackets
...
Enabling the config adds spaces within type arguments: <>
2016-10-13 19:28:18 +03:00
Mikko Rantanen
7be202fa3c
Add support for spaces_within_parens config ( #1187 )
...
* Add support for spaces_within_parens config
* Changes based on review comments
2016-10-13 14:34:08 +13:00
Nick Cameron
3ff7e83457
Merge pull request #1156 from sinkuu/break_if_let
...
Prefer line break at `=`/`in`
2016-09-19 18:51:21 +12:00
sinkuu
114a3e287a
Fix self test
2016-09-19 11:48:56 +09:00
sinkuu
b6bffa6596
Prevent line breaking at =
or in
after trivial patterns
2016-09-17 13:03:14 +09:00
est31
efd3e5c091
Add three new options for spaces
2016-09-17 02:22:13 +02:00
Nick Cameron
4418fab4f2
Update to latest Syntex
...
+ Cargo update
+ 0.6.2 release
2016-09-16 15:28:02 +12:00
dawirstejeck
a5d7073bf5
Split impl at 'for' if a line break is needed ( #1148 )
...
* Split impl at 'for' if a line break is needed
* Fix formatting
* Improve comments
* Skip second try if there is no 'for'
* Restore intentional trailing whitespace
* Change test source to be incorrectly formatted
* Restore more missing trailing whitespace
* Remove too much whitespace...
Really should learn how to use git revert.
2016-09-06 17:11:56 +12:00
sinkuu
a3c63fdef9
Run clippy
2016-08-29 08:57:27 +09:00
sinkuu
130c593544
Fix #977
2016-08-28 16:40:03 +09:00
Nathan Ridge
899169a1d2
Apply space_before_type_annotation to struct ctors ( #1109 )
2016-08-05 01:30:53 -04:00
Nick Cameron
fe69e975e3
Merge pull request #1110 from HighCommander4/issue1109a
...
Add two new whitespace options (#1109 )
2016-08-04 10:58:32 +12:00
Nathan Ridge
4b999a99c0
Add two new whitespace options ( #1109 )
...
* An option to leave a space before the colon in a type annotation
* An option to leave a space before the colon in a trait or lifetime bound
2016-08-03 01:11:39 -04:00
dawirstejeck
22de7ced28
Fix overlong function signature ( #1089 )
...
* Fix issue-1049
* Add testcase suggested by pepyakin
* Fix last commit
* Handle special case
* Remove debugging println
* Fix grammar in comment
* Change word in comment
* Add test for long func without ret type
* Add one more test
2016-08-01 16:25:00 +12:00
dawirstejeck
e76cb6a907
Fix overlong impl ( #1091 )
...
* Fix issue-1048
* Take possible where-clause into account
* Move test to existing test set
* Fix wrong variable name
2016-07-26 17:34:11 +12:00
Jacob Clark
77edbb7def
Refactoring exsisting filter_maps to maps
2016-06-07 00:03:25 +01:00
Jacob Clark
2ea99869a7
Refactor string collects to itertools join
2016-06-06 22:30:40 +01:00
lqd
b6263735b1
Add support for the default
keyword ( #1025 )
...
Adds support for Defaultness on impl methods.
Fixes #945
2016-05-31 19:48:49 +02:00
Kamal Marhubi
bd10af127e
utils: Move codemap related utilities to a dedicated module
...
This commit adds a `codemap` module, and moves the `CodemapSpanUtils`
added in #857 to it. This is preparation for adding more `Codemap`
specific utilities.
Refs #434
2016-05-31 00:49:26 +02:00
Nick Cameron
5436977bd5
Merge pull request #1017 from marcusklaas/tweak-if-else
...
Format non-statement if-else expressions on a single line
2016-05-31 01:57:29 +12:00
Kamal Marhubi
120e1a0b51
deps: Update syntex_syntax to 0.33
...
This bump brings syntex_syntax support for `..` in tuple and tuple
struct patterns, which come from RFC 1492:
https://github.com/rust-lang/rfcs/blob/master/text/1492-dotdot-in-patterns.md
These new patterns are not properly handled in this PR; instead #1021
tracks supporting them.
Refs #1021
2016-05-30 14:53:04 +02:00
Marcus Klaas
98c0570a28
Format non-statement if-else expressions on a single line
2016-05-29 17:58:38 +02:00
Kamal Marhubi
66cac1f3e9
Handle pub(restricted) ( #1013 )
...
* Handle pub(restricted)
This commit properly handles pub(restricted) as introduced in RFC 1422
[0]. The syntax support was added in #971 , but they were not correctly
formatted.
[0] https://github.com/rust-lang/rfcs/blob/master/text/1422-pub-restricted.md
Fixes #970
* Drop #[inline] attribute on format_visibility
* Make newly non-failing functions return String
The change to `format_visibiilty` means that `format_header` and
`format_unit_struct` can no longer fail. Their return type is updated to
reflect that.
2016-05-28 00:58:25 +02:00
Nick Cameron
882ef8cc82
Fix off by 2 error in function sigs
...
Fixes #1000
This is a little conservative in some cases, but better than being wrong in others.
2016-05-27 15:05:15 -07:00
Nick Cameron
775de8a62b
Optionally put short struct variants on one line ( #997 )
...
Closes #418
2016-05-18 22:38:49 +02:00
Marcus Klaas
eae2921e14
Bootstrap it. Hard.
2016-05-12 21:50:43 +02:00
Kamal Marhubi
8309d1a74c
deps: Update syntex_syntax to 0.32.0
2016-05-05 16:39:34 -04:00
Kamal Marhubi
6285d53885
Handle new visibility types more gracefully
2016-05-02 01:05:23 -04:00
Kamal Marhubi
fd38acb86f
deps: Update syntex_syntax to 0.31.0
...
Most of the churn on this bump comes from the `Visibility` enum changing
from
pub enum Visibility {
Public,
Inherited,
}
to
pub enum Visibility {
Public,
Crate,
Restricted { path: P<Path>, id: NodeId },
Inherited,
}
which require taking `Visibility` by reference in most places. The new
variants are not handled at this point.
Refs #970
2016-05-01 23:06:58 -04:00
Nick Cameron
a9c3108c9c
Change defaults and update tests and source
...
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-22 19:18:48 +12:00
Nick Cameron
9761cf71d8
Tests
2016-04-22 18:53:39 +12:00
Marcus Klaas
f364a7ec43
Add option to force explicit extern ABI's
2016-04-18 18:39:40 +02:00
Marcus Klaas de Vries
320df84e96
Fix brace indentation for impl items ( #927 )
2016-04-14 20:42:38 +02:00
Nick Cameron
c6084cb29c
Fix the build
2016-04-12 11:04:33 +12:00
Nick Cameron
ce97bc08be
Merge pull request #896 from erikjohnston/fn_arg_one_line
...
Add fn_arg_one_line option
2016-04-12 10:44:01 +12:00
Nick Cameron
492b26cf04
Empty structs and struct lits ( #920 )
...
* Handle empty struct lits
Closes #835
* Don't crash on empty struct defs.
Not a great fix, but better than crashing.
2016-04-11 21:05:54 +02:00
Erik Johnston
6a82a5fb0e
Tidy up
2016-04-07 20:47:43 +01:00
Erik Johnston
4c9dd747bf
Fix long generic indent
2016-04-07 20:29:05 +01:00
Erik Johnston
4edc6f1a4e
Add variant to fn_args_layout
2016-04-07 20:01:16 +01:00
Erik Johnston
57847e451a
Add fn_arg_one_line option
...
If set, arguments will be kept on one line if they fit. Currently only
applies when `fn_args_layout` is set to `Block`.
This commit also fixes a bug where newlines were inserted inbetween
argument brackets when there were no arguments and `fn_args_layout` was
set to `Block`.
2016-04-02 00:25:35 +01:00
Erik Johnston
8219d15291
Fix incorrect indent with fn_args_layout: Block
...
The closing parenthesis for the arg list was written on a new line
without first applying the appropriate indent.
2016-04-01 23:01:49 +01:00
Marcus Klaas
03bf1ceeb9
Fix tuple destructuring in impl fns
2016-03-27 13:07:28 +02:00
Marcus Klaas de Vries
8fd95df54a
Merge pull request #868 from rust-lang-nursery/tuple-wide
...
Don't apply the function args heuristic to tuple lits.
2016-03-24 14:57:24 +01:00
Marcus Klaas de Vries
ca757183fe
Merge pull request #864 from Venti-/fn-density
...
Add option for vertical function argument list
2016-03-22 10:14:04 +01:00
Marcus Klaas de Vries
6f2bb908bb
Merge pull request #866 from rust-lang-nursery/empty-extern
...
Keep empty extern blocks on one line
2016-03-16 18:06:25 +01:00
Connor Brewster
0a665aaceb
Fixed nitpicks
...
Removed unneeded comment
Commented line wrapping conditions
Removed prefix param on `rewrite_associated_type`
Merged `rewrite_associated_static` into `rewrite_static`
Added extra tests
2016-03-15 14:08:12 -06:00
Connor Brewster
a0a5335634
Fixed span_after issue
2016-03-14 20:51:41 -06:00
Connor Brewster
7a6eb2197e
Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into add-trait-formatting
2016-03-14 20:49:14 -06:00
Connor Brewster
2793b4090c
Added tests
2016-03-14 20:05:20 -06:00
Connor Brewster
7ba43ff06e
Finished implementing impl and trait type/const
2016-03-14 19:52:07 -06:00
Nick Cameron
9d8ce54428
Don't apply the function args heuristic to tuple lits.
...
Closes #450
Closes #510
2016-03-14 20:51:06 +13:00
Nick Cameron
96a2f25788
Keep empty extern blocks on one line
...
Closes #462
2016-03-14 18:55:55 +13:00
Nick Cameron
da65090050
Merge pull request #857 from kamalmarhubi/codemap-ext
...
utils: Add CodeMapExt extension trait for span_* methods
2016-03-14 18:00:51 +13:00
Ari Koivula
0c8640a84f
Fix last comment turning into block comment
...
This fixes the comment after the last argument in an argument list
being turned into a block comment when it's not necessary.
2016-03-14 02:02:52 +02:00
Kamal Marhubi
d82d9fc808
utils: Add CodeMapSpanUtils trait for span_* methods
...
This commit adds a CodeMapSpanUtils extension trait on CodeMap, and
moves some functions to methods there:
- span_after
- span_after_last
- span_before
This better reflects them being lookup methods on the codemap.
2016-03-13 18:14:07 -04:00
Connor Brewster
3163071c75
Updated to latest rustfmt
2016-03-12 11:09:27 -07:00
Connor Brewster
34651c4f78
Fixed formatting
2016-03-11 22:41:22 -07:00
Connor Brewster
d24c31f74c
Added support for associated type rewriting
2016-03-11 22:32:08 -07:00
Connor Brewster
9e583ce7a7
Added where clause formatting
2016-03-11 14:49:11 -07:00
Connor Brewster
35dfcc0078
Adding trait formatting
...
trait header formatting finished
generic formatting finished
added basic trait bounds formatting
2016-03-11 14:18:30 -07:00
Amanieu d'Antras
698027c4c4
Fix ordering of "const unsafe fn"
2016-03-09 02:44:01 -08:00
Kamal Marhubi
589dabda2f
deps: Update syntex_syntax to 0.29.1
2016-03-02 13:08:21 -05:00
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