Commit graph

2318 commits

Author SHA1 Message Date
Nick Cameron
920a50ded9 Refactoring: return a summary from format_project
Rather than modifying `self.summary`.

Also move some Timer methods.
2018-07-24 09:07:54 +12:00
Nick Cameron
069c4fc508 Refactoring: summary
Move the timer from Summary to Session.

Move Summary from config to formatting.
2018-07-24 08:43:30 +12:00
Nick Cameron
09a8c6d22b Refactoring: move code around in formatting
To try and make cleaner abstractions and to start to separate formatting from
other tasks.
2018-07-24 08:26:33 +12:00
Nick Cameron
71d3d04270 factor out a Session object 2018-07-23 15:37:34 +12:00
Nick Cameron
4153e66e42 Move non-public API from lib.rs to its own module 2018-07-23 12:45:41 +12:00
Nick Cameron
bcb64fdab8
Merge pull request #2853 from nrc/match-comment
Handle missing comments in match arm and more generally
2018-07-20 22:20:35 +12:00
Seiichi Uchida
d40ed146a5 Fix breaking changes
cc https://github.com/rust-lang/rust/pull/51829.
2018-07-20 16:18:45 +09:00
Nick Cameron
b085113cbe Trigger an internal error if we skip formatting due to a lost comment 2018-07-20 16:05:19 +12:00
Nick Cameron
6899471497 Check for comments after the => in a match arm
Closes #2188
2018-07-20 16:05:18 +12:00
Nick Cameron
90c5792565 Set rustfmt-format_macro_matchers to false by default
cc #2543
2018-07-18 12:09:50 +12:00
Nick Cameron
79c5ee8b42 Add config options for formatting macro matchers and bodies
Closes #2753
2018-07-18 12:03:59 +12:00
Nick Cameron
b27d544478 replace_with_system_newlines doesn't need to be public 2018-07-18 09:16:51 +12:00
Michael Bebenita
c2ae39e77a Add max_width option for all heuristics.
This is useful when working with very small max_widths like 79 chars.
2018-07-17 13:17:36 -04:00
Nick Cameron
b28a0cd6e6 Fix an anomaly with comments and array literals
Closes #2842
2018-07-17 15:40:19 +12:00
Nick Cameron
d911b640d1
Merge pull request #2823 from fwalch/default-newline-style
Change default newline style to "Native"
2018-07-17 11:18:10 +12:00
Stéphane Campinas
86018133a0
removed unused max_width argument of rewrite_string function 2018-07-14 19:33:26 +02:00
Stéphane Campinas
472a2ed0f6
fix rewrite_string when a line feed is present in a sequence of whitespaces, resulting in strange formatting 2018-07-14 19:22:31 +02:00
Nick Cameron
229a55248b address reviewer comments 2018-07-12 22:21:07 +12:00
Nick Cameron
486f8fd8e7 Fixup formatting of tests and source 2018-07-12 21:37:28 +12:00
Nick Cameron
a4cdb68925 Improve formatting of series of binop expressions
This commit changes the handling of binops (and potentially other pairs), where
the expressions are logically a list, e.g., `a + b + c`. It makes the single
line vs multi-line approaches explicit and introduces a lowering step.

This improves formatting in a number of places, mostly improving consistency of
formatting with very short sub-expressions, but also some weird indentation.

