Nick Cameron
abb253df8b
Rationalise result and error types
2018-05-21 08:58:53 +12:00
Nick Cameron
432b1cb253
Rationalise error types
...
cc #2639
2018-05-21 08:58:53 +12:00
Nick Cameron
760af6cfc9
Make format_snippet
and format_code_block
private
...
cc #2639
2018-05-21 08:58:53 +12:00
Nick Cameron
e83c7ff005
Merge pull request #2723 from topecongiro/rustc-ap-syntax
...
Update rustc-ap-syntax
2018-05-19 11:47:36 +12:00
topecongiro
912e4bdc90
Fix breaking changes from rustc-ap-syntax
...
cc https://github.com/rust-lang/rust/pull/50045 .
2018-05-19 08:43:00 +09:00
Thomas Lively
5d56adb10c
Fix position of auto in auto trait declaration
2018-05-18 17:25:33 -04:00
Nick Cameron
2ee8b0e4c5
Remove remove_blank_lines_at_start_or_end_of_block
...
cc #1974
2018-05-18 16:56:55 +12:00
Nick Cameron
dd9c15ad01
Unstabilise unstable_features
...
cc #1974
2018-05-18 16:53:08 +12:00
Nick Cameron
a70f71610c
stabilise remove_nested_parens
and set default to true
2018-05-18 16:46:22 +12:00
Nick Cameron
8afe367510
stabilise shorthand options
...
cc #1974
2018-05-18 16:38:09 +12:00
Nick Cameron
d726492e65
Remove spaces_within_parens_and_brackets
...
cc #1974
2018-05-18 16:35:09 +12:00
Nick Cameron
7b6d2b4699
Stabilise reorder_imports and reorder_modules
2018-05-18 16:04:09 +12:00
Nick Cameron
416bc4c353
Unstabilise comments options
...
cc #1974
2018-05-18 16:02:05 +12:00
Nick Cameron
1452349966
Exit with 1 for license check in --check
mode
...
Closes #2707
2018-05-18 15:30:32 +12:00
Shotaro Yamada
d1e2b80fb9
Use saturating_sub
2018-05-15 20:41:43 +09:00
Nick Cameron
390a284851
Give a deprecation warning on rustfmt_skip
and an error on rustfmt::
other than skip
2018-05-14 18:10:46 +12:00
Nick Cameron
51f566062f
Update uses of rustfmt_skip
to rustfmt::skip
2018-05-14 16:25:10 +12:00
Nick Cameron
de950c2973
Skip on rustfmt::skip
as well as rustfmt_skip
2018-05-14 16:13:21 +12:00
Nick Cameron
7eb8bdbbd2
Format attributes with paths
2018-05-14 16:04:15 +12:00
Nick Cameron
a3c85cdc41
Reorder the --help message
2018-05-14 11:07:54 +12:00
Nick Cameron
6d0695303a
Make some write modes unstable
2018-05-14 10:55:16 +12:00
Nick Cameron
3b23a98d00
Support unstable options
...
cc #1976
2018-05-14 10:20:51 +12:00
Nick Cameron
5d9f5aa05a
Replace --write-mode
with --emit
...
cc #1976
2018-05-13 14:13:24 +12:00
Nick Cameron
8396da1882
Add --backup
flag
2018-05-13 13:18:08 +12:00
Pazzaz
1c1763c7ae
Remove unnecessary use of Box in format_function_type
2018-05-12 10:53:06 +02:00
Seiichi Uchida
1b1eccc553
Fix build failure ( #2699 )
2018-05-12 10:36:34 +09:00
Nick Cameron
eca7796fb1
Replace --dump-minimal-config
and --dump-default-config
with --print-config
...
cc #1976
2018-05-11 20:43:08 +12:00
Nick Cameron
4d9de48e06
Add --check
flag.
...
cc #1976
2018-05-11 20:26:00 +12:00
Nick Cameron
798bffb8b1
--help
options
...
cc #1976
2018-05-11 20:12:16 +12:00
Nick Cameron
1869888b1a
Remove --verbose-diff
...
Use `--verbose` instead
cc #1976
2018-05-11 13:58:34 +12:00
Nick Cameron
55ac062da0
Add --quiet
flag, remove Plain
write mode
...
cc #1976
2018-05-11 13:50:30 +12:00
Nick Cameron
5dba81bbbf
Merge pull request #2687 from Marwes/issue_2641
...
fix: Don't insert an extra brace in macros with native newlines
2018-05-09 13:18:27 +12:00
Nick Cameron
659d0c9741
Merge pull request #2684 from topecongiro/issue-2175
...
Apply small parent heuristic only when the chain is at the beginning of the line
2018-05-09 13:16:26 +12:00
Alex Crichton
47742807f7
Ensure tests pass on the beta compiler
...
Also add a travis matrix entry for emulating the beta tests
2018-05-08 18:05:08 -07:00
Markus Westerlind
4c9ef93df7
fix: Don't insert an extra brace in macros with native newlines
...
Due to `format_snippet` formatting the input with \r\n the subtraction
would wouldn't give a length that removed the }
Fixes #2641
2018-05-08 20:34:44 +02:00
Alex Crichton
a72be170d7
Fix rustfmt tests in the Rust repo
...
Two tests were executing `cargo run` but `cargo` is not ambiently available to
execute. Instead it's best to execute the rustfmt binary directly, which is
always assembled as part of `cargo test`.
2018-05-08 07:32:00 -07:00
topecongiro
bd25c7d0f7
Cargo fmt
2018-05-08 06:25:48 +09:00
topecongiro
0ec311ee07
Apply small parent rule only when there is small offset
2018-05-08 06:25:06 +09:00
Nick Cameron
f46f4b5f66
Merge pull request #2675 from flodiebold/non-modrs-mods
...
Fix handling of modules in non_modrs_mods style
2018-05-07 11:23:14 +12:00
Nick Cameron
bd7ae5e89b
Merge pull request #2682 from topecongiro/issue-2670
...
Do not duplicate attributes on use items
2018-05-07 11:21:02 +12:00
Nick Cameron
4bbd5c4ae5
Merge pull request #2681 from topecongiro/issue-2680
...
Error on self_tests when there are lines that exceed max width
2018-05-07 11:20:33 +12:00
Florian Diebold
e65aa302d3
Turn the nonmodrs-mods test into a standard idempotence test
...
We need to skip children on foo.rs, since the parser will not find bar from that
file, but with that, the test works fine.
2018-05-06 13:08:43 +02:00
topecongiro
e59ceaf954
Do not duplicate attributes on use items
2018-05-06 17:01:14 +09:00
Florian Diebold
215baae223
Add a test for non-mod.rs mods
2018-05-06 09:58:03 +02:00
Florian Diebold
cf573e8157
Fix handling of modules in non_modrs_mods style
...
We need to keep track of the module relative to which we're resolving paths,
instead of always passing None.
Fixes #2673 .
2018-05-06 09:58:03 +02:00
topecongiro
51c07f4335
Fix up lines exceeding max width
2018-05-06 16:17:09 +09:00
topecongiro
5f05987211
Use rustfmt.toml when running self_tests
2018-05-06 16:16:58 +09:00
topecongiro
1f738ea208
Cargo fmt
2018-05-06 15:22:29 +09:00
topecongiro
f8439ce8fe
Put operands on its own line when each fits in a single line
2018-05-06 15:22:17 +09:00
topecongiro
f885039e6c
Do not overflow a long item
...
Take the first line's width of a single item into account when
trying to overflow something.
Closes #2676 .
2018-05-06 12:12:16 +09:00
Nick Cameron
17b04f181d
Merge pull request #2677 from csmoe/remove_nested_parens_opt
...
Add remove nested parens option
2018-05-06 14:01:17 +12:00
Nick Cameron
0cc4a8d848
Update rustc_ap_syntax
2018-05-06 09:57:26 +12:00
Nick Cameron
0f8029f251
Use a different env var for the test directory
2018-05-06 08:23:26 +12:00
csmoe
7c246344f8
remove nested parens option
2018-05-05 23:13:49 +08:00
Nick Cameron
4a57e79469
Merge pull request #2667 from tspiteri/width-heuristics
...
Do not scale WidthHeuristics when max_width less than 100
2018-05-04 11:46:28 +12:00
Nick Cameron
b6cd17f28a
Fix test bug (again)
2018-05-04 09:35:56 +12:00
Nick Cameron
a06caf6b17
Merge pull request #2671 from csmoe/merge_mix
...
Make imports_layout = "Mixed" addressed
2018-05-03 20:08:16 +12:00
csmoe
8c8676cd30
fix merge_mix
2018-05-03 10:26:53 +08:00
Nick Cameron
4a4916920f
Make test temp files in the Cargo target directory, if known
2018-05-03 11:14:01 +12:00
Trevor Spiteri
48df8f8dc0
Add test for width heuristics
2018-05-02 11:38:23 +02:00
Trevor Spiteri
9b36156020
Do not scale WidthHeuristics when max_width less than 100
2018-05-02 10:38:02 +02:00
Nick Cameron
36c49d703a
Merge pull request #2666 from topecongiro/issue-2634
...
Avoid flip-flopping impl items when reordering them
2018-05-02 10:28:46 +12:00
Nick Cameron
c3bdd3aa90
Merge pull request #2665 from topecongiro/issue-2647
...
Use correct one line width for list attribute
2018-05-02 10:26:49 +12:00
Nick Cameron
d8982e5efe
Suppress warning about unused attribute
2018-05-02 10:18:14 +12:00
topecongiro
43df7dcb0e
Run cargo fmt with reorder_impl_items set to true
2018-04-30 16:24:01 +09:00
topecongiro
37c216c50f
Use bytepos to compare impl items
2018-04-30 16:19:52 +09:00
topecongiro
48e193c7f6
Factor out visit_impl_items
2018-04-30 16:13:51 +09:00
topecongiro
61a401ae51
Use correct one line width for list attribute
...
Closes #2647 .
2018-04-30 15:49:32 +09:00
Nick Cameron
e554d8617d
Merge branch 'master' into imports_indent
2018-04-30 11:50:53 +12:00
Nick Cameron
1b7195695a
Merge pull request #2663 from csmoe/config_curr
...
set stdin default config path to current dir
2018-04-30 11:20:04 +12:00
Nick Cameron
ffaa6fcb0c
Merge pull request #2661 from topecongiro/issue-2645
...
Preserve comments between attribute and use item
2018-04-30 11:10:48 +12:00
Nick Cameron
af5976cf1e
Merge pull request #2659 from topecongiro/issue-2652
...
Do not add a trailing comma on array inside macro
2018-04-30 11:07:33 +12:00
Nick Cameron
dae9fb64b6
Merge pull request #2656 from topecongiro/issue-2594
...
Use consistent formatting for empty enum and struct
2018-04-30 11:06:33 +12:00
csmoe
be3be582cc
set stdin default config path to curr
2018-04-29 21:40:37 +08:00
csmoe
f7415bcea2
update self format
2018-04-29 20:53:31 +08:00
csmoe
c9cef5db17
import_indent to Block
2018-04-29 19:57:49 +08:00
Ryan Leung
fb9a5add9b
add rustc_target to dependencies ( #2660 )
2018-04-28 16:08:58 +09:00
topecongiro
0c5631e4c1
Use correct span for UseTree
2018-04-28 16:05:02 +09:00
topecongiro
a159b64b0a
Preserve comments between attribute and use item
2018-04-28 16:04:09 +09:00
topecongiro
43890cff6b
Preserve trailing comma inside array
...
Closes #2652 .
2018-04-28 15:09:54 +09:00
topecongiro
e512c19ed5
Use format_empty_struct_or_tuple over format_missing_no_indent
...
Closes #2594 .
2018-04-28 14:03:14 +09:00
topecongiro
fb0c6affa5
Use format_empty_struct_or_tuple
2018-04-28 13:59:54 +09:00
topecongiro
82d8dd2f4b
Factor out a formatting routine for empty struct and tuple
2018-04-28 13:59:03 +09:00
topecongiro
a955365459
Use a glob import for import utils
2018-04-28 13:24:05 +09:00
Nick Cameron
d19fc450c0
Merge pull request #2650 from thibaultdelor/useFailureCrate
...
Use failure crate
2018-04-27 15:14:47 +12:00
Nick Cameron
0f4ed08d0e
Harden tests to not rely on CWD
2018-04-27 11:13:05 +12:00
Tibo
e06c9c8c53
Allow io::Error
to live longer before being wrapped in a failure::Error
2018-04-26 14:39:10 +10:00
Tibo
b7df23c3d5
Replace completely std::error with failure crate
2018-04-26 13:48:48 +10:00
Tibo
5581be2616
Use failure for FormattingError
2018-04-26 12:18:30 +10:00
Tibo
efb8069cfc
Replace std::Error with failure for FormatDiff
2018-04-26 12:18:20 +10:00
Seiichi Uchida
ac8ae00625
Cargo update and clippy ( #2643 )
2018-04-25 07:21:23 +09:00
Roman Stoliar
5b5a72c840
keep auto trait
2018-04-20 17:31:31 +03:00
Nick Cameron
866900449a
Make some more stuff private
...
0.6
2018-04-20 22:10:48 +12:00
Nick Cameron
ca610d35b3
Refactor to make a sensible public API
...
0.5 - lots of breaking changes
cc #2639
2018-04-20 21:52:02 +12:00
Nick Cameron
6a31741eaa
Get exit codes right
2018-04-20 14:17:56 +12:00
Nick Cameron
5194984812
Add a verbose-diff option
...
And don't print end of line characters by default in diffs
cc #2536
2018-04-20 14:02:44 +12:00
Nick Cameron
7a886e8fe5
Refactoring around write mode in main
2018-04-20 13:42:27 +12:00
Nick Cameron
a73f14aa95
Trivial refactoring in bin
2018-04-20 13:24:45 +12:00
David Barsky
f9532ba8d7
Implemented rough draft of check
write mode. ( #2539 )
...
* Add rough draft of `check` mode. Not unit tested.
* Added assert-cli; simple test case for `--write-mode=check`
* Lightly documented `check` WriteMode
* wrote clearer phrasing for config::options::WriteMode::Check
* Implemented default for WriteMode where default is Overwrite
* Simplified exit code handling
* updated README.md as per @nrc' comment
* collapsed exit-code handling
* Removed write_mode from Summary, introduced partial option parsing earlier
* Handle write-mode parsing in a slightly better way.
2018-04-20 11:14:11 +12:00
Shotaro Yamada
61d29eb70c
Add spaces between consecutive ..
..=
2018-04-16 17:33:22 +09:00
Nick Cameron
1415a4dc23
Fix tests
2018-04-14 10:20:08 +12:00
Nick Cameron
01c1f99e39
Fallout from removing TupField
2018-04-14 10:15:39 +12:00
Nick Cameron
2cea3644fe
Merge pull request #2618 from topecongiro/issue-1174
...
Output xml header and footer only once
2018-04-12 16:56:00 +12:00
Seiichi Uchida
8b731db6ba
Output xml header and footer only once
2018-04-12 13:45:12 +09:00
Nick Cameron
55dd8f1df0
Merge pull request #2603 from topecongiro/merge-nested-imports
...
Merge imports
2018-04-12 16:40:06 +12:00
Seiichi Uchida
e58e97783e
Preserve trailing comma on macro call when using mixed layout
2018-04-12 09:54:00 +09:00
Nick Cameron
305c640553
Review changes
2018-04-11 10:50:19 +12:00
Nick Cameron
1c17dbbf74
rebasing
2018-04-11 10:46:49 +12:00
Nick Cameron
911395a451
Squash the various 'reorder imports' option into one
...
cc #2185
2018-04-11 10:46:49 +12:00
Seiichi Uchida
8820a59bd5
Resolve review comments
2018-04-10 12:36:57 +09:00
Seiichi Uchida
4a7e45ec28
Simplify UseTree::has_comment
2018-04-10 12:36:57 +09:00
Seiichi Uchida
1954513ace
Merge imports with the same prefix into a single nested import
2018-04-10 12:36:57 +09:00
Seiichi Uchida
5dd203eabe
Add merge_imports config option
2018-04-10 12:36:57 +09:00
Nick Cameron
518ece2272
Merge pull request #2612 from peterhuene/suppress-unstable-config-options
...
Suppress unstable config options by default.
2018-04-10 15:07:57 +12:00
Peter Huene
8208f8aa01
Suppress unstable config options by default.
...
This commit suppresses the output of unstable config options by default.
Users can specify the `--unstable-features` option to show the config options
that are unstable.
Fixes #2611 .
2018-04-09 12:45:56 -07:00
Nick Cameron
e784712f09
Try to fix a build regression before it happens
2018-04-09 21:07:49 +12:00
Nick Cameron
f14671131e
Make error_on_line_overflow
false by default
...
And improve docs, the error message, etc.
I think false is the better default since such errors should only occur due to a bug in Rustfmt and therefore most users should not be notified of it happening (although to be clear, it might be a 'bug' which only occurs with pathological input and therefore we won't fix it). The error has proven to be confusing and annoying in the past.
Closes #1080
2018-04-09 16:47:55 +12:00
Nick Cameron
48e5bc1988
Reorder config options
...
cc #1974
2018-04-09 16:31:53 +12:00
Nick Cameron
7822d0c921
Fix test
2018-04-09 09:54:07 +12:00
csmoe
84d3659767
update rustc syntax 91.0.0
2018-04-08 22:22:11 +08:00
Seiichi Uchida
edcc7b69eb
Cargo update ( #2602 )
...
Update `rustc-ap-syntax` to 89.0.0 and fix up breaking changes.
2018-04-06 23:09:45 +09:00
Nick Cameron
b6645e345e
Merge pull request #2601 from topecongiro/fix-merge-mess
...
Fix up merge mess
2018-04-06 15:32:05 +12:00
Seiichi Uchida
04227a7d30
Fix up merge mess
2018-04-06 10:31:57 +09:00
Nick Cameron
0a480181e8
Merge pull request #2600 from i1skn/error_on_unformatted
...
Fix error_on_unformatted and skip_children override
2018-04-06 12:41:13 +12:00
Nick Cameron
4b2160e1b2
Merge pull request #2599 from topecongiro/issue-2596
...
Use multiple lines for imports list which exceeds max width
2018-04-06 11:12:53 +12:00
Nick Cameron
a3fba04141
Merge pull request #2593 from topecongiro/issue-2455
...
Add reorder_impl_items config option
2018-04-06 11:12:11 +12:00
Ivan Sorokin
3fe2233fd3
Fix error_on_unformatted and skip_children override
...
Currently, error_on_unformatted and skip_children options
specified in the config file are discarded.
This happens because CLI options have a higher priority,
but we coerce an absence of a `bool` option to `false`.
In this scenario, an absence of a `bool` option is indistinguishable
from explicetely set as `false`. We should coerce it to `None` instead,
so it does not override the one in the config file.
2018-04-05 23:13:17 +02:00
Nick Cameron
b7ba6f70b1
Merge pull request #2576 from topecongiro/merge-imports
...
Use normalized form to format use items
2018-04-05 17:39:22 +12:00
Nick Cameron
0156fe07ac
Merge pull request #2589 from topecongiro/issue-2588
...
Do not indent or unindent inside string literal
2018-04-05 17:36:15 +12:00
Nick Cameron
a318bc887f
Merge pull request #2580 from remram44/improve-where_single_line-help
...
Improve `where_single_line` help
2018-04-05 17:34:53 +12:00
Seiichi Uchida
97ec417e74
Add trailing comma when using mixed layout with block indent
2018-04-05 13:27:42 +09:00
Seiichi Uchida
636de8313d
Put imports list on the next line if it exceeds max width
2018-04-05 13:24:18 +09:00
Seiichi Uchida
ec1907b2a4
Do not indent or unindent inside string literal
...
Closes #2588 .
2018-04-05 12:52:43 +09:00
Seiichi Uchida
89070a2244
Implement LineClasses
2018-04-05 12:52:43 +09:00
Seiichi Uchida
fa80ddf876
Reorder impl items based on its kind
...
The ordering is defined as follows:
type < cosnt < macro < method
Items that are same kind will not be reordered: that is, the item
that an user has put first comes first.
2018-04-05 12:49:16 +09:00
Seiichi Uchida
94f5a05a6a
Add reorder_impl_items config option
2018-04-05 12:49:16 +09:00
memoryleak47
d48cbedfe4
typo ( #2598 )
...
* typo
* more typos
2018-04-05 12:47:09 +09:00
Marthog
bc05621f9b
Let --dump-default-config default to stdout #2579 ( #2586 )
2018-04-01 23:15:25 +09:00
Seiichi Uchida
dec307b2fa
Merge pull request #2584 from sinkuu/cleanup
...
Misc cleanups
2018-04-01 23:14:52 +09:00
Shotaro Yamada
e2d801f11e
Do not turn spaces in the beginning of the file into a newline ( #2583 )
2018-04-01 23:09:53 +09:00
Shotaro Yamada
56e10aa6e9
Fix typo
2018-04-01 22:29:26 +09:00
Shotaro Yamada
3467b4dafe
Use ListItem::has_comment
2018-04-01 22:29:26 +09:00
Shotaro Yamada
ba792a7fa2
Remove redudant parens
2018-04-01 22:29:26 +09:00
Shotaro Yamada
71448ff3c2
Return String instead of always returing Cow::Owned
2018-04-01 22:29:26 +09:00
Shotaro Yamada
39e85281f3
Remove stray comment
...
Its pointee was removed in 04a6d16c7b
2018-04-01 22:29:26 +09:00
Shotaro Yamada
a2325375ed
Do not collect into a Vec by hand
2018-04-01 22:29:26 +09:00
Shotaro Yamada
89200f40ff
Remove unnecessary [..]
s
2018-04-01 22:29:26 +09:00
Shotaro Yamada
6b3811a358
Use Iterator methods
2018-04-01 22:29:26 +09:00
Shotaro Yamada
ed46a777c8
Use str::repeat
2018-04-01 22:29:26 +09:00
Remi Rampin
37ee9c20aa
Improve where_single_line help
2018-03-31 18:51:41 -04:00
Seiichi Uchida
78e09bd05c
Cargo fmt
2018-03-31 14:47:50 +09:00
Seiichi Uchida
f6c0a0f4ed
Cargo fmt
2018-03-31 14:23:40 +09:00
Seiichi Uchida
01311c63ec
Format normalized use item
...
This commit implements `Rewrite` trait on `UseTree`, which is a normalized
form of `ast::UseTree` for rustfmt.
2018-03-31 14:23:36 +09:00
Seiichi Uchida
2b682b8ed5
Do not include separator to post comment
...
This prevents the trailing `;` on use item to be treated as comment.
2018-03-31 13:19:55 +09:00
Seiichi Uchida
a8022f3862
Do not insert newline when item is empty
...
This change is necessary when we remove unused imports (`use std::{};`).
2018-03-31 13:18:53 +09:00
Seiichi Uchida
73e7235317
Cargo update ( #2575 )
...
Update `rustc-ap-syntax` to 82.0.0.
2018-03-30 17:52:09 +09:00
Seiichi Uchida
3de184fb0e
Merge pull request #2572 from codeworm96/remove_unreachable
...
Remove unreachable! from macros.rs
2018-03-29 09:16:38 +09:00
codeworm96
e68682f6db
Remove unreachable! from macros.rs
...
replaced unreachable! with error handling using Option.
Closes #2558
2018-03-28 23:38:34 +08:00
Nick Cameron
72b715bad4
Merge pull request #2571 from topecongiro/issue-2569
...
Avoid panicking on macro call with a single comma
2018-03-28 17:02:49 +02:00
Nick Cameron
1644b174a7
Merge pull request #2557 from topecongiro/vertical-layout-complex-attrs
...
Use vertical layout for complex attributes
2018-03-28 17:01:16 +02:00
Nick Cameron
8dd08ddd92
Merge pull request #2562 from topecongiro/issue-2196
...
Combine simple heuristics for function calls and array
2018-03-28 16:49:25 +02:00
Seiichi Uchida
a49e00b4d7
Avoid panicking on macro call with a single comma
...
`parse_item` from libsyntax may return `None`, so we need to discard
the result in that case.
2018-03-28 18:14:51 +09:00
Seiichi Uchida
efd295a4e1
Follow indent style config when formatting attrs
2018-03-28 17:42:17 +09:00
Seiichi Uchida
0f55350c7d
Merge pull request #2563 from rleungx/allow-underscore
...
allow underscore in macro_rules!
2018-03-28 12:41:51 +09:00
rleungx
bf3bf8c235
allow underscore
2018-03-28 00:31:44 +08:00
Taylor Cramer
72d8c9143b
Allow stabilization of match_default_bindings
2018-03-26 22:29:01 +02:00
Nick Cameron
53ecabad04
Merge pull request #2556 from topecongiro/issue-2554
...
Do not add the beginning vert to the match arm
2018-03-26 18:01:24 +13:00
Seiichi Uchida
48424ea765
Update tests and cargo fmt
2018-03-26 07:38:39 +09:00
Seiichi Uchida
98c6f7b731
Format array using overflow module
...
This commit applies heuristics used for function calls to array
and vice versa.
2018-03-26 07:36:44 +09:00
Seiichi Uchida
affa4ce1ec
Factor out default_tactic and fix indentation
...
rustfmt fails to handle binary expressions with comments in-between.
2018-03-26 07:34:17 +09:00
Seiichi Uchida
cf6c67e1a6
Replace MacroStyle with ast::DelimToken
2018-03-26 07:32:48 +09:00
Seiichi Uchida
903de92dae
Avoid cloning RewriteContext
2018-03-25 20:20:50 +09:00
topecongiro
c77708ff9a
Use vertical layout for complex attributes
2018-03-25 15:17:41 +09:00
Seiichi Uchida
1e1d9d4afe
Do not add the beginning vert to the match arm
...
Pass the span after the match's condition expression.
Closes #2554 .
2018-03-23 19:59:38 +09:00
Nick Cameron
2fbdedbf2f
Merge pull request #2549 from topecongiro/macro-def-spaces-around-colon
...
Add config option to control spaces around colon in macro def
2018-03-23 10:51:47 +13:00
topecongiro
ccec777f92
Cargo fmt and update tests
2018-03-22 16:09:21 +09:00
topecongiro
6115dcdbdc
Remove a space after a colon of metavariable def in macro def
2018-03-22 16:08:57 +09:00
topecongiro
b58a113370
Use UseSegment::Slf
or UseSegment::Super
when appropriate
...
Currently we `UseSegment::Ident` for all of the segments except the last.
E.g. `use super::foo::bar::self;` will be
`[Ident("super"), Ident("foo"), Ident("bar"), Self(None)]`.
in the current implementation. I think that this should be
`[Super(None), Ident("foo"), Ident("bar"), Self(None)]`.
instead.
I noticed this because some tests failed after updating
`rustc-ap-syntax` to 73.0.0.
2018-03-22 15:56:51 +09:00
topecongiro
846f4f21db
Fix libsyntax updates
...
`ast::UseTreeKind::Simple` now takes `Option<ast::Ident>`
instead of `ast::Ident`.
2018-03-22 15:55:14 +09:00
topecongiro
51d5696977
Fix libsyntax update
...
Underscore is now one of keywords.
2018-03-22 15:53:43 +09:00
Alan Du
d402cd20a8
Close #2551
2018-03-22 00:57:22 -04:00
Alan Du
d8723aaa8c
Fix build
2018-03-22 00:01:09 -04:00
Nick Cameron
ff9ab51617
Merge pull request #2550 from sinkuu/chars_count_index
...
Don't index a string with chars().count()/position()
2018-03-22 16:26:48 +13:00
Nick Cameron
0bc0241d2a
Merge pull request #2548 from topecongiro/match-mod
...
Do not collapse block around expr with condition on match arm
2018-03-22 15:40:36 +13:00
Shotaro Yamada
83c8d23cc2
Omit unnecessary UTF-8 decoding
2018-03-22 08:34:53 +09:00
Shotaro Yamada
e5572bbb66
Use take_while
2018-03-22 08:34:36 +09:00
Shotaro Yamada
4757321277
Don't index a string with chars().count()
2018-03-22 08:33:18 +09:00
Seiichi Uchida
5b9b7d5b9f
Do not collapse block around expr with condition on match arm
...
Closes #2376 .
2018-03-21 22:21:08 +09:00
Seiichi Uchida
88589f2ad8
Add matches module
...
`matches` module contains `rewrite_match` and related stuffs.
2018-03-21 22:21:08 +09:00
Nick Cameron
3a138a24a3
Return grouping extern crate
to true by default
2018-03-20 09:54:00 +13:00
Nick Cameron
bf9f175336
reviewer comments and rebase fallout
2018-03-20 09:27:31 +13:00
Nick Cameron
0cf80dcce7
Better handle comments and newlines around erased imports
2018-03-20 09:27:31 +13:00
Nick Cameron
50c95a074a
cargo fmt
2018-03-20 09:27:31 +13:00
Nick Cameron
4cfffbd0a8
Reimplement import reordering.
2018-03-20 09:27:31 +13:00
Nick Cameron
a76d9b529a
format code and tests
2018-03-20 09:27:31 +13:00
Nick Cameron
164cf7d6c9
Reorder imports by default
2018-03-20 09:26:10 +13:00
Seiichi Uchida
adc257f4b3
Put a space before colon that appears after a meta variable
...
Closes #2534 .
2018-03-19 08:27:53 +09:00
Seiichi Uchida
f8109f8e9c
Put spaces around braces
2018-03-19 08:23:53 +09:00
Seiichi Uchida
96a83b57e5
Add some doc comments and factor out add_repeat and add_delimited
2018-03-19 08:23:53 +09:00
Seiichi Uchida
0fd174d5f1
Handle binary operators and lifetimes
2018-03-19 08:23:53 +09:00
Seiichi Uchida
3f7b59ca2b
Break before meta variables when using multiple lines
2018-03-19 08:23:53 +09:00
Seiichi Uchida
95507e3a43
Remove has_prefix_space
2018-03-19 08:23:53 +09:00
Seiichi Uchida
ec71459c44
Format macro arguments with vertical layout
2018-03-19 08:23:53 +09:00
Seiichi Uchida
84ea306d32
Remove unit tests
2018-03-19 08:23:53 +09:00
Nick Cameron
56d2a08db0
Merge pull request #2541 from topecongiro/issue-2358
...
Skip name replacement in comments and strings
2018-03-19 08:55:35 +13:00
Seiichi Uchida
1a969cff7f
Remove FIXME about duplicated code
2018-03-17 14:59:39 +09:00
Seiichi Uchida
d7188654ea
Skip name replacement in comments and strings
2018-03-17 14:59:26 +09:00
Seiichi Uchida
ca6fc67e60
Fix print_version
2018-03-17 12:16:15 +09:00
topecongiro
a03b3b7d6f
Cargo update
...
Remove `rustc-ap-rustc_errors` from dependencies since it
is re-exported from `rustc-ap-syntax`.
2018-03-16 08:52:36 +09:00
Nick Cameron
c416246494
Merge pull request #2509 from topecongiro/issue-2493
...
Overflow the last rhs of a binary expression
2018-03-16 07:30:30 +13:00
Seiichi Uchida
eda626cfc9
Call syntax::with_globals before using a parser
2018-03-15 18:55:52 +09:00
Matthew McAllister
c5168405b0
Format attributes on block expressions
2018-03-14 01:16:19 +09:00
Nick Cameron
a0e063a6e1
Merge pull request #2522 from topecongiro/ignore-config-option
...
Add ignore config option
2018-03-12 16:25:31 +13:00
topecongiro
3999d64f12
Simplify IgnoreList
2018-03-12 08:41:19 +09:00
Seiichi Uchida
182b46e0ed
Simplify join_bounds()
2018-03-12 07:57:03 +09:00
Seiichi Uchida
ccd134ed75
Add a test for #2497
...
Closes #2497 .
2018-03-12 07:54:12 +09:00
Seiichi Uchida
b077297179
Modify the placement of the opening brace of trait
...
Put the opening brace on the next line if
1. putting it one the current line exceeds max width.
2. trait bounds uses multiple lines.
2018-03-12 07:54:12 +09:00
Seiichi Uchida
f56039c7e5
Use rewrite_assign_rhs for rewriting bounds
2018-03-12 07:54:12 +09:00
Seiichi Uchida
8f7a90fbef
Add rewrite_assign_rhs_with
...
It is like `rewrite_assign_rhs` but lets us force to put the rhs on the next
line if it uses multiple lines.
This lets us avoid duplicating logic for choosing whether to put stuff on the
same line or the next line.
2018-03-12 07:48:31 +09:00
Nick Cameron
f5ebcd922e
Merge pull request #2513 from rtsuk/master
...
Restore cargo fmt behavior in workspaces
2018-03-12 11:26:12 +13:00
Nick Cameron
bcaeab7a5e
Merge pull request #2527 from topecongiro/issue-2526
...
Check whether '\\'' is char literal or lifetime
2018-03-12 11:25:40 +13:00
Nick Cameron
af5d3cc87b
Merge pull request #2524 from topecongiro/issue-2523
...
Do not unindent code block in comments with unformattable macro
2018-03-12 11:21:09 +13:00
Nick Cameron
124f03b1fc
Merge pull request #2516 from topecongiro/issue-2510
...
Make rewrite_call_inner more generic
2018-03-12 11:18:14 +13:00
David Lukes
a41947cd7d
Enable doctests
...
Doctests were disabled globally because up until #2456 , they were just
formatting examples which were not supposed to compile. Now that there
is one runnable doctest, I disabled the other ones individually (by
adding the ignore directive).
I also added some empty lines around the code blocks to avoid the
following warning and instead ignore the code blocks cleanly:
WARNING: ... Code block is not currently run as a test, but will in
future versions of rustdoc. Please ensure this code block is a runnable
test, or use the `ignore` directive.
See rust-lang/rust#28712 for further details.
2018-03-10 09:57:01 +01:00
Seiichi Uchida
86a427fe32
Check whether '\\'' is char literal or lifetime
2018-03-10 01:19:38 +09:00
Rob Tsuk
ba10a4c48d
Canonicalise the paths
2018-03-09 07:24:40 -07:00
Rob Tsuk
53dcb0d09d
Restore cargo fmt behavior in workspaces
...
Previously, cargo fmt invoked without parameters would
only format the crate in the current directory, even if
the crate was part of a workspace. This patch restores
that behavior.
2018-03-09 07:24:40 -07:00
topecongiro
2188b464b0
Format macro call with item arguments
2018-03-09 17:17:55 +09:00
topecongiro
eaab592cb8
Avoid unindenting code block in comment with unformattable macro
...
`format_code_block` formats the given `code_snippet` by enclosing it inside
`fn main` block. Previously we did not add indentation to the `code_snippet`
before formatting it. This works fine as long as we can format the given
`code_snippet`, but when the code block has unformattable macro, they gets
unindented. This commit fixes it by adding proper indentation before formatting
the `code_snippet`.
For example, when formatting the following code block,
```rust
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
```
previously we enclosed it like this:
```rust
fn main() {
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
}
```
with this PR, we will enclose it like this:
```rust
fn main() {
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
}
```
Closes #2523 .
2018-03-09 17:10:20 +09:00
Seiichi Uchida
6ba7c34433
Use Option<SeparatorTactic> over bool to control trailing comma
2018-03-09 14:07:43 +09:00
Seiichi Uchida
466caa77bb
Make INDENT_BUFFER longer
...
Avoid panicking when indent whose width is 80 called `to_string()`.
2018-03-09 14:07:43 +09:00
Seiichi Uchida
2a99d9704f
Use overflow::rewrite_with_angle_brackets to rewrite generics
2018-03-09 14:07:43 +09:00
Seiichi Uchida
ae629abc41
Add overflow module
...
This commit adds `overflow` module. This module provides two APIs.
`rewrite_with_parens` is basically the same as `rewrite_call_inner`.
`rewrite_with_angle_brackets` is used for rewriting generics and types.
2018-03-09 14:07:43 +09:00
Seiichi Uchida
8943c376bc
Use RefCell for RewriteContext fields
2018-03-09 14:07:05 +09:00
Seiichi Uchida
84ad70c151
Add ignore config option
...
For example, with the following config file, rustfmt will ignore `src/types.rs`,
`src/foo/bar.rs` and every file under `examples/` directory.
```toml
[ignore]
files = [
"src/types.rs",
"src/foo/bar.rs",
]
directories = [
"examples",
]
```
2018-03-09 13:37:52 +09:00
Nick Cameron
dc2f1429e7
Merge pull request #2521 from topecongiro/issue-2520
...
Fix bugs when rewriting doc comments with code block
2018-03-09 15:18:53 +13:00
Nick Cameron
58fb47a8ca
Merge pull request #2519 from topecongiro/nested-parens
...
Remove nested parens
2018-03-09 15:16:30 +13:00
Nick Cameron
5f99ebe628
Merge pull request #2518 from topecongiro/issue-2491
...
Disallow combining parens and brackets in impl
2018-03-09 15:15:21 +13:00
Nick Cameron
1780d68761
Catch panics in the parser before they crash rustfmt
...
Closes #753
2018-03-09 14:59:52 +13:00
Seiichi Uchida
484469899b
Keep code block without correct backticks enclosing
2018-03-09 09:46:43 +09:00
Seiichi Uchida
67fa394e4e
Restrict the width of doc comments with comment_width
...
See the diff in tests/target/enum.rs for an example.
2018-03-09 09:34:13 +09:00
Seiichi Uchida
9344d2ca83
Fix a bug in attr::take_while_with_pred
...
Closes #2520 .
2018-03-09 09:29:08 +09:00
Seiichi Uchida
d45aa55bd6
Remove nested parens
...
And make sure that we do not remove comments within parens.
2018-03-08 20:25:18 +09:00
Seiichi Uchida
71ca21fc23
Disallow combining parens and brackets in impl
2018-03-08 19:08:38 +09:00
Seiichi Uchida
a6b574bfa7
Cargo update and cargo clippy
2018-03-08 18:10:23 +09:00
moe
a2f861730e
fix adds a trailing comma to struct-like macro ( #2490 )
...
* fix adds a trailing comma to struct-like macro
2018-03-08 18:05:39 +09:00
Seiichi Uchida
822dd41ad9
Put lhs and rhs of binop on the same line if lhs is short
2018-03-08 17:21:30 +09:00
Nick Cameron
06d509c25c
Merge pull request #2512 from topecongiro/rustc-ap-syntax
...
Update rustc-ap-syntax
2018-03-08 17:13:05 +13:00
Seiichi Uchida
9889678f56
Replace Option<Vec<&'a ast::pat>> with Vec<&'a ast::Pat>
2018-03-08 12:56:28 +09:00
Nick Cameron
f0d179dd12
Merge pull request #2456 from dlukes/feat/check-license
...
Attempt at checking for license (#209 )
2018-03-08 15:36:27 +13:00