Commit graph

2069 commits

Author SHA1 Message Date
Seiichi Uchida
eaab51db2e Break after colon if static item does not fit in a single line 2018-01-10 23:23:42 +09:00
Seiichi Uchida
949708f617 Use correct BytePos when recovering comments on removed import 2018-01-10 21:30:41 +09:00
Seiichi Uchida
cb0b366b38 Cargo fmt 2018-01-10 17:17:06 +09:00
Seiichi Uchida
590857db37 Reformat a nested function call with a single newline using larger budget 2018-01-10 17:15:02 +09:00
David Alber
d981fb89c0 Removing unused name 2018-01-09 19:56:46 -08:00
David Alber
85ccb98469 Adding test to verify code block idempotency in Configurations.md 2018-01-04 00:01:18 -08:00
Nick Cameron
91a332483b
Merge pull request #2316 from topecongiro/issue-2315
Remove trailing comma from extern items snippet before comparing
2018-01-04 17:49:47 +13:00
Vishal Sodani
3345b00952 Fix #2300 2018-01-04 09:50:45 +05:30
topecongiro
405360a3fd Refactoring: use methods from libsyntax attr module 2018-01-04 12:49:37 +09:00
topecongiro
75cb236711 Compare extern crate items with its name instead of span
When we use span, bugs easily sneak in.
2018-01-04 12:49:37 +09:00
topecongiro
19d6a3c786 Put the opening brace of impl on the next line
We put the opening brace on the next line if the following conditions hold:

1. the result before '{' ends with comments or contains newline
2. the last line of the result before '{' is not extendable (i.e. consists of
   '>' and whitespaces).
2018-01-04 12:46:55 +09:00
topecongiro
c355f3854c Use correct budget when rewriting generics of trait 2018-01-04 12:46:05 +09:00
Nick Cameron
0f24bc0d44
Merge pull request #2330 from topecongiro/issue-2329
Issue 2329
2018-01-04 15:07:05 +13:00
Seiichi Uchida
d3c2523c32
Merge pull request #2335 from Hopman/rename_git-fmt
Rename git-fmt to git-rustfmt
2018-01-04 10:32:43 +09:00
Nick Cameron
9368de276c
Merge pull request #2327 from nrc/macro-defs
Some macros 2.0 macro defs
2018-01-04 14:02:37 +13:00
Nick Cameron
e52b383a57
Merge pull request #2306 from dtwood/assert-eq-on-one-line
Add assert_eq! to special-cased macros
2018-01-04 13:42:24 +13:00
Joost Hopmans
361a30b159 Rename git-fmt to git-rustfmt 2018-01-03 14:15:45 +01:00
Nick Cameron
aa758d671f Better handling of comments in macro defs 2018-01-03 20:36:52 +13:00
topecongiro
12ddaf93e2 Remove trim_newlines()
We call `trim_newlines()` after the `trim()`ed buffer, which is unnecessary.
2018-01-02 13:04:39 +09:00
Nick Cameron
f86f6dcd9c Format some macros 2.0 macro defs
cc #1539
2018-01-01 19:51:54 +13:00
David Wood
39e2f43f91 Split assert_eq! if any arguments are not simple 2017-12-27 21:19:42 +00:00
Nick Cameron
e95541c7d2 Make the import of Config pub 2017-12-28 10:08:27 +13:00
Marcus Klaas
656edbf0f0 Use std time 2017-12-27 16:34:09 +13:00
Marcus Klaas
dc356ffef7 Add rudimentary timing of parsing and formatting phases 2017-12-27 16:33:21 +13:00
Nick Cameron
9feb4988f2
Merge pull request #2310 from topecongiro/issue-2309
Do not give up rewriting struct field when attribute is long
2017-12-27 14:12:45 +13:00
Nick Cameron
a6244c2f58
Merge pull request #2311 from topecongiro/format-code-block
Format code block in comment
2017-12-27 13:32:14 +13:00
Seiichi Uchida
4604fea0a0 Refactoring
1. Cargo clippy
2. Run 'cargo fmt' with import reordering options set to `true`.
3. Factor out `rewrite_lifetime_param()`.
2017-12-25 00:13:59 +09:00
Seiichi Uchida
27167cbbaa Format code block in comment
Closes #554.
Closes #1695.
2017-12-24 23:56:51 +09:00
David Wood
212a8a3c29 Slightly simplify write_list for DefinitiveListTactic::SpecialMacro 2017-12-24 12:29:54 +00:00
David Wood
0291331203 Add documentation to expr::SPECIAL_MACRO_WHITELIST 2017-12-24 12:27:07 +00:00
David Wood
3320b400ae Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt 2017-12-24 12:01:59 +00:00
Seiichi Uchida
f523ec58ab Do not give up rewriting struct field when attribute is long 2017-12-24 13:57:29 +09:00
Seiichi Uchida
939a6c5820 Get rid of GenericsArg wrapper type
`GenericsArg` is basically identical to `ast::GenericParam`.
Just use the latter.
2017-12-24 00:29:59 +09:00
Seiichi Uchida
1ef6bccea3 Cargo fmt
Run 'cargo fmt' with the following setting:

