Commit Graph

1235 Commits

Author SHA1 Message Date
rChaser53
7926851bb0 stop to strip 'impl' from impl trait type alias (#3816) 2019-10-04 11:25:16 +09:00
Stéphane Campinas
dbd8936391 fix rust code in comment with a line containing only a hash sign (#3818) 2019-10-02 23:58:25 +09:00
Caleb Cartwright
634e2441c4 tests: add more merge_import tests for #3808 2019-09-26 20:11:11 -05:00
Caleb Cartwright
7c9c0d1a39 fix: merge_imports handling of ::{self} 2019-09-26 20:02:41 -05:00
Caleb Cartwright
3bb266180e fix: handling of empty str for license template path (#3804) 2019-09-24 09:24:05 +09:00
Caleb Cartwright
6b0a447150 feat: support parameter attributes (#3793) 2019-09-20 16:11:52 +09:00
rChaser53
4449250539 fix the error with long string in raw string (#3800) 2019-09-18 22:39:27 +09:00
Caleb Cartwright
dfe87fe946 fix: async expression indentation (#3789) 2019-09-11 09:55:18 +09:00
Seiichi Uchida
5baba86fe5
Update rustc-ap-* crates to 581.0.0 (#3783) 2019-09-06 22:41:03 +09:00
Seiichi Uchida
783948fcbb
Fix handling of match arm's rewrite (#3775) 2019-09-05 11:15:46 +09:00
Andrey
950b288d6f do not remove discriminant value if exists (#3771) (#3772) 2019-09-04 23:01:04 +09:00
Caleb Cartwright
ad5d9fba9b fix formatting mods inside cfg_if macro (#3763) 2019-09-02 18:36:51 +09:00
Seiichi Uchida
deb329a6bb
Forbid adding or removing a block from match arms inside macro calls (#3756) 2019-08-28 20:50:41 +09:00
Valentine Valyaeff
ef00f74ce3 Merge imports fix (#3753) 2019-08-27 11:23:55 +09:00
Seiichi Uchida
1643d726ef
Use correct indent when formatting complex fn type (#3731) 2019-08-16 11:15:28 +09:00
Seiichi Uchida
4871d6467a
Use the correct BytePos for the opening brace position (#3742) 2019-08-13 23:21:55 +09:00
Caleb Cartwright
ac150d016b fix: remove trailing space with empty dyn macro arg (#3737) 2019-08-11 12:49:14 +09:00
Seiichi Uchida
c0cb5eb535
Fix broken tuple pattern (#3729) 2019-08-06 11:09:45 +09:00
Igor Matuszewski
62a32e7b83 Fix most recenty nightly breakage due to removed await! support (#3722) 2019-08-02 23:54:39 +09:00
rChaser53
fe05e88831 fix to build with rustc 1.38.0-nightly (4560cb830 2019-07-28) (#3712) 2019-07-30 14:32:38 +09:00
rChaser53
da2ed095f3 add test for handling double semicolon (#3706) 2019-07-29 05:56:34 +09:00
Seiichi Uchida
983a92c872
Update rustc-ap-* crates to 541.0.0 (#3707) 2019-07-29 05:52:45 +09:00
Seiichi Uchida
c0e616bc1d
Implement closing-block procedure without relying on missed_span module (#3691) 2019-07-17 23:07:12 +09:00
Michele d'Amico
76e2ba25bd #3665: Implemented (#3689) 2019-07-17 09:40:33 +09:00
Seiichi Uchida
66c27c9161
Add #[ignore] to test that runs external process (#3690) 2019-07-16 19:36:23 +09:00
Seiichi Uchida
89940e541f
Fix bugs related to file-lines (#3684) 2019-07-15 22:41:56 +09:00
rChaser53
71289e1d23 fix 'extra comma inserted due to comment' (#3677) 2019-07-14 22:16:47 +09:00
Seiichi Uchida
3200af9785
Do not consider macro-origin await as chain item (#3671) 2019-07-06 14:17:53 +09:00
Stéphane Campinas
1f06a8b361 fix extraction of missing comments when rewriting an empty where clause (#3663) 2019-06-30 12:19:24 +09:00
calebcartwright
d9e42aea74 tests: add tests for assoscaited_type_bounds fix 2019-06-29 10:11:20 -05:00
rChaser53
9986b9d011 fix internal error for long closure types (#3653) 2019-06-25 23:14:19 +09:00
rChaser53
5b0ce0ed12 avoid not to truncate necessary chars (#3640) 2019-06-23 14:32:14 +09:00
Seiichi Uchida
1d19a08ed4
Format the last expression-statement as expression (#3631) 2019-06-17 08:53:39 +09:00
Stéphane Campinas
84c2356590 handle unicode chars in closures (#3632)
The `NotUnicode` branch was unecessarily put on a new line, although it
was within max width:

```diff
 fn baz() {
     let our_error_b = result_b_from_func.or_else(|e| match e {
         NotPresent => Err(e).chain_err(|| "env var wasn't provided"),
-        NotUnicode(_) => Err(e).chain_err(|| "env var was very very very bork文字化ã"),
+        NotUnicode(_) => {
+            Err(e).chain_err(|| "env var was very very very bork文字化ã")
+        }
     });
 }
```
2019-06-17 08:53:17 +09:00
Caleb Cartwright
aa0c9dd212 tests: add normalize_doc_attributes config tests (#3630) 2019-06-16 23:46:25 +09:00
Stéphane Campinas
1cea171cef Improve handling of unicode characters (#3618) 2019-06-12 20:28:29 +09:00
Seiichi Uchida
47a11cd516
Format modules defined in cfg_attr (#3604) 2019-06-09 09:20:39 +09:00
Seiichi Uchida
e71bffb008
Format modules defined inside cfg_if macro calls (#3600) 2019-06-08 18:47:18 +09:00
Stéphane Campinas
87565c42ce
Merge pull request #3607 from topecongiro/issue-3493
Ignore sub-modules when skip-children is used
2019-06-08 09:50:12 +02:00
topecongiro
788a4cbe4f
Add a test for #3493 2019-06-08 14:52:49 +09:00
Marcel Hellwig
eea8af0183 removed bitrig support (#3608)
bitrig support has been removed (by me) in https://github.com/rust-lang/rust/pull/60775
2019-06-07 16:56:30 +09:00
Stéphane Campinas
e0459eb3fe inline the attribute with its item even with the macro_use attribute or when reorder_imports is disabled (#3598) 2019-06-05 00:14:12 +09:00
Seiichi Uchida
2244f326e6
Cargo update (#3559)
Update `rustc-ap-*` crates to 486.0.0.
2019-06-03 23:57:02 +09:00
Stéphane Campinas
e6b60a40d5 stabilise fn_args_density (#3581) 2019-06-03 22:26:48 +09:00
Stéphane Campinas
6d19a8c71d
Merge pull request #3586 from topecongiro/issue-3584
Format trait aliases with where clauses
2019-05-30 09:39:15 +02:00
topecongiro
1c1b4f76bd Add a test for #3583 2019-05-28 00:03:42 +09:00
topecongiro
264417e10d Add tests for trait aliases with where clauses 2019-05-26 21:14:59 +09:00
Seiichi Uchida
b5449ba785
Allow overflowing rhs of unit variant (#3566) 2019-05-22 10:51:19 +09:00
topecongiro
2445f0ea76 Add a test for #3575 2019-05-22 00:10:35 +09:00
Ruben Schmidmeister
9b98dd774e
Merge branch 'master' into normalize-multiline-doc-attributes 2019-05-18 11:27:35 +02:00
Seiichi Uchida
531b2d9136
Merge pull request #3535 from xiongmao86/issue3417
Try to solve issue 3417.
2019-05-16 11:12:56 +09:00
Ruben Schmidmeister
3eb8e4d33c
Ignore unstable key when overriding config 2019-05-13 09:40:16 +02:00
Ruben Schmidmeister
4ac0d35ebb
Only run test on nightly 2019-05-12 23:03:48 +02:00
Ruben Schmidmeister
7fc181d111
Add regression test 2019-05-11 15:03:59 +02:00
xiongmao86
a956a20532 Revert "Revert "Change config option from format_doc_comments to format_code_in_doc_comments.""
This reverts commit 97d7216cd4.
2019-05-10 21:22:52 +08:00
xiongmao86
97d7216cd4 Revert "Change config option from format_doc_comments to format_code_in_doc_comments."
This reverts commit 6a6924c12b.
2019-05-08 16:51:32 +08:00
xiongmao86
6a6924c12b Change config option from format_doc_comments to format_code_in_doc_comments. 2019-05-06 19:45:34 +08:00
xiongmao86
3300bb22a5 Isolate format_doc_comment with normalize_comments and wrap_comments. 2019-05-02 21:11:13 +08:00
Ruben Schmidmeister
703a2eab19
Merge remote-tracking branch 'origin/master' into refactor-apply-newline-style 2019-05-02 06:47:41 +02:00
xiongmao86
a653e30d9f Add tests for #3417. 2019-05-01 16:27:34 +08:00
rchaser53
2c58b205d5 fix Comma in comment causes no formatting 2019-04-29 21:38:38 +09:00
Ruben Schmidmeister
19bd1a44ce
Preserve standalone carriage returns on windows also 2019-04-24 21:01:09 +02:00
Seiichi Uchida
a6daccc229
Merge pull request #3523 from topecongiro/issue-3515
Attempt to format attributes if only they exist
2019-04-24 07:22:55 -07:00
rChaser53
05547d90b5 leave the comment in parentheses of argumentless Fn (#3518) 2019-04-23 16:21:04 -07:00
topecongiro
8d43ca297a Add and update test for #3515 2019-04-23 08:50:44 +09:00
Seiichi Uchida
5dd042c152
Merge pull request #3511 from topecongiro/issue3498
Avoid overflowing item with attributes
2019-04-17 11:40:00 -07:00
Seiichi Uchida
760ec07978
Merge pull request #3510 from topecongiro/issue3509
Fix duplication of attributes on a match arm's body
2019-04-17 11:39:44 -07:00
topecongiro
37959a9da7 Add a test for #3498 2019-04-14 20:44:52 +09:00
topecongiro
0d4fb2403c Add a test for #3509 2019-04-14 20:12:58 +09:00
Christian Duerr
919bee8990
Enable overflow_delimited_expr for structs
This fixes https://github.com/rust-lang/rustfmt/issues/3482.
2019-03-30 18:37:37 +01:00
Shotaro Yamada
c0ff894a22 Fix indexing panic on unicode whitespaces 2019-03-29 20:12:45 +09:00
Seiichi Uchida
17ca7408f3 Do not add a space after empty impl 2019-03-25 11:21:14 +09:00
Seiichi Uchida
288d7db5a9
Merge pull request #3467 from topecongiro/issue-3465
Fix bad performance on deeply nested binary expressions
2019-03-25 07:26:04 +09:00
Stéphane Campinas
cc26c5eaca
Merge pull request #3454 from rchaser53/issue-3434
add new attribute rustfmt::skip::macros
2019-03-24 22:29:56 +01:00
topecongiro
04cc821e4a Add a test for #3465 2019-03-24 18:43:35 +09:00
rchaser53
85b206a32c add test for visitor mad from same context 2019-03-22 18:20:00 +09:00
rchaser53
bbbc1e86eb refrect topecongiro reviews
- &Vec<syntax::ast::PathSegment> => &[ast::PathSegment]
    - remove unnecessary implements
    - transfer skip logic to inside rewrite_macro
    - fix test
    - use util methods in libsyntax
    - use meta_item_list directly
    - avoid no_entry.rs for test using module system
    - add logic to skip rustfmt::skip::macros only
    - remove base_skip_macro_names
    - remove Rc
    - use clone to append skip_macro_names
2019-03-21 21:45:39 +09:00
Seiichi Uchida
94b381f1cc
Merge pull request #3464 from topecongiro/issue-3463
Avoid duplication on the presence of spaces between macro name and !
2019-03-21 20:32:29 +09:00
topecongiro
017e491a17 Avoid duplication on the presence of spaces between macro name and ! 2019-03-21 15:58:39 +09:00
Stjepan Glavina
1fa06ecf1e Fix formatting of async blocks 2019-03-20 18:18:02 +01:00
rchaser53
1f8553d66f add new attribute rustfmt::skip::macros
add test for function not having attribute
2019-03-21 00:18:51 +09:00
Seiichi Uchida
c9479de9a7 Avoid panic on macro inside deeply nested block
Closes #3457.
2019-03-19 10:50:44 +09:00
Seiichi Uchida
f048fc0fde
Merge pull request #3448 from topecongiro/use-new_sub_parser_from_file
Support path clarity module even when we start from internal module
2019-03-17 14:04:11 +09:00
Seiichi Uchida
ad6d89842a
Merge pull request #3453 from scampi/issue-3423
remove trailing whitespaces in missing spans
2019-03-17 14:01:49 +09:00
topecongiro
7fc4e418bf Tweak test settings 2019-03-17 12:33:18 +09:00
topecongiro
9d281b44c3 Add a test for #3427 2019-03-17 12:21:21 +09:00
Stéphane Campinas
2d5bc69475
remove trailing whitespaces in missing spans 2019-03-16 12:23:02 +01:00
Seiichi Uchida
ce5cccc32c
Update rustc-ap-* crates to 407.0.0 (#3447) 2019-03-14 22:50:53 +09:00
Seiichi Uchida
331a0500ce
Merge pull request #3441 from rchaser53/const-generics
implement for const generics
2019-03-14 22:50:20 +09:00
rchaser53
f0c861bfa9 implement for const generics 2019-03-13 03:58:23 +09:00
Seiichi Uchida
5f3dfe6c51
Format the if expression at the end of the block in a single line (#3338) 2019-03-11 23:18:43 +09:00
rchaser53
8e3ef3e3a9 fix not to remove comment in the case of no arg 2019-03-05 00:18:33 +09:00
rchaser53
dec3902076 leave post comment for self 2019-03-02 17:33:43 +09:00
rchaser53
ae7330eea4 leave pre comment for self 2019-02-24 22:05:08 +09:00
rchaser53
0e408bf83c add config inline_attribute_width
If the line width is width within config width, attribute is inline.
I don't want to change default rustfmt behavior, so config default value is 0.

- fix description
- fix test comment
- remove unnecessary clone
- remove unnecessary test file
- fix test for β version
- attributes => attribute
2019-02-23 13:40:11 +09:00
Alexander Regueiro
7a3b7c9275 Various cosmetic improvements (#3403) 2019-02-19 11:56:42 +09:00
Stéphane Campinas
e5284b1377
Merge pull request #3334 from rchaser53/issue-3227
fix Inconsistency between  loop  and while
2019-02-15 13:12:42 +01:00
rchaser53
c4b6b52ada remove tests/source/issue-3227/one.rs 2019-02-15 18:11:49 +09:00
rchaser53
7d9a2ef96d version/2: Align loop and while formatting
The loop and while formatting was diverting as  `loop`
was not being moved to a new, indented block, as `while`
was.

This commit fixes this inconsistency but pins it to version 2
to avoid changing existing code.
2019-02-14 10:06:29 +09:00
topecongiro
96a3df3b5c Format visibility on trait alias 2019-02-12 10:16:12 +09:00
topecongiro
9a7ea6aacb Handle a macro argument with a single keyword
Closes #3331.
2019-02-11 00:34:23 +09:00
Seiichi Uchida
c4611a0e6b
Merge pull request #3326 from scampi/issue-3302
fix formatting of strings within a macro
2019-02-11 00:32:06 +09:00
Seiichi Uchida
44d6f7c43e
Merge pull request #3332 from rchaser53/issue-3234
add issue-3234 test
2019-02-08 12:35:50 +09:00
rchaser53
5e530980b7 add issue-3234 test
this issue is already resolved
2019-02-08 00:05:54 +09:00
Stéphane Campinas
813aa79567
fix formatting of strings within a macro 2019-02-07 00:05:05 +01:00
Seiichi Uchida
1ae032652c Add a test for #3313 2019-02-06 23:10:27 +09:00
Stéphane Campinas
4c5ef9a2f5
remove unecessary source test file 2019-02-05 21:19:41 +01:00
rchaser53
5fcb7507ca fix Removed indentation after nested comments error 2019-02-05 13:12:45 +09:00
Seiichi Uchida
bfcfaf1743
Merge pull request #3308 from topecongiro/issue-2835
Prioritize single_line_fn and empty_item_single_line over brace_style
2019-02-04 00:11:01 +09:00
Seiichi Uchida
efd6fda43f
Merge pull request #3311 from rchaser53/issue-3295
fix "internal error: left behind trailing whitespace" with long lines
2019-02-04 00:10:42 +09:00
rchaser53
c2534f5324 fix "internal error: left behind trailing whitespace" with long lines 2019-02-01 19:58:38 +09:00
topecongiro
0142e961ad Prioritize single_line_fn and empty_item_single_line over brace_style
When either one of these two options are set to `true`, each should take
precedence over the brace_style option.

This commit does not introduce any formatting change to the default
configuration, so no version gate is required.
2019-02-01 00:22:47 +09:00
topecongiro
154ccf6a02 Do not force trailing comma when using mixed layout 2019-01-31 23:44:58 +09:00
Seiichi Uchida
923da60f72
Merge pull request #3298 from topecongiro/issue-3272
Use the same rule between function and macro
2019-01-30 00:36:55 +09:00
topecongiro
181ca427dc Use the same rule with macro and function calls with a single chain 2019-01-28 23:05:42 +09:00
topecongiro
5df0a18849 Avoid putting a long macro call in a single line 2019-01-28 23:05:39 +09:00
Seiichi Uchida
36c9dc646c
Merge pull request #3293 from scampi/issue-3241
Keep leading colons for global paths
2019-01-27 23:14:57 +09:00
Stéphane Campinas
2125ad272e
fix glob and nested global imports 2019-01-27 12:46:14 +01:00
Seiichi Uchida
203e6d265d
Merge pull request #3294 from rchaser53/issue-3278
change new line point in the case of no args
2019-01-27 16:28:28 +09:00
Seiichi Uchida
35d5ef7828
Apply rustfmt::skip on imports (#3289) 2019-01-27 16:26:09 +09:00
rchaser53
f92f3e3bda add the version gate to the code and test 2019-01-27 14:38:57 +09:00
rchaser53
7b996542cc change new line point in the case of no args 2019-01-26 00:16:51 +09:00
Nick Cameron
d2e91b5b68
Merge pull request #3284 from scampi/issue-3270
recognize strings inside comments in order to avoid indenting them
2019-01-17 20:22:36 +13:00
Stéphane Campinas
083a20fb1a
version-gate the formatting of commented strings 2019-01-16 23:06:28 +01:00
wada314
a01990c4d0 Use Unicode-standard char width to wrap comments or strings. (#3275) 2019-01-15 08:41:09 +09:00
Stéphane Campinas
baa62c609e
recognize strings inside comments in order to avoid indenting them
Close #3270
2019-01-10 21:04:16 +01:00
Nick Cameron
2c204c11d1
Merge pull request #3260 from topecongiro/issue-3004
Do not modify original source code inside macro call
2019-01-07 17:39:05 +13:00
Seiichi Uchida
996d5e8d6c
Fix shape when formatting return or break expr on statement position (#3259) 2018-12-25 18:20:29 +09:00
Shohei Wada
6a316e3ac7 Add test cases. 2018-12-24 06:18:00 +09:00
topecongiro
30cda580bd Add a test for #3004 2018-12-20 01:13:18 +09:00
Stéphane Campinas
b73a602d6e
version-gate the trailing semicolon change of return statements inside a match arm 2018-12-14 09:54:23 +01:00
Stéphane Campinas
d03d9a45ef
end expressions like return/continue/break with a semicolon
Close #3213
2018-11-29 20:39:07 +01:00
Stéphane Campinas
40174e9481
fix the visitor's starting position when visiting a labelled block
Close #3217
2018-11-28 22:50:17 +01:00
Nick Cameron
3d01fc186a
Merge pull request #3177 from kestred/kstenerson/preserve-brace-leading-ws
Format brace-delimited macros with a space after the name
2018-11-19 13:35:09 +13:00
Seiichi Uchida
1dd54e67a1
Prefer to break arguments over putting output type on the next line (#3190) 2018-11-18 21:31:40 +09:00
Kevin Stenerson
bc5124e016 Always enforce exactly one space between macro! and braces ({}) 2018-11-17 11:53:11 -07:00
Kevin Stenerson
1a3bc79c68 Preserve possibly one whitespace for brace macros 2018-11-16 14:57:43 -07:00
Nick Cameron
5dbe107f56 test for #3128 2018-11-15 21:38:23 +13:00
Stéphane Campinas
a4e97fa17b
compute the span after a struct-like item based on the ident description 2018-11-13 21:10:30 +01:00
Nick Cameron
4e2f741917
Merge pull request #3175 from kestred/kstenerson/delimited-overflow
Add config option to more aggressively allow overflow
2018-11-09 15:46:23 +13:00
Kevin Stenerson
3330e6717e Add tests that include comments before the overflow-able params 2018-11-08 19:38:01 -07:00
Nick Cameron
c4cc479fcd
Merge pull request #3183 from scampi/issue3182
do not wrap comments in doctest to avoid failing doctest runs
2018-11-09 15:14:44 +13:00
Stéphane Campinas
a5043a81be
do not wrap comments in doctest to avoid failing doctest runs 2018-11-07 16:48:39 +01:00
Stéphane Campinas
9467033a8e
fix the logic for retaining a comment before the arrow in a match 2018-11-07 15:00:33 +01:00
Kevin Stenerson
cd8bb50aea Trim the indentation on macros which heuristically appear to use block-style indentation (#3178) 2018-11-07 17:49:53 +09:00
Kevin Stenerson
25b828d35f Add config option to more aggressively allow overflow 2018-11-05 21:12:40 -07:00
Nick Cameron
16d5f507b6
Merge pull request #3172 from scampi/issue3153
trim the start of a line when wrapping an item in preparation for formatting
2018-11-06 10:23:30 +13:00
Stéphane Campinas
5a2ebdddcc
trim the start of a line when wrapping an item in preparation for formatting 2018-11-05 20:22:06 +01:00
Rémy Rakic
83d1d9aa14 normalize_doc_attributes: remove leading whitespace from the doc comment opener
Remove possible whitespace from the `CommentStyle::opener()` so that the literal itself has control over the comment's leading spaces.

This is most useful for tools, such as bindgen, to allow for example: machine-readable comments with precise syntax rules, or idempotently round-tripping between the proc-macro API and rustfmt.
2018-11-05 18:24:36 +01:00
Stéphane Campinas
7132fe03a0
fix alignment of a struct's fields with the visual style
- rewrite_with_alignment was called from the expr module with the wrong
  shape that missed the extra offset needed for the visual style
- rewrite_with_alignment was indenting the given shape although that
  should have been the caller's responsability
2018-11-04 23:41:21 +01:00