Closes #2802
2018-07-12 21:37:28 +12:00
Nick Cameron
b68fd9e6bf Move pair handling to its own module 2018-07-12 21:37:28 +12:00
Nick Cameron
b6ea973d19 Factor out PairParts::infix 2018-07-12 21:37:28 +12:00
Seiichi Uchida
60ce411b53 Format async closure 2018-07-09 23:20:53 +09:00
Eric Huss
800e488de8 Fix help for --help=file-lines
Due to the way getopts works, it requires the equals sign.
2018-07-05 22:50:23 -07:00
Florian Walch
363363d066 test: Assert CRLF line endings on Windows 2018-07-02 23:43:59 +02:00
Florian Walch
9d8f3812cc Change default newline style to "Native"
Fixes #2626.
2018-07-02 23:16:17 +02:00
Nick Cameron
5e5992517d Update rustc-ap-syntax 2018-07-02 09:34:55 +12:00
Nick Cameron
d5cb93216b
Merge pull request #2822 from topecongiro/issue-2782
Avoid panicking on deeply nested expressions
2018-07-01 14:38:30 +12:00
topecongiro
ebb1626264 Flatten multiple empty blocks at once 2018-07-01 10:51:36 +09:00
topecongiro
54af8b578e Factor out block_can_be_flattened 2018-07-01 10:49:05 +09:00
topecongiro
e7c6c29562 Avoid panicking on deeply nested expressions 2018-07-01 10:46:32 +09:00
topecongiro
5a3640da69 Return the trimmed original snippet when formatting macro def failed 2018-07-01 09:59:53 +09:00
Nick Cameron
888abbb0ec
Merge pull request #2820 from scampi/defaults
[wip] remove some defaults
2018-07-01 10:57:31 +12:00
Stéphane Campinas
f7a25a1177
warn on use of default value for an option 2018-06-30 17:03:18 +02:00
topecongiro
57a6cae49f Fix span bug when searching for the closing paren 2018-06-30 19:21:15 +09:00
topecongiro
bc16d8864a Fix compile error from breaking changes in libsyntax 2018-06-30 15:53:28 +09:00
Seiichi Uchida
cc2afeca9e Fix compile errors from breaking changes 2018-06-28 16:26:10 +09:00
Nick Cameron
3abebf95ce Apply short function call heuristic to attributes
Closes #2620
2018-06-26 15:18:17 +12:00
Nick Cameron
42f03458dd Refactor and fixup attribute formatting
Preserves trailing commas (except in derives where we follow function args).
Correctly uses `#` vs `#!` for derives.
Uses block indent for derives, fixes #2805.
2018-06-26 15:18:17 +12:00
Nick Cameron
be4d37da4b Indent a match guard if the pattern is multiline
Closes #2377
2018-06-26 15:18:17 +12:00
Seiichi Uchida
3027c21371 Handle raw identifiers 2018-06-25 23:36:45 +09:00
Nick Cameron
ca1c13a896
Merge pull request #2804 from Mike-Baker/mb-strip-vert-in-match-arms
Strip leading `|` in match arm patterns
2018-06-25 21:02:24 +12:00
topecongiro
e5e1e0cea8 Fix compile errors from breaking changes in libsyntax
cc https://github.com/rust-lang/rust/pull/48149.
2018-06-25 15:24:00 +09:00
Mike Baker
1d4b988414 Strip leading | in match arm patterns
This addresses issue #2621

This commit turns out to be a partial revert of
ea3c01e337

The rationale is that a `|` character preceding a match pattern is not
semantically relevant and therefore should be considered a
style/formatting choice.

A discussion concluded that the best way to emit consistent formatting
here was to strip the leading `|`

This removes the match_with_beginning_vert test because it was asserting
the old behaviour which has been changed, it adds a new test
(issue_2621) which should be a more comprehensive check of the behavior
of `|` in match arms.

Discussion at https://github.com/rust-lang-nursery/fmt-rfcs/issues/119
2018-06-25 00:53:15 +01:00
Nick Cameron
87edd75ecf TODO -> FIXME
Or just delete

Closes #25
2018-06-22 14:42:27 +12:00
Nick Cameron
1ead31ae9d
Merge pull request #2795 from jechase/issue-2794
Add test and fix for #2794
2018-06-20 10:35:16 +12:00
Nick Cameron
fb5513564e
Merge pull request #2785 from wada314/issue-2728
Fix #2728.
2018-06-20 10:32:46 +12:00
Josh Chase
ee5ff2d9e8 Add flag to the ListFormatting struct for nested imports 2018-06-19 12:13:35 -04:00
Josh Chase
2077855e00 Remove NestedImport tactic 2018-06-19 12:13:26 -04:00
Shohei Wada
036244cdce Fix #2728. 2018-06-19 20:51:49 +09:00