```
reorder_imports = true
reorder_imports_in_group = true
```
2017-12-24 00:28:58 +09:00
Seiichi Uchida
0ef2b99b74 Remove workspace membership check 2017-12-23 12:24:58 +09:00
Seiichi Uchida
02bb1c8c97 Rustup to rustc 1.24.0-nightly (5165ee9e2 2017-12-22) 2017-12-23 11:58:19 +09:00
David Wood
ef8b2efd13 Fix off-by-one error in assert_eq! line wrapping
If two really long conditions are checked for equality, they wouldn't be split
into multiple lines if the last condition is the one to push the line past the
width limit.

Fix the off-by-one error that caused this, and add a test-case for it.
2017-12-23 01:32:55 +00:00
David Wood
e343521276 Add assert_eq! to special-cased macros
Allows for this form of assert_eq! macros:
```rust
assert_eq!(
    left.id, right.id,
    "IDs are not equal: {:?} {:?}",
    left, right
);
```

Also allows for assert! macros to have the format arguments split across
multiple lines even if the assert condition is not simple:
```rust
assert!(
    result >= 42,
    "The result must be at least 42: {:?}",
    result, result.code, context
);
```
2017-12-23 01:06:17 +00:00
Nick Cameron
5725f41974
Merge pull request #2298 from davidalber/fix-2269
Adding --version to cargo-fmt
2017-12-22 21:55:07 +13:00
topecongiro
984ac100a4 Fix indent width bug when recovering comments
Using last_line_width() ignores the width of tab character ('\t').
2017-12-22 12:05:36 +09:00
Nick Cameron
de5683cf11 fix tests 2017-12-22 15:30:45 +13:00
Bastian Köcher
fa67631b32 Fixes compilation with rust version 2017-12-21 2017-12-22 02:52:22 +01:00
Nick Cameron
723b938057
Merge pull request #2291 from topecongiro/issue-2289
Take the width of block's prefix into account only once
2017-12-22 12:58:02 +13:00
Nick Cameron
23dfa827a7
Merge pull request #2295 from topecongiro/issue-2280
Make 'cargo fmt' formats every workspace member
2017-12-22 12:56:53 +13:00
Nick Cameron
72413c55b0 fix libsyntax fallout 2017-12-22 11:30:54 +13:00
David Alber
09d0ca4892 Using common execute rustfmt function 2017-12-20 23:24:28 -08:00
David Alber
f17556966c Reusing status-handling function 2017-12-20 22:36:36 -08:00
David Alber
655022c42b Factoring out status code values 2017-12-20 21:53:33 -08:00
David Alber
6aaed5b08f Adding --version option to cargo-fmt 2017-12-20 21:48:59 -08:00
topecongiro
1d8619d49a Fix wrong indentation on type alias
Use rewrite_assign_rhs() when rewriting type alias.
2017-12-21 09:58:13 +09:00
Seiichi Uchida
85ef4638b6 Make 'cargo fmt' formats every workspace member 2017-12-20 22:47:51 +09:00
topecongiro
366ff40ae7 Take the width of block's prefix into account only once 2017-12-20 15:44:11 +09:00
Seiichi Uchida
ccc487ade7 Do not put comment's line start and closer on the same line 2017-12-17 15:25:24 +09:00
Seiichi Uchida
81eb88c4c0 Respect leading whitespace in original comment when wrapping comment 2017-12-17 15:24:49 +09:00
topecongiro
3a98b5a5be Format trait aliases 2017-12-15 13:47:52 +09:00
topecongiro
d60c2ec5d3 Add an initial support for trait aliases 2017-12-15 10:35:07 +09:00
Oliver Schneider
fad903fd14 Move from String to PathBuf where applicable 2017-12-15 10:26:19 +09:00
Nick Cameron
4ee7911f4b
Merge pull request #2271 from topecongiro/refactorings
Refactorings from cargo clippy etc.
2017-12-15 08:53:48 +13:00
Seiichi Uchida
7229b26f14 Do not print to stderr when parsing the toml file succeeded 2017-12-12 14:10:31 +09:00
Seiichi Uchida
efb68ee21a Refactor write_snippet_inner() 2017-12-12 13:48:24 +09:00
Seiichi Uchida
516f15aba1 Cargo clippy 2017-12-12 13:48:12 +09:00
topecongiro
17154c30cb Warn when there are unknown config options 2017-12-12 00:54:55 +09:00
topecongiro
32804c1f09 Do not print usage when rustfmt failed 2017-12-12 00:54:37 +09:00
Nick Cameron
fc52a4d33f
Merge pull request #2173 from topecongiro/assignment-with-100-chars
Assignment whose lhs has 100 chars
2017-12-11 17:04:41 +13:00
Nick Cameron
644b60ad85
Merge pull request #2257 from topecongiro/error-on-line-overflow-strings
Add error_on_line_overflow_strings config option
2017-12-11 16:41:15 +13:00
Nick Cameron
3c08da3433
Merge pull request #2270 from topecongiro/issue-2260
Trim a trailing whitespace on empty line inside code block comment
2017-12-11 16:40:12 +13:00
Seiichi Uchida
3dd31e25bf Use enumerate() 2017-12-11 11:50:11 +09:00
Seiichi Uchida
e45c0c4815 Rename error_on_unformatted_comments_or_strings to error_on_unformatted 2017-12-11 11:48:17 +09:00
Seiichi Uchida
d3ee7f3f06 Set error_on_unformatted_comments_or_strings to true when --error-on-unformatted
option is passed
2017-12-11 11:48:17 +09:00
Seiichi Uchida
93a75de18e Print command line options in alphabetical order 2017-12-11 11:48:17 +09:00
Seiichi Uchida
1e982c66a0 Fix a typo 2017-12-11 11:48:17 +09:00
Seiichi Uchida
cbd3608c30 Organize command line options and start with upper case 2017-12-11 11:48:17 +09:00
Seiichi Uchida
d17168f4ba Add error-on-unformatted command line option 2017-12-11 11:48:17 +09:00
Seiichi Uchida
aea19d5e33 Combine error_on_line_overflow_comments/strings
1. Rename to error_on_unformatted_comments_or_strings
2. Set the option to false by default.
2017-12-11 11:48:17 +09:00
Seiichi Uchida
4d9226ffee Fix a typo 2017-12-11 11:48:17 +09:00
Seiichi Uchida
6c3de706ae Make RichChar public 2017-12-11 11:48:17 +09:00
Seiichi Uchida
ef6ebaa215 Add a config option to suppress error message on string literal 2017-12-11 11:48:17 +09:00
Seiichi Uchida
d1e5d7866b Make CharClasses and FullCodeCharKind public 2017-12-11 11:47:19 +09:00
Seiichi Uchida
5faf31bb32 Trim a trailing whitespace on empty line inside code block comment 2017-12-11 11:37:13 +09:00
Seiichi Uchida
db29f9e0f7 Fix indent issue when recovering comments
Closes #1989
2017-12-11 09:20:02 +09:00
Seiichi Uchida
414a995926 Replace StringBuffer with String 2017-12-11 09:19:00 +09:00
Nick Cameron
0c9b2b402e
Merge pull request #2267 from topecongiro/issue-2264
Remove block() and block_only() wherever possible
2017-12-11 09:02:16 +13:00
Nick Cameron
08022ec1a3
Merge pull request #2265 from topecongiro/issue-2262
Fix bugs related to closures
2017-12-11 09:00:56 +13:00
Nick Cameron
5da2d7be32
Merge pull request #2258 from topecongiro/issue-819
Format macro in pattern position
2017-12-11 08:54:02 +13:00
Nick Cameron
d2b006d6b4
Merge pull request #2255 from topecongiro/nested-imports
Nested imports
2017-12-11 08:53:23 +13:00
Nick Cameron
68b43b2240
Merge pull request #2250 from topecongiro/rustfmt-skip-no-warning-on-items
Do not report errors on skipped items or statements
2017-12-11 08:47:26 +13:00
Seiichi Uchida
b29a3afb96 Fix indentation in multi lined pattern 2017-12-10 23:54:34 +09:00
Seiichi Uchida
a7060f9fdf Remove excessive block() and block_only()
Since we now use the same indent style for every expressions, these safe guards
can be removed.
2017-12-10 23:39:09 +09:00
Seiichi Uchida
e3d2f2c2b1 Cargo fmt 2017-12-10 21:54:26 +09:00
Seiichi Uchida
90383d7426 Do not set inside_macro flag when converting try!() to '?'
This will keep rustfmt idempotent when using 'use_try_shorthand' config option.
2017-12-10 21:53:01 +09:00
Seiichi Uchida
42726906f7 Allow struct to be multi-lined in closure's body without block 2017-12-10 21:52:23 +09:00
Seiichi Uchida
bd6bef8cfa Move macro check to is_block_closure_forced() 2017-12-10 21:49:59 +09:00
Seiichi Uchida
812fc4ca56 Remove and_one_line() 2017-12-10 21:30:12 +09:00
Seiichi Uchida
5871967312 Verify whether adding block is safe in rewrite_closure_with_block()
Also ensure that the expression is nested to avoid false-positive.
2017-12-10 21:27:28 +09:00
Christopher Durham
7e2c3cb857 unstable_features without CFG_RELEASE_CHANNEL
Per discussion in #2228

