Seiichi Uchida
cf4ab38f67
Hide parse error in format_snippet()
2018-01-11 15:19:23 +09:00
Nick Cameron
1ced6d1037
Minor refactoring in macros.rs
2018-01-11 17:40:05 +13:00
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