Commit graph

586 commits

Author SHA1 Message Date
Nick Cameron
a0e85f9a5f Put empty modules on one line
Fixes #463
2016-01-28 19:53:41 +13:00
Nick Cameron
02302d2800 Don't reformat strings if we don't have to.
Specifically if no line exceeds the allowed width and we aren't moving the string to a new offset
2016-01-28 19:14:08 +13:00
DarkDrek
feb09a42f5 Fix #784 2016-01-27 02:18:05 +01:00
Nick Cameron
4344c51c80 Merge pull request #783 from jwazny/issue-588
Added where_trailing_comma option.
2016-01-26 22:23:05 +13: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
Kevin Yeh
f01ed6f507 Format item macros 2016-01-22 13:43:18 -06:00
Nick Cameron
81516fe8ca Merge pull request #745 from markstory/checkstyle-output
RFC implementation of checkstyle output
2016-01-22 17:48:39 +13:00
Mark Story
d8c6f5954a Update checkstyle write mode to take Write arguments.
By accepting Write traits we can write tests using StringBuffer.
2016-01-19 00:23:38 -05:00
Mark Story
5632831bd1 Clean up function names for checkstyle output. 2016-01-14 22:04:24 -05: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
Mark Story
add80569ff Use PartialEq/Eq implementation instead of match.
Also cleanup from rebasing onto master.
2016-01-13 21:07:38 -05:00
Mark Story
58410ddd93 Extract checkstyle output into a separate module.
Rename functions a bit now that they are specific to checkstyle output.
2016-01-13 21:03:25 -05:00
Mark Story
3c968e1e38 Update based on pull request feedback.
* Extract duplicated logic.
* Make checkstyle errors into warnings.
2016-01-13 21:02:50 -05:00
Mark Story
de10545906 Encode XML entities. 2016-01-13 21:02:50 -05:00
Mark Story
c3632befb5 Remove unused argument. 2016-01-13 21:02:05 -05:00
Mark Story
309f284dfb Fix formatting errors. 2016-01-13 21:01:27 -05:00
Mark Story
d188854e13 Hack together checkstyle output that compiles.
I'm not sure it does something useful yet though.
2016-01-13 21:01:26 -05:00
Mark Story
0c9f27fe5e Start hacking checkstyle output in.
checkstyle now shows up on the option parser, and the code still
compiles/passes tests. Next up will be outputing the XML to stdout.
2016-01-13 20:59:18 -05:00
Victor M. Suarez
4f8938c616 Allow for setting of write-mode via config file. FIxes #215
Also from @marcusklaas:
 Refactor code output functions

 Specifically, `write_all_files` no longer returns a HashMap. It would sometimes
 contain items, and sometimes be empty. When "fixed" newlines are required, this
 must now be done with a separate call. The tests use this strategy and should now pass!
