Commit Graph

282 Commits

Author SHA1 Message Date
topecongiro
669a139956 Only merge consecutive derives 2017-08-24 23:48:18 +09:00
topecongiro
5dafcc24e4 Add merge_derives config option 2017-08-24 22:29:56 +09:00
Nick Cameron
d7b5e7de54 Merge pull request #1906 from topecongiro/remove_count_missing_closing_parens
Remove count_missing_closing_parens()
2017-08-21 10:12:30 +12:00
topecongiro
3d1b6fe1c6 Remove count_missing_closing_parens() 2017-08-20 23:23:13 +09:00
Seiichi Uchida
63ac49638b Support match_pattern_separator_break_point config option 2017-08-18 23:19:47 +09:00
topecongiro
528200009a Do not panic against files with invalid attributes 2017-08-16 00:11:20 +09:00
sinkuu
f9ee060eae Use utils::inner_attributes 2017-08-12 18:28:28 +09:00
sinkuu
955b25625d Use attribute span 2017-08-12 18:28:28 +09:00
sinkuu
b433e63d2a Remove unnecessary blank lines at the start and the end of a block 2017-08-11 17:44:16 +09:00
Nick Cameron
62689ef568 Merge pull request #1861 from topecongiro/refactor-chain
Remove unnecessary rewriting
2017-08-10 09:03:45 +12:00
topecongiro
be38606c77 Add leave_last field to ListItems 2017-08-09 16:37:21 +09:00
Seiichi Uchida
f9239dd630 Format source codes and update tests 2017-08-09 16:36:41 +09:00
topecongiro
7bf9aa25be Add reorder_extern_crates and reorder_extern_crates_in_group config options 2017-08-09 00:16:18 +09:00
Caleb Jones
fa242a5cd6 Fix #1858 - "Don't erase a use with attributes attached"
This prevents code like

    #[cfg(unix)]
    pub use self::unix::{};

from becoming

    #[cfg(unix)]

