Nick Cameron
3c20d8a9e6
Merge pull request #2874 from cavedweller/master
...
Format Async block and async fn
2018-07-31 08:52:07 +12:00
Benjamin Brittain
46b241004d
fix nits
2018-07-29 17:20:21 -07:00
Ben Brittain
fedde3790c
Add tests for async & async move
2018-07-29 08:55:36 -07:00
Ben Brittain
0b25f602fd
Format Async block and async fn
2018-07-29 08:05:38 -07:00
Aaron Loucks
6ff2a5e0f3
Auto-detect newline style by default
2018-07-29 10:12:31 -04:00
Andrew Audibert
f121b1a3a9
Support raw identifiers in struct expressions
2018-07-28 19:40:52 -07:00
Nick Cameron
69ad879d52
Merge pull request #2864 from topecongiro/issue-2863
...
Modify the rule for reordering impl items
2018-07-27 16:24:46 +12:00
Nick Cameron
814f6339b4
Merge pull request #2862 from topecongiro/issue-2852
...
Preserve parens in trait bounds
2018-07-27 16:24:11 +12:00
Seiichi Uchida
7b37776ade
Modify the rule for reordering impl items
...
1. If two items have the same kind, then reorder them based on its ident.
2. Handle existential type.
2018-07-26 21:37:23 +09:00
Seiichi Uchida
e6255ca3de
Preserve parens in trait bounds
2018-07-25 18:27:25 +09:00
Nick Cameron
8ff2836eaf
Merge pull request #2861 from topecongiro/issue-2859
...
Put lifetimes after trait when they gets orphaned
2018-07-25 21:22:25 +12:00
Seiichi Uchida
339fa20973
Veto converting delimiters inside nested macro
2018-07-25 08:58:37 +09:00
Seiichi Uchida
6cecdd681f
Put lifetimes after trait when they gets orphaned
2018-07-25 08:44:32 +09:00
Seiichi Uchida
975b3753ba
Keep the inside macro context in nested macro call
2018-07-25 07:15:33 +09:00
Seiichi Uchida
6d7a764b3d
Remove span from rewrite_generics's parameter
...
We can just use the span from ast::Generics.
2018-07-25 00:34:46 +09:00
Seiichi Uchida
fc307ff582
Format exitential type
2018-07-25 00:30:01 +09:00
Nick Cameron
43f178bd58
Remove Summary
2018-07-24 21:45:15 +12:00
Nick Cameron
df4fb8a05b
Reformatting after rebase
2018-07-24 15:49:35 +12:00
Nick Cameron
f9510a55eb
chains: fix visual indent chain layout
2018-07-24 15:46:39 +12:00
Nick Cameron
8618a55834
chains: treat some string lits as blocks
2018-07-24 15:46:39 +12:00
Nick Cameron
481e85cc58
formatting
2018-07-24 15:46:39 +12:00
Nick Cameron
f0fe9c3c4a
chains: prefer to use the next line for an expression, if using the same line would introduce an open block or similar
...
This problem came to light due to the chains changes, but effects other code too. It only happens rarely, e.g.,
before this fix:
```
match foo {
MacroArgKind::Delimited(ref delim_tok, ref args) => rewrite_delimited_inner(
delim_tok,
args,
).map(|(lhs, inner, rhs)| format!("{}{}{}", lhs, inner, rhs)),
};
```
after:
```
match foo {
MacroArgKind::Delimited(ref delim_tok, ref args) => {
rewrite_delimited_inner(delim_tok, args)
.map(|(lhs, inner, rhs)| format!("{}{}{}", lhs, inner, rhs))
}
}
```
2018-07-24 15:43:29 +12:00
Nick Cameron
5bc27593f4
chains: minor fixups
...
* remove unnecessary clone
* comment formatting
* fix bug with `?` collection
* respect the heuristic if the root is more than just the parent
2018-07-24 15:43:29 +12:00
Nick Cameron
467b095d48
chains: share code between block and visual formatters
2018-07-24 15:43:29 +12:00
Nick Cameron
f55cadb65a
chains: refactor formatting of chain items
2018-07-24 15:43:29 +12:00
Nick Cameron
a56ff9d02f
chains: factor into objects
2018-07-24 15:43:29 +12:00
Nick Cameron
86314bf09f
chains: more refactoring of visual formatting
2018-07-24 15:43:29 +12:00
Nick Cameron
92701552bc
chains: refactor block formatting
2018-07-24 15:43:29 +12:00
Nick Cameron
914e750c9e
chains: further simplification
2018-07-24 15:43:29 +12:00
Nick Cameron
38e8b086e8
chains: refactoring
...
pre-process the expression tree to get a list of chain items.
2018-07-24 15:43:29 +12:00
Nick Cameron
9c82224746
chains: simplify visual formatting a bit
2018-07-24 15:43:29 +12:00
Nick Cameron
d244234607
factor out treatment of 1-length chains
...
And create `Chain` and `ChainItem` structs
2018-07-24 15:43:29 +12:00
Nick Cameron
a8d5f25572
chains: split handling of chains in block and visual cases
...
Just refactoring, lots of code dup here, but it should get better...
2018-07-24 15:43:29 +12:00
Nick Cameron
728b0182c5
Changes to chains with block indent
...
* More often combine a chain item to the previous line (if it is a block)
* Don't indent if the parent is a block
This is not perfect and doesn't pass tests, but I need to refactor to make more
progress
2018-07-24 15:43:29 +12:00
Nick Cameron
d3288841ea
Refactoring: factor format_lines
and format_project
into smaller chunks
2018-07-24 15:17:47 +12:00
Nick Cameron
9fbce1f627
Reorganise formatting.rs
2018-07-24 14:10:09 +12:00
Nick Cameron
2af1ed109c
Refactoring: factor out format_file
and FormatHandler
...
This effectively separates out formatting from other handling.
2018-07-24 14:05:04 +12:00
Nick Cameron
b9c6754d8c
Refactoring: move format_project
and Timer
out of Session
2018-07-24 10:08:41 +12:00
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
Nick Cameron
488e6fda12
Remove some unnecessary pub
s
2018-06-19 14:36:50 +12:00
Nick Cameron
261238ea51
Change use_small_heuristics
to an enum and stabilise
...
Since it is now an enum, we can be future compatible since we can add variants
for different heuristics.
Closes #1974
2018-06-19 13:28:27 +12:00
Seiichi Uchida
0ec1533054
Merge pull request #2779 from thibaultdelor/stableApi
...
Improve end lines handling
2018-06-11 11:38:26 +09:00
Tibo Delor
2e90c4314c
Stop delaying Trailing whitespace error reporting
2018-06-10 14:19:09 +10:00
Tibo Delor
42efae5944
Clean Up code where last whitspace tracking isn't used
2018-06-10 14:07:33 +10:00
Tibo Delor
6b00b8b302
Move newline logic inside the formatting process.
...
Why?:
- Conceptually it sounds right
- Absolutely all write modes where doing it anyway
- It was done several times in some in case
- It greatly simplify the code
2018-06-10 00:25:47 +10:00
Tibo Delor
8c32a9d909
Parse Error return an Error instead of a successful empty response
2018-06-10 00:25:06 +10:00
Nick Cameron
34067a1c4c
Merge pull request #2775 from topecongiro/macro-def-with-complex-macro
...
Change format_snippet to return None when it has failed to format macro call
2018-06-08 08:50:35 +12:00
Seiichi Uchida
19054347ca
Fix test failures
2018-06-07 15:20:01 +09:00
Seiichi Uchida
c95fa8cbe2
Return None when the formatting of macro failed in format_snippet
2018-06-07 12:33:33 +09:00
Seiichi Uchida
d1477ca1de
Add a field in Summary for notiyfing about formatting failure of macro
2018-06-07 12:32:58 +09:00
Seiichi Uchida
94e68b1eb6
Set the flag in RewriteContext when rewriting macro call failed
2018-06-07 12:32:10 +09:00