2016-01-12 18:12:48 -05:00
Marcus Klaas de Vries
ba465e0fc2 Merge pull request #766 from ConnorGBrewster/fix-#489
Added option for tighter punctuation in types. fixes #489
2016-01-12 22:52:34 +01:00
Marcus Klaas de Vries
4cefecb495 Merge pull request #768 from DarkDrek/amend-to-fix-#447
fixes parsing issue #767
2016-01-12 21:53:19 +01:00
Connor Brewster
479b69266b Changed TypeDensity::WhiteSpace to TypeDensity::Wide
Changed eq_str and plus_str assignments to use a match
2016-01-12 13:42:53 -07: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
DarkDrek
937e26d4e1 fixes parsing issue #767 2016-01-12 21:13:59 +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
DarkDrek
4da91e7df2 Handle more possible comment position for if else
Extended the test with the new possiblecomment positions
2016-01-12 03:08:48 +01:00
DarkDrek
b0eb0f5daa Keep comments between if and else blocks. Fixes #447 2016-01-12 03:08:16 +01:00
Connor Brewster
749697d845 Changed is_block_empty to has_body 2016-01-11 14:47:56 -07:00
Connor Brewster
dba2d8afd5 Added option for tighter punctuation in types. fixes #489 2016-01-11 12:26:57 -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
cassiersg
b236819f72 Merge pull request #756 from cassiersg/missed-comments
Detect (and recover) when comments disappear
2016-01-11 01:16:52 +01:00
Nick Cameron
0badc128f7 Merge pull request #740 from svmnotn/less_tmp_files
stop creating bk files if there are no changes. Fixes #733
2016-01-11 10:45:51 +13:00
Victor M. Suarez
56a3aac2b5 stop creating bk files if there are no changes. Fixes #733 2016-01-10 16:37:13 -05:00
Gaëtan Cassiers
b117d7b2b8 Document comment::*CodeCharKind 2016-01-10 22:04:30 +01:00
Gaëtan Cassiers
598fcdddc3 Fix issue with windows line endings (#717).
The '\r' character wasn't counted in the line length.
2016-01-10 16:25:31 +01:00
Gaëtan Cassiers
9f98f725cb Detect when comments disappear
When the reformatted code doesn't contain the same quantity of comments
as the original code, use the original code instead of the reformatted
code.
This is done for all expressions and `let` statements.

This should be used at the finest grained level possible, to avoid that
a small disappearing comment prevents a big chunk of code to be
reformatted.

Kind of fixes (avoid disappearing comments, but prevents a good
formatting is such case) #285 #225 #563 #743
2016-01-10 15:20:58 +01:00
Seo Sanghyeon
16b348dd9c Add commas after skipped arms when needed 2016-01-08 22:15:54 +09:00
Nick Cameron
bd32589ff5 Merge pull request #747 from Manishearth/clippy
Clippy rustfmt
2016-01-07 20:15:49 +13:00
Manish Goregaokar
ffe9c9d834 Clippy rustfmt 2016-01-07 12:17:22 +05:30
Seo Sanghyeon
f9f7235c1b Trailing commas for wildcard arms 2016-01-06 11:02:01 +09:00
Nick Cameron
d290271db4 Merge pull request #739 from svmnotn/case_insensitive_config_options
ignore case for config enums. Fixes #738
2016-01-05 07:40:03 +13:00
Victor M. Suarez
f6497ca3fb ignore case for config enums. Fixes #738 2016-01-02 20:47:58 -05:00
Sinh Pham
122fc4bc65 Fixed #700, use default color for titles and context in write-mode=diff 2016-01-01 09:14:39 -08:00
Marcus Klaas de Vries
0698f0255a Merge pull request #732 from utkarshkukreti/update-diff-to-0.1.8
Update diff to 0.1.8
2015-12-28 17:45:56 +01:00
Utkarsh Kukreti
15e6b7d335 Add tests for #606. 2015-12-28 17:23:34 +05:30
Marcus Klaas
291aa1b228 Make fn argument formatting more resilient for complex self types 2015-12-27 14:25:37 +01:00
Nick Cameron
71508b310b Merge pull request #728 from marcusklaas/typed-mut-self
format typed mut self
2015-12-27 09:18:20 +13: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
1e80fd2dcd Prevent incorrect backslash removal in strings 2015-12-25 18:50:40 +01:00
Aleksey Kladov
a70b621607 add option to ignore out of line modules 2015-12-23 17:25:49 +03:00
Jan Likar
a5da67f4c4 Add verbose and quiet flags to cargo-fmt
Quiet mode supresses rustfmt's stdout, verbose mode prints targets that
are going to be formatted.
2015-12-20 04:19:08 +01:00
Nick Cameron
0b5e6d57e5 Merge pull request #710 from JanLikar/master
Remove `--write-mode=replace` from cargo-fmt
2015-12-18 08:43:41 +13:00
Jan Likar
c578ad8df5 Remove --write-mode=replace from cargo-fmt
Since replace is the default rustfmt write mode, there's no need to
call rustfmt with `--write-mode=replace`. As a bonus, it is now also
possible to override the write-mode.
2015-12-17 17:17:43 +01:00
Sean Marshallsay
7f21569351 Fix spelling mistake in cargo-fmt usage string. 2015-12-16 12:18:18 +00:00
Nick Cameron
ecf12778fb Use replace rather than overwrite for cargo fmt 2015-12-16 18:07:59 +13:00
Jan Likar
1e5e290e39 Allow to pass arguments to rustfmt 2015-12-16 04:48:49 +01:00
Jan Likar
360f3efce8 Replace locate-project with read-manifest
Use `cargo read-manifest` instead of `cargo locate-project` to get
a list of files to be formatted.
2015-12-16 02:21:43 +01:00
Jan Likar
623277e7e0 Add cargo-fmt binary
Add a new utility, which formats all readable .rs files in the src
directory of the crate using rustfmt. Both binaries can be installed
using cargo install rustfmt. cargo-fmt can be used as a Cargo
subcommand - cargo fmt.
2015-12-14 15:50:19 +01:00
Nick Cameron
8983037db6 Merge pull request #695 from marcusklaas/string-rewrite-backslash
Prevent backslash stripping in string literals
2015-12-14 07:50:56 +13:00
Marcus Klaas
8cccf45d43 Prevent backslash stripping in string literals 2015-12-12 16:25:01 +01:00
Marcus Klaas
2636fed5f3 Don't panic on function return type rewrite failure 2015-12-12 15:41:10 +01:00
Nick Cameron
f8cb1baadd Add normalise_comments option.
So block comments are not converted to line comments
2015-12-10 09:29:03 +13:00
Nick Cameron
e94bd34a06 cargo upgrade, bug fix, and prepare for packaging 2015-12-08 16:19:23 +13: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
db72e0390c Merge pull request #664 from marcusklaas/fix-reformat-failurez
Don't include failed item rewrites in missed spans
2015-12-07 08:33:02 +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
Nick Cameron
26297c56df Merge pull request #615 from JanLikar/version
Add --version switch
2015-12-07 07:32:16 +13:00
Marcus Klaas
97e4e7e5ba Fixed named arguments in bare function types 2015-12-06 01:11:26 +01:00
Marcus Klaas de Vries
22353ca8c7 Merge pull request #674 from Ms2ger/start
Use starts_with to avoid panics.
2015-12-04 16:37:59 +01:00
Ms2ger
1ed36a3a6b Use starts_with to avoid panics. 2015-12-04 16:10:14 +01:00
Manish Goregaokar
f61ba91c2d Minor clippy fixes 2015-12-04 18:02:19 +05:30
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 de Vries
e677f05805 Merge pull request #659 from Marwes/where_clause
Fix where clauses not taking the width of the line into account
2015-12-02 19:06:24 +01:00
Bryce Van Dyk
74d40c042f Update block checking code 2015-12-02 16:44:40 +13: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
Bryce Van Dyk
7ce887abcf Update trailing comma match logic, add tests
Updates the traling comma code to attempt to handle multiline non-block bodies when
adding traling commas to blocks. Also add and update tests to cover better
the interactions between trailing commas and wrapping match arms.
2015-12-01 20:10:57 +13:00
Marcus Klaas
0fb9611786 Don't include failed item rewrites in missed spans 2015-11-30 23:12:50 +01:00
Bryce Van Dyk
2a430a8947 Trailing commas for match block arms
Attempt to implement an option for trailing commas for block based match arms (issue
173). Put in place test files to verify this behaviour.
2015-11-30 21:51:20 +13: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
Seo Sanghyeon
17c8fb10ea Remove unused imports 2015-11-27 23:38:05 +09: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
Kevin Yeh
314aff1a33 Reformat trim_newlines 2015-11-25 22:46:11 -06:00
Seo Sanghyeon
2b11d84119 Apply Clippy 2015-11-25 15:39:15 +09:00
Kevin Yeh
f5fac4c54f Fix empty trim_newline panic, add impl macro test 2015-11-24 14:37:31 -06: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
Jakko Sikkar
411fa40988 update dependencies and fix compile errors 2015-11-23 20:54:33 +02:00
Nick Cameron
2661592d59 Handle multiply-referenced files
Fixes #645
2015-11-23 15:22:00 +13: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
e3f39941de Types which can be return types for function types
Fixes #643
2015-11-23 13:55:53 +13:00
Nick Cameron
b577f95e3c Reformatting due to changes 2015-11-23 13:09:00 +13:00
Nick Cameron
9cf8529e33 Implement formatting for impls
Fixes #614
2015-11-23 13:09:00 +13:00