which would cause the attribute to be attached to the next item.
2017-08-06 19:53:57 -04:00
topecongiro
60fb11e5dd Do not take inner attributes into account for span 2017-08-05 15:21:46 +09:00
Emilio Cobos Álvarez
27a3bdb394
visitor: Only reorder imports if at least one of them is in file-lines. 2017-07-31 09:14:58 +01:00
Seiichi Uchida
47456aaa43 Merge pull request #1819 from brainlessdeveloper/fix-extern-crate-whitespace
Remove whitespace between words in extern declarations
2017-07-31 16:21:48 +09:00
Fausto Núñez Alberro
3377ba4dd7 Remove whitespace between extern crate declaration 2017-07-29 12:03:57 +02:00
topecongiro
5aff5beb2a More fine-grained file-lines 2017-07-29 16:11:36 +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
Seiichi Uchida
8b970fcc9f Format inner attributes wherever possible 2017-07-25 00:55:55 +09:00
Seiichi Uchida
adce954560 Support inner attributes 2017-07-25 00:55:29 +09:00
Nick Cameron
b559a0f2f2 Merge pull request #1808 from topecongiro/issue-831
Allow block-like rhs expression to stay on the same line with lhs
2017-07-22 16:29:36 +12:00
topecongiro
0b38ac40d7 Support rustfmt_skip on statements 2017-07-22 11:18:47 +09:00
topecongiro
68c6fe70fd Format source codes and update tests 2017-07-21 17:57:31 +09:00
topecongiro
1e00a28332 Apply item_brace_style to mod 2017-07-21 13:55:15 +09:00
Seiichi Uchida
a8b0a6e4c5 Format source codes and update tests 2017-07-20 00:42:00 +09:00
Seiichi Uchida
faf45b3a80 Remove old heuristics from legacy style 2017-07-20 00:42:00 +09:00
Seiichi Uchida
b78b6e8b09 Format source codes and update tests 2017-07-20 00:42:00 +09:00
topecongiro
6fd291981e Sort imports in alphabetical and consistent order 2017-07-13 18:42:14 +09:00
Seiichi Uchida
51641f167e Do not count the number of parens inside str or comment 2017-07-12 17:17:41 +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
Seiichi Uchida
bc63d69c3f Format source codes 2017-07-10 02:24:59 +09:00
topecongiro
fb1225a8af Use format_expr wherever single-lined block is not allowed 2017-06-20 22:35:16 +09:00
topecongiro
91bd1fdc86 Format source codes 2017-06-18 14:29:17 +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
f60a810730 Preserve comments inside attributes 2017-06-17 05:44:54 +09:00
topecongiro
208ff15954 Format source codes 2017-06-16 08:49:49 +09:00
topecongiro
b8f11a4e3c Format source codes 2017-06-14 20:39:07 +09:00
topecongiro
e2d51aeb41 Use correct span for MetaItem 2017-06-14 00:09:05 +09:00
topecongiro
384d985df9 Do not rely on format_missing for rewriting attributes 2017-06-14 00:08:31 +09:00
Nick Cameron
1f512948a0 Reformat source code using new defaults 2017-06-13 14:41:49 +12:00
topecongiro
647fd4ff77 Leave GlobalAsm and MacroDef without formatting 2017-06-06 07:32:06 +02: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
8ac9245df4 Merge pull request #1634 from topecongiro/impl-rewrite-attribute
Implement Rewrite trait for syntax::ast::Attribute
2017-06-06 17:11:10 +12:00
topecongiro
7be703a637 Implement Rewrite trait for syntax::ast::Attribute 2017-06-06 13:55:34 +09:00
Nick Cameron
130aa70e3a Merge pull request #1621 from topecongiro/combining
Combine more expressions
2017-06-06 14:52:48 +12:00
Nick Cameron
14a1ea8193 Merge pull request #1629 from topecongiro/issue-982
Use recover_comment_removed in rewrite_static
2017-06-05 11:37:21 +12:00
topecongiro
b49269ad39 Forbid method chain to get combined if it uses multi line.
If the method chain goes multi line before the last element, disallow combining
the method chain.
2017-06-04 19:37:24 +09:00
topecongiro
d54634bd7c Use recover_comment_removed in rewrite_static 2017-06-04 18:44:08 +09:00
topecongiro
aadd3e11f4 Unindent comment on top of else 2017-06-02 11:58:58 +09:00
Seiichi Uchida
789abf063d Use block indent style when visual indent failed 2017-06-01 12:08:20 +09:00
Nick Cameron
2dc4298b71 Merge pull request #1593 from topecongiro/issue-1439
Allow comments after where clause
2017-05-27 13:34:50 +12:00
topecongiro
dab14b4485 Allow comments after where clause 2017-05-27 02:07:58 +09:00
topecongiro
fcffe854b8 Allow default associated types 2017-05-26 17:17:12 +09:00
topecongiro
77a2e9858b Format source codes 2017-05-23 11:37:33 +09:00
Michael Killough
bce1f309b7 Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into config 2017-05-19 16:10:27 +07:00
Flier Lu
1077a100a1 reorder imports in group 2017-05-18 13:26:34 +08:00
Michael Killough
c0bdbfa531 Switch to accessing config items via method.
Preparation for #865, which proposes adding a flag which outputs which
config options are used during formatting.

This PR should not make any difference to functionality. A lot of this
was search-and-replace.

Some areas worthy of review/discussion:

 - The method for each config item returns a clone of the underlying
   value. We can't simply return an immutable reference, as lots of
   places in the code expect to be able to pass the returned value as
   `bool` (not `&bool). It would be nice if the `bool` items could
   return a copy, but the more complex types a borrowed reference... but
   unfortunately, I couldn't get the macro to do this.
 - A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding
   config items by modifying the fields of the `Config` struct directly.
   They now use the existing `override_value()` method, which has been
   modified to return a `Result` for use by `src/bin/rustfmt.rs`. This
   benefits of this are that the complex `file_lines` and `write_mode`
   strings are now parsed in one place (`Config.override_value`) instead
   of multiple. The disadvantages are that it moves the compile-time
   checks for config names to become run-time checks.
2017-05-16 15:47:09 +07:00
Seiichi Uchida
762db5138e Format source codes 2017-05-15 22:55:45 +09:00
Seiichi Uchida
7ec78711f2 Prevent rewriting closure block to expr inside macro 2017-05-13 18:32:25 +09:00
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