https://github.com/rust-lang-nursery/rustfmt/pull/2228#issuecomment-348893294
https://github.com/rust-lang-nursery/rustfmt/pull/2228#issuecomment-349799548

Inline comment should explain the reasoning.
2017-12-10 01:01:36 -05:00
Seiichi Uchida
5624175574 Format macro in pattern position 2017-12-10 00:22:00 +09:00
Seiichi Uchida
234c7da871 Handle nested imports 2017-12-09 16:45:25 +09:00
topecongiro
adc3b12ad4 Remove println! debug :( 2017-12-08 17:48:49 +09:00
topecongiro
821d04b2a4 Do not report errors on skipped items or statements 2017-12-08 17:46:43 +09:00
topecongiro
5e6bb3edb0 Keep track of line number in visitor 2017-12-08 16:59:04 +09:00
Nick Cameron
97fd517593
Merge pull request #2247 from topecongiro/optimize-snippet
Optimize snippet()
2017-12-08 20:39:01 +13:00
Seiichi Uchida
3ebe054362 Replace into() on &str with to_owned() 2017-12-08 13:07:42 +09:00
Seiichi Uchida
c776443981 Remove unused lifetime 2017-12-08 13:07:28 +09:00
Seiichi Uchida
23fa0bc3ef
Merge pull request #2240 from davidalber/revisit-2219
Adding `print!` to the list of specially-formatted `format!`-like macros
2017-12-07 17:37:01 +09:00
Seiichi Uchida
d6d8d86e94 Replace &Rc<String> with &str 2017-12-07 17:32:19 +09:00
David Alber
0f561a1447 Moving panic! into the list of macros from the Standard Library 2017-12-06 22:23:02 -08:00
Seiichi Uchida
c0eb8c3212 Add FmtVisitor::from_context() 2017-12-07 13:57:54 +09:00
Seiichi Uchida
1d9a10e00e Use explicit lifetime to get rid of unsafe code
at least this is why we use Rust
2017-12-07 13:57:54 +09:00
Seiichi Uchida
7c4a84751f Convert '&str' into 'String' whenever necessary 2017-12-07 13:57:52 +09:00
Alex Butler
db0a72318a Fix config warnings leaking into stdout 2017-12-06 16:23:18 +00:00
Seiichi Uchida
69a15b2eee Update FmtVisitor::from_codemap() 2017-12-06 22:51:52 +09:00
Seiichi Uchida
0928762562 Use SnippetProvider in FmtVisitor and RewriteContext 2017-12-06 22:49:49 +09:00
Seiichi Uchida
98860ab890 Add SnippetProvider 2017-12-06 22:48:48 +09:00
Seiichi Uchida
b8448f6223 Use package name instead of target name for --package filter 2017-12-06 12:41:04 +09:00
Nick Cameron
b07e4339f0
Merge pull request #2221 from topecongiro/rfc/blank-lines
Keep vertical spaces between items or statements within range
2017-12-06 15:52:19 +13:00
David Alber
eb42956e84 Adding print! specially-formatted format!-like macros list
This commit corrects what appears to be an accidental inclusion of
`panic!` twice in the list resulting from the union of ffbe52e and
aeb3398.
2017-12-05 16:56:56 -08:00
Seiichi Uchida
04449c6622 Handle cases when bound changed from the default 2017-12-05 17:38:27 +09:00
Seiichi Uchida
454c85e359 Cargo fmt 2017-12-05 17:15:58 +09:00
Seiichi Uchida
1d1305eef8 Take into account a trailing newline in buffer 2017-12-05 17:15:42 +09:00
Seiichi Uchida
5632a7c075 Process blank lines if only they're within file lines range 2017-12-05 17:14:57 +09:00
Seiichi Uchida
53616f63b1 Keep blank lines around comments with range 2017-12-05 16:39:45 +09:00
Seiichi Uchida
829d94940e Factor out process_comment() 2017-12-05 16:25:33 +09:00
Seiichi Uchida
d96a48c517 Change the type of argument of push_vertical_spaces() 2017-12-05 15:19:36 +09:00
Seiichi Uchida
228578b9c7 Add count_newlines() utility function 2017-12-05 15:17:40 +09:00
Nick Cameron
ae51f69de4
Merge pull request #2239 from topecongiro/issue-2157
Fix double indented chained closure
2017-12-05 16:56:52 +13:00
Nick Cameron
c4c3f5ba1e
Merge pull request #2238 from topecongiro/issue-1209
Format a macro in the type position
2017-12-05 16:55:31 +13:00
Seiichi Uchida
0c1eb20575 Fix indent of chain with small parent 2017-12-05 10:03:23 +09:00
Seiichi Uchida
b2b14d0f7f Foramt macro on types 2017-12-05 08:42:13 +09:00
Seiichi Uchida
65c90dc08c Do not pass files as arguments to rustfmt when dumping the default config 2017-12-05 08:01:29 +09:00
Nick Cameron
24f1f69d5a
Merge pull request #2236 from topecongiro/simple-array
Compress an array whose items are all 'simple'
2017-12-04 17:33:42 +13:00
topecongiro
1684df6a0a Compress an array with simple items 2017-12-04 12:07:06 +09:00
topecongiro
8cf99b1d90 Factor out array_tactic 2017-12-04 12:06:46 +09:00
topecongiro
ef4b3d9bfa Inspect CFG_RELEASE_CHANNEL env var at compile time 2017-12-04 11:34:27 +09:00
Seiichi Uchida
026c716168 Cargo fmt 2017-12-03 11:38:16 +09:00
Seiichi Uchida
aeb33986b1 Add macros from the log crate to whitelist 2017-12-03 11:37:55 +09:00
topecongiro
8f395bd953 Cargo fmt 2017-12-03 11:34:18 +09:00
topecongiro
27a540db47 Factor out a mess 2017-12-03 11:34:18 +09:00
topecongiro
16184d3e16 Cargo fmt and update a test 2017-12-03 11:34:18 +09:00
topecongiro
0f5dcc665d Handle special-case macros 2017-12-03 11:34:18 +09:00
topecongiro
ffbe52eb76 Add whitelists of macros that need special-case format 2017-12-03 11:34:18 +09:00
Seiichi Uchida
b9126fac82 Do not format fenced code blocks in comment 2017-12-02 23:01:50 +09:00
Seiichi Uchida
89f27764ed Cargo fmt and update tests 2017-12-02 17:45:39 +09:00
Seiichi Uchida
c4c9bf028a Keep vertical spaces between items or statements within range 2017-12-02 17:43:50 +09:00
Seiichi Uchida
483f71c8b1
Merge pull request #2218 from pietroalbini/fix-ast-for-use_nested_groups
Fix broken build after use_nested_groups lands on nightly
2017-12-02 16:34:16 +09:00
Nick Cameron
8f6b6c28f7
Merge pull request #2210 from topecongiro/issue-2178
Combine a short callee and a single argument
2017-12-01 15:02:16 +13:00
Nick Cameron
db81a7f669
Merge pull request #2216 from topecongiro/issue-2214
Preserve trailing comma on array inside macro call
2017-12-01 12:18:38 +13:00
Pietro Albini
9d8cfbcd93
Fix imports formatting broken after AST change 2017-12-01 00:18:00 +01:00
Nick Cameron
076bc2332f
Merge pull request #2213 from topecongiro/issue-2212
Format defualtness on specialized impl const
2017-12-01 12:17:10 +13:00
Nick Cameron
c18ba569df
Merge pull request #1889 from topecongiro/match-arm
Do not put if on the same line as match arm
2017-12-01 11:56:01 +13:00
Oliver Schneider
ae18c6064a Run rustfmt 2017-11-30 15:04:19 +01:00
topecongiro
b33df45d04 Look for trailing comma on array and preserve it inside macro call 2017-11-30 22:14:06 +09:00
topecongiro
65cb9b4649 Generalize rewrite_array() to types other than ast::Expr 2017-11-30 22:13:28 +09:00
topecongiro
3b36371b78 Format defualtness on specialized impl const 2017-11-30 19:38:05 +09:00
Seiichi Uchida
8116e3491d Cargo fmt & update a test 2017-11-30 18:07:10 +09:00
topecongiro
22c9025027 Format source codes 2017-11-30 18:00:49 +09:00
topecongiro
89bf00986d Do not put if on the same line as match arm 2017-11-30 17:56:29 +09:00
Oliver Schneider
9667cc2484
Address clippy lints 2017-11-30 09:24:10 +01:00
topecongiro
39d85b0d41 Combine a sigle argument and a short callee 2017-11-30 15:00:32 +09:00
Seiichi Uchida
f99b775de7 Rename is_dummy to has_braces 2017-11-30 06:40:29 +09:00
Seiichi Uchida
1323abf93f Fix a typo 2017-11-30 06:13:42 +09:00
Seiichi Uchida
b5e4c99ca7 Use an explicit flag to decide on whether to add brace compensation 2017-11-30 06:12:32 +09:00
Seiichi Uchida
54f3c21a2f Fix a typo 2017-11-30 04:56:19 +09:00
Nick Cameron
566f34f2b4
Merge pull request #2205 from topecongiro/issue-2202
Print unstable option's name on warning
2017-11-30 08:44:36 +13:00
Seiichi Uchida
4cb1dccb97 Print unstable option's name on warning 2017-11-29 20:31:58 +09:00
topecongiro
8b53d7806c Cargo fmt 2017-11-29 17:37:51 +09:00
topecongiro
af663d8f62 Ignore fn_call_width when rewriting a call with a single non-call arg 2017-11-29 17:36:51 +09:00
topecongiro
94a770a777 Use correct shape when rewriting the last arg with overflowing 2017-11-29 17:32:31 +09:00
topecongiro
be19bab9de Take into account the rhs overhead when rewriting the last element of chain 2017-11-29 17:29:38 +09:00
Nick Cameron
4e04e825b5 Use the right kind of doc comment in chains.rs
cc #2185
2017-11-28 15:03:02 +13:00
Nick Cameron
3c4d260bfc
Merge pull request #2194 from topecongiro/use-cargo_metadata
Use cargo_metadata
2017-11-28 11:48:40 +13:00
topecongiro
f06cb34022 Replace TargetKind with simple String 2017-11-27 22:09:01 +09:00
topecongiro
940758b1bd Cargo fmt 2017-11-27 21:00:27 +09:00
topecongiro
dff2ebba05 Remove FIXME
now is the time
2017-11-27 20:58:39 +09:00
topecongiro
5c81741733 Minor refactoring 2017-11-27 20:57:06 +09:00
topecongiro
261d325e15 Remove width of a trailing comma on variant 2017-11-27 20:54:55 +09:00
topecongiro
a5b647faa7 Allow '--package <package>' 2017-11-27 19:29:26 +09:00
topecongiro
bf87d9b79f Rename WorkspaceHitlist to CargoFmtStrategy 2017-11-27 18:57:46 +09:00
topecongiro
fbe06c6f77 Random formatting 2017-11-27 18:48:16 +09:00
topecongiro
33ab1f4927 Use cargo_metadata crate over json crate 2017-11-27 18:47:07 +09:00
topecongiro
58e83fb426 Implement PartialEq, Eq and Hash trait for Target
and move Target::from_json() to TargetKind::from_str()
2017-11-27 18:45:26 +09:00
topecongiro
1b1122654f Add cargo_metadata to dependency 2017-11-27 18:37:21 +09:00
Nick Cameron
fcb48786c8
Merge pull request #2191 from topecongiro/issue-2190
Recover from failing to format variants even where there is no comment
2017-11-27 18:14:08 +13:00
topecongiro
d5c98008f0 Recover from failing to format variants even where there is no comment 2017-11-27 13:50:01 +09:00
Nick Cameron
f0af1d4818 Remove CompressedIfEmpty option from fn_args_density
It was identical to Tall
2017-11-27 17:49:55 +13:00
Nick Cameron
677446e99d Merge fn_empty_single_line and impl_empty_single_line into empty_item_single_line 2017-11-27 17:46:09 +13:00
Nick Cameron
9a33255834 Rename wrap_match_arms to match_arm_blocks 2017-11-27 17:35:27 +13:00
Nick Cameron
8f4d85a9d7 Merge multiline_closure_forces_block and multiline_match_arm_forces_block into force_multiline_block 2017-11-27 17:03:54 +13:00
Nick Cameron
087f8b5854 Remove match_arm_forces_newline 2017-11-27 16:31:49 +13:00
Nick Cameron
0e1fa2c244 Remove indent_match_arms 2017-11-27 15:49:14 +13:00
Nick Cameron
86007e7d17 Remove where_density and where_layout options
There is a choice between block and visual indent for where clauses, plus the
single line option. I think these two are too fine-grained to be useful.
2017-11-24 21:08:24 +13:00
Nick Cameron
abfa4a1473
Merge pull request #2184 from topecongiro/issue-2179
Put rhs on the same line as lhs if putting rhs on next line exceeds max width
2017-11-24 20:19:12 +13:00
Nick Cameron
dd1fbca99a Replace various small width heuristics with a single option
Closes #1984
2017-11-24 20:17:06 +13:00
topecongiro
e6ce65b214 Put rhs on the same line as lhs if putting rhs on next line exceeds max width 2017-11-24 12:05:02 +09:00
Nick Cameron
96886cd67f Fix a typo in the unstable options handling and address fallout 2017-11-24 15:41:27 +13:00
Nick Cameron
e5bcb2259a Reorganise config options and stabilise a few 2017-11-24 15:41:27 +13:00
Nick Cameron
45d4f7a2dd struct_lit_multiline_style -> struct_lit_single_line (and make it a bool) 2017-11-24 14:45:18 +13:00
Nick Cameron
20805acf42 Merge attributes_on_same_line_as_field and attributes_on_same_line_as_variant into same_line_attributes 2017-11-24 14:29:44 +13:00
Nick Cameron
d00c60df5c Remove chain_split_single_child option 2017-11-24 14:12:54 +13:00
Nick Cameron
4cb474b5ee Remove force_format_strings in favour of format_strings 2017-11-24 14:07:37 +13:00
Nick Cameron
8a7b6b8806 Remove match_pattern_separator_break_point in favour of binop_separator 2017-11-24 14:01:44 +13:00
Nick Cameron
179b3c59de Remove legacy option fn_args_paren_newline 2017-11-24 13:27:14 +13:00
Nick Cameron
4f65124422 Remove legacy option fn_return_indent 2017-11-24 13:19:36 +13:00
Nick Cameron
d0f12b8ec8 Remove unused option take_source_hints 2017-11-24 13:08:02 +13:00
topecongiro
d92cfff43b Align post comments with items when the it starts with newline 2017-11-23 12:38:34 +09:00
topecongiro
53d7489221 Force vertical layout when we find any kind of single line comments 2017-11-23 12:37:12 +09:00
topecongiro
59ebde26f7 Cargo fmt 2017-11-21 08:52:43 +09:00
topecongiro
34b0c9cf3f Do not give up when we run out of space when choosing rhs 2017-11-21 08:52:11 +09:00
topecongiro
6710f0dc9a Do not squash unsafe block 2017-11-20 16:40:58 +09:00
Nick Cameron
f987946078
Merge pull request #2161 from topecongiro/issue-1807
Implement RFC style for match pattern
2017-11-20 14:51:53 +13:00
Nick Cameron
d230242e23
Merge pull request #2162 from utkarshkukreti/issue-1753
Fix missing trailing newline in --write-mode=diff.
2017-11-20 14:45:07 +13:00
topecongiro
448991a6f3 Handle multi-lined fn signature 2017-11-18 15:46:01 +09:00
topecongiro
d5152fc8c6 Use choose_rhs() for the layout of multi-lined struct field 2017-11-18 15:45:58 +09:00
Utkarsh Kukreti
d44d4a3fbc Add test for trailing newline in diff.
Credits to @afshinm for most of the code.
2017-11-17 20:46:17 +05:30
Utkarsh Kukreti
d0df53d833 Fix checkstyle test.
The only reason it passed before was due to a bug in the `diff` crate.
The diff was empty even though the contents of the files were different --
namely one string had a trailing newline character while the other didn't.
Now both have a trailing newline character.
2017-11-17 09:43:47 +05:30
topecongiro
95d7619e34 Use mixed layout for patterns that are all short 2017-11-16 17:43:36 +09:00
topecongiro
e09a0cc836 Add is_short_pattern() 2017-11-16 17:43:36 +09:00
topecongiro
311a3c526c Fix up write_list() to handle Mixed tactic 2017-11-16 17:43:36 +09:00
topecongiro
35466adbfe Generalize ListItems to allow a separator other than comma 2017-11-16 17:43:36 +09:00
topecongiro
34c2499029 Cargo fmt 2017-11-16 17:43:06 +09:00
topecongiro
09d54512da Break before '|' for multi-lined match arm pattern 2017-11-16 17:43:06 +09:00
topecongiro
b1a6dd6b83 Cargo fmr & update tests
Note that we are forcing vertical layout when there are attributes on top of a
variant.
2017-11-16 16:07:15 +09:00
topecongiro
8ef54293e8 Force vertical layout for all variants if one of then use multiple lines 2017-11-16 16:02:01 +09:00
topecongiro
f7ef1f681c Use rewrite_assign_rhs() when rewriting associated type 2017-11-16 11:31:09 +09:00
topecongiro
4cd2e6f39a Generalize rewrite_assign_rhs() 2017-11-16 11:26:36 +09:00
topecongiro
95c7325ac2 Do not get tricked by a nested comment 2017-11-15 15:46:00 +09:00
topecongiro
37b1779426 Look for a newline after match arm only when there is one 2017-11-15 12:22:50 +09:00
Nick Cameron
a90b76a731
Merge pull request #2153 from topecongiro/issue-2152
Return None when a literal exceeds budget
2017-11-15 15:43:03 +13:00
topecongiro
bdb8f369e8 Return None when a literal exceeds budget 2017-11-15 10:36:49 +09:00
topecongiro
bc543cce0b Combine spaces_within_parens and spaces_within_brackets 2017-11-14 23:42:31 +09:00
topecongiro
babc479783 Use space_before_colon and space_after_colon 2017-11-14 23:25:36 +09:00
Nick Cameron
6a6e9a22bc
Merge pull request #2148 from topecongiro/audit-option/brace_style
Combine fn_brace_style and item_brace_style
2017-11-14 16:57:09 +13:00
Nick Cameron
be76476421
Merge pull request #2137 from clippered/add-color-cli-option
add cli option for color
2017-11-14 15:11:31 +13:00
topecongiro
f8074b340d Combine fn_brace_style and item_brace_style 2017-11-14 10:47:02 +09:00
clippered
794a215b27 rename to use_colored_tty; used match as well 2017-11-13 20:18:05 +11:00
clippered
d2f2f25463 add cli option for color 2017-11-13 20:18:03 +11:00
topecongiro
04f09c9d85 Replace '*_indent' with 'indent_style' in src 2017-11-13 17:33:32 +09:00
Nick Cameron
4da9a147e1 Collapse multiple blocks in closures
Fixes #1524
2017-11-13 16:45:54 +13:00
Nick Cameron
bc6e493ce0 More closures refactoring 2017-11-13 16:29:43 +13:00
Nick Cameron
e6800bf27d remove closure_block_indent_threshold option 2017-11-13 15:40:54 +13:00
Nick Cameron
7ff2cb23f5
Merge pull request #2146 from topecongiro/where-on-unit-struct
Format where clause on unit struct
2017-11-13 15:28:32 +13:00
Nick Cameron
e6253c4d31 Extract a closures module 2017-11-13 15:27:16 +13:00
Nick Cameron
10bce817d9 Some basic refactoring 2017-11-13 15:13:23 +13:00
topecongiro
6b8cd40d07 Format where clause on unit struct 2017-11-13 11:07:09 +09:00
topecongiro
687b26c688 Add BracePos 2017-11-13 11:06:53 +09:00
Nick Cameron
1a6d117719
Merge pull request #2145 from topecongiro/issue-2144
Format generics on unit struct
2017-11-13 13:01:37 +13:00
topecongiro
f45aba9ced Cargo clippy 2017-11-13 08:02:23 +09:00
topecongiro
c485202907 Format generics on unit struct 2017-11-13 08:02:06 +09:00
Seiichi Uchida
d9e31be40f Refactor: use less vertical lines 2017-11-11 23:15:57 +09:00
Seiichi Uchida
033ce59a6a Return None when string literal from source exceeds max width 2017-11-11 23:15:33 +09:00
Seiichi Uchida
1664ebb18b Return 'None' when macro call snippet from source exceeds max width 2017-11-11 23:14:24 +09:00