Commit graph

3721 commits

Author SHA1 Message Date
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
070ae8ab5c update integration tests 2018-07-23 10:04:07 +12:00
Nick Cameron
b3cf8c1474
Merge pull request #2856 from snsmac/patch-1
Update Readme.md
2018-07-23 08:29:08 +12:00
jr
9c6a53053b
Update Readme.md
Use "rustfmt --print-config default rustfmt.toml" instead of "rustfmt --dump-default-config rustfmt.toml" to create default config
2018-07-22 13:00:33 +02: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
Nick Cameron
b3aa671d71 Allow futures integration test to fail 2018-07-20 22:19:08 +12:00
Nick Cameron
d7bc9b50da
Merge pull request #2854 from topecongiro/rustc-ap-syntax
Update rustc-ap-*
2018-07-20 22:18:03 +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
Seiichi Uchida
52f9f7bbe2 Cargo update 2018-07-20 16:05:18 +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
aa61bd5c1a Update integration tests 2018-07-18 13:02:23 +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
Nick Cameron
1b0efd99e6
Merge pull request #2847 from mbebenita/max-width
Add max_width option for all heuristics.
2018-07-18 09:06:26 +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
9038da6df0
Merge pull request #2790 from DevOrc/master
add emit flag documentation
2018-07-17 11:21:00 +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
Nick Cameron
ca57ff5b76 Fix Configurations.md
Correct default for `imports_indent`

Closes #2839
2018-07-17 10:45:30 +12:00
Seiichi Uchida
48c3e46cf1
Merge pull request #2829 from scampi/issue1210
fix rewrite_string when a line feed is present in a sequence of whitespaces, resulting in strange formatting
2018-07-16 16:07:05 +09: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
Seiichi Uchida
e110d95f53 0.8.3 2018-07-14 22:18:12 +09:00
Seiichi Uchida
12775ed978
Cargo update (#2845) 2018-07-14 22:16:23 +09:00