Commit graph

165 commits

Author SHA1 Message Date
topecongiro
d062d79fb5 Use block indent when visual indent failed 2017-05-08 08:07:18 +09:00
topecongiro
4a28be486e Refactor Shape 2017-05-08 07:24:32 +09:00
topecongiro
e923df4146 Add indented and with_max_width 2017-05-08 07:24:12 +09:00
Nick Cameron
8579c1db0e Merge pull request #1495 from topecongiro/poor-formatting/closure
Fix weird indentation inside closures
2017-05-04 17:15:58 +12:00
Sheng Hau
51815effbe Format macros in trait item position 2017-05-04 00:10:03 +08:00
topecongiro
58d957be3f Check format failures explicitly in visit_block 2017-05-04 00:21:51 +09:00
Jonathan Behrens
b6f1b516d9 Format any statement whose span intersects file_lines 2017-03-29 01:33:14 -04:00
Nick Cameron
5305bc8436 test fallout 2017-03-28 11:25:59 +13:00
Nick Cameron
5fb1140688 fallout - source reformatting 2017-03-28 11:14:47 +13:00
Nick Cameron
e4efa22983 Source formatting fallout 2017-03-28 10:58:41 +13:00
C4K3
ab832fa4bb config: Rename ideal_width -> comment_width (#1370)
Since the config option only affects comment widths, and the previous
name has led to some confusion (see #1321, #1152).
2017-03-13 09:07:33 +13: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
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
e018712612 process cfg'ed off modules
Fixes #1229
Fixes #1277
2017-01-20 08:20:49 +13:00
Nick Cameron
49e86a1e65 Handle semicolons in macro statements
Fixes #1279
2017-01-18 10:38:46 +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
Nick Cameron
d3eba76e4d update Serde, etc.
Lots of changes to how closures work
2016-11-21 11:02:18 +13:00
Fraser Hutchison
aef665aa21 Fixes a few doc typos. 2016-11-03 04:22:16 +00:00
Philip Craig
c4a7a7108e Preserve macro formatting if we can't rewrite it 2016-10-03 14:14:56 +10:00
Nick Cameron
e1d7b8ea01 Merge pull request #1162 from sinkuu/fix1040
Fix #1040
2016-09-19 14:35:42 +12:00
Nick Cameron
4418fab4f2 Update to latest Syntex
+ Cargo update
+ 0.6.2 release
2016-09-16 15:28:02 +12:00
sinkuu
b446e31739 Fix #1040 2016-09-10 13:08:32 +09:00
sinkuu
a3c63fdef9 Run clippy 2016-08-29 08:57:27 +09:00
Stuart Dootson
61042e6e4d Fix issue 1124 - detect start of output rather than start of input file when writing output source file (#1133)
* Change required to prevent a trailing space at the end of a separate module being propagated

* Detect the start of the output file rather than the start of the input file when deciding whether to output preceding snippets - this stops unnecessary whitespace and blank lines from being inserted when spans and statements are output in an order other than that from the input file.

* Add code to prevent space from being added with the prefix snippet if a) the snippet is entirely horizontal whitespace, or b) the snippet contains whitespace  followed by a newline. This prevents trailing spaces at the end of a line from being added.

* Tests for this issue

* Tidy up `match` statements

* Add test with blank lines between `use` statements
2016-08-25 08:32:04 +12:00
Stuart Dootson
78b52ec3e1 Add use declaration re-ordering (#1104)
* Add config options for combinations of lines and items

* Reordering of import lines implemented.

* Changed nested matches to tuple pattern matching

* Added ordering of path list items to the ordering of use declarations

* Move `format_imports` and `format_import` methods to `imports.rs`

* Add comment to explain how `use` declarations are split off while walking through a module

* Change `ImportReordering` config option to separate boolean options
2016-07-26 17:20:01 +12: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
9fa5a91fc5 visitor: Handle specified line ranges in visit_stmt
This commit adds a very rough implementation of handling the specified
line ranges in `config.file_lines_map` for statements. It reformats a
statement if its span is fully contained in the set of lines specified
for the file.

The implementation here is intended as a proof of concept, and
demonstration that the machinery added in the preceding commits is
functional. A final implementation would likely hook in via the
`Rewrite` trait.

Refs #434
2016-05-31 01:33:11 +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
Kamal Marhubi
80c56a01ff visitor: Add debug log for FmtVisitor::visit_stmt() 2016-05-31 00:43:48 +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
775de8a62b Optionally put short struct variants on one line (#997)
Closes #418
2016-05-18 22:38:49 +02:00
Nick Cameron
9589cac62d Format inline attributes on out-of-line modules (#996)
Fixes #838
2016-05-18 22:36:59 +02:00
Daniel Campbell
238fc500ae Altered FmtVisitor to function correctly on generated code 2016-05-06 13:51:48 +12:00
Nick Cameron
90c0f708f5 Merge pull request #971 from kamalmarhubi/update-syntex-syntax
deps: Update syntex_syntax to 0.31.0
2016-05-03 09:19:50 +12:00
Nick Cameron
c696dcf8da Handle attributes on modules (#968)
* Handle attributes (including doc comments) on inline modules

Closes #22
Closes #684

* Tweak the rules for changing indentation in comments (to do it less often).
2016-05-02 10:54:25 +02: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
mrBliss
b0755581ca Format visibility of associated consts (#953)
Fixes #951.
2016-04-19 20:19:14 +02:00
Nick Cameron
afc8be1d79 Change the logic around breaking multiple patterns in match arms
Refactor to use the list code, don't preserve original stacking-ness, base vertical vs mixed formatting on complexity of the patterns.

Closes #386
2016-04-12 09:23:37 +12:00
Marcus Klaas
9e5c0390a0 Properly format macro's with an extra ident 2016-03-29 23:16:40 +02: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
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