Commit graph

767 commits

Author SHA1 Message Date
Nick Cameron
8494d5f89c Merge pull request #1200 from efyang/strayspace
Remove extra whitespace after macro calls
2016-10-28 09:14:37 +13:00
Edward Yang
5ecdd072d6 Remove extra whitespace after macro calls 2016-10-27 02:40:08 -05:00
Edward Yang
1c83c76015 Stop extra newlines from being added after block comments (#1185) 2016-10-25 08:45:15 +13:00
Mikko Rantanen
4b1c669037 Add spaces_within_square_brackets config option. (#1191)
* Add spaces_within_square_brackets config option.

Enabling the config enforces spaces within various array/slice brackets.

* Fixed budget-calculations for [] spacing
2016-10-18 09:09:49 +13:00
Nick Cameron
23f01eddac Merge pull request #1188 from Rantanen/master
Add support for spaces_within_angle_brackets
2016-10-14 11:38:39 +13:00
Josh Chase
903e30b503 Quick fix for "impl Trait"
* Remove "TODO" conversion
* Add a couple of simple test cases

Fix courtesy of @signaraiona
2016-10-13 12:30:16 -07: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
Philip Craig
c4a7a7108e Preserve macro formatting if we can't rewrite it 2016-10-03 14:14:56 +10:00
Florian Gilcher
b8f7ec3dcc Add custom comments (#1179)
* Add custom comments

This allows users to use custom comments such as

```
//@ this is a custom comment
//@ with multiple lines
```

without having them destroyed by rustfmt.

* Fix issues with empty lines

* Check non-whitespace right after custom comments
2016-09-30 08:34:46 +13:00
nokaa
8a9dfc5ede Fix broken import 2016-09-27 12:38:17 -05:00
Nick Cameron
77ceba2bc0 Write to the supplied buffer if one is supplied to format_input 2016-09-27 17:25:54 +13:00
sinkuu
2dfa96bc9a Fix #775
rewrite_tuple referring config.max_width where given width should be
used
2016-09-20 14:06:28 +09: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
Nick Cameron
e1d7b8ea01 Merge pull request #1162 from sinkuu/fix1040
Fix #1040
2016-09-19 14:35:42 +12:00
Nick Cameron
fb8a1903cf Merge pull request #1161 from sinkuu/fix550
Fix #550: `if` nested in tuple is indented oddly
2016-09-19 08:49:38 +12:00
sinkuu
b6bffa6596 Prevent line breaking at = or in after trivial patterns 2016-09-17 13:03:14 +09:00
sinkuu
079f39d07f Fix #550: if nested in tuple is indented oddly 2016-09-17 10:46:20 +09:00
est31
c6243c950e Improve comment rewriting with normalize_comments == false
Only change multiline comments of the form

```rust
/*
 * Text
 */
```

while not affecting comments of the form

```rust
/*
Text
*/
```

when normalize_comments is off. In the first case,
we have a known character we can align against, while
we don't have one in the second case.

Before, we have converted the second form into the first,
but this is against the spirit of normalize_comments being
turned off.

Fixes #956
2016-09-17 03:41:11 +02: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
sinkuu
b446e31739 Fix #1040 2016-09-10 13:08:32 +09:00
sinkuu
bf078566d7 Fix #1021: Handle .. in tuple / tuple struct patterns 2016-09-09 19:56:34 +09: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
Nick Cameron
bce26d51bd Merge pull request #1134 from sinkuu/issue977
Fix #977
2016-08-29 07:07:48 +12:00
sinkuu
130c593544 Fix #977 2016-08-28 16:40:03 +09:00
Kamal Marhubi
05882314f5 Check term supports colour before printing fancy diffs
For a terminal like DUMB, we were still attempting to print colourful
diffs, which failed with a `NotSupported` error.

Fixes #1140
2016-08-26 17:08:47 -04: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
Nick Cameron
e1759ae295 Merge pull request #1123 from juicejitsu/807
Don't emit filename in diff mode, add filename to diff metadata
2016-08-10 21:52:46 +12:00
Stuart Dootson
4029b0e704 Fix #1120 - rework how the use list prefix is determined. (#1121)
* Fix #1120 - rework how the use list prefix is determined.

* Added test commentary & another test case
2016-08-10 18:13:27 +12:00
juicejitsu
a0de408198 Don't emit filename in diff mode, add filename to diff metadata 2016-08-09 18:21:04 -07:00
Nick Cameron
69f647b9f1 Merge pull request #1119 from HighCommander4/issue1109b
Apply space_before_type_annotation to struct ctors (#1109)
2016-08-05 18:03:34 +12:00
Nathan Ridge
899169a1d2 Apply space_before_type_annotation to struct ctors (#1109) 2016-08-05 01:30:53 -04:00
Nick Cameron
f21808a65c Merge pull request #1117 from pepyakin/issue-1116
Fix underflow in format_imports
2016-08-05 16:29:41 +12:00
Sergey Pepyakin
f6959a4772 Fix issue-1116 2016-08-04 08:54:40 +03: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
Julien Blanchard
b4e49ddbf5 Fix imports with absolute paths 2016-08-01 10:10:04 +02: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
Daniel Campoverde
6380937b59 Multiple config file names feature (#1101)
* Add multiple configuration file names feature

* Add '.rustfmt.toml' in README file

* Clean up configuration file code

* Make config file names constant

* Use only one blank line
2016-08-01 09:32:35 +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
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
Stuart Dootson
9750fb7fca Canonicalize file paths within the map of file line ranges (#1098)
* Canonicalize file paths within the map of file line ranges

* Forgot to run the tests - and of course, the formatting of the canonicalization change was off, but it's fixed now!

* Move imports to the top of the file, as per @nrc.

* Change `canonicalize_path_string` to return `Option<String>`, `None` indicating an error rather than an empty string

* `format!` is better than string concatenation...

* Change `canonicalize_path_string` to return `Result` rather than `Option`
2016-07-19 09:05:01 +12:00
sinkuu
0dc3fc7a2c Fix formatting empty block comments (/**/)
issue #1086
2016-07-09 22:56:50 +09:00
Nick Cameron
ffa5a22d1c Merge pull request #1084 from johannhof/rustfmt-not-found
Show more helpful error if rustfmt is not in PATH.
2016-07-04 21:30:52 +12:00
Johann Hofmann
033741246c
Show more helpful error if rustfmt is not in PATH.
This fixes #1071.
2016-07-04 07:42:18 +02:00
Nick Cameron
ddda46d265 rustup 2016-07-04 15:46:58 +12:00
Johann Hofmann
8260d277c8
Return failure exit code on found diffs (fix #906)
This changes rustfmt to return exit code 4
when run with write mode diff and differences between
the formatted code and the original code are found.

Useful for CI to make sure your contributors actually ran rustfmt.
2016-06-21 23:01:15 +02:00