Commit Graph

442 Commits

Author SHA1 Message Date
sinkuu 0dc3fc7a2c Fix formatting empty block comments (/**/)
issue #1086
2016-07-09 22:56:50 +09:00
Nick Cameron 664bf3eae7 Merge pull request #1054 from sanxiyn/loop-width
Fix width computation in Loop::rewrite
2016-06-14 08:32:02 +02:00
Seo Sanghyeon 921b563847 Fix width computation in Loop::rewrite 2016-06-12 20:37:15 +09:00
Kamal Marhubi 5361f61110 Include git commit and worktree status in version output (#1060)
This will help in debugging issues as rustfmt gets more users.

If the working tree is clean, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b)

If the working tree is dirty, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b worktree dirty)

If git is unavailable, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (git commit unavailable)

To avoid rebuilds on changing tests, the build script will only rerun if
files under src/ are changed. This means the actual git status may show
changed files and this would not show up in the version. This should not
be an issue as files not in src/ should not affect the build output.
2016-06-12 10:38:03 +02:00
Marcus Klaas 88fdf9a6e3 Fix integer underflow in extra_offset 2016-06-10 16:17:10 +02:00
Nick Cameron 3d4bc8c84a Merge pull request #1033 from marcusklaas/assignment-break
Add test for general assignment breaks
2016-06-05 18:06:08 +01:00
Marcus Klaas 05188deadc Add test for general assignment breaks 2016-06-04 11:00:01 +02:00
Marcus Klaas b3488c6186 Fix constraints on pattern formatting of else arms 2016-06-03 23:18:19 +02:00
Nick Cameron 0087306761 Merge pull request #1016 from rust-lang-nursery/try-double-indent
Treat chains with just expr? specially.
2016-06-01 12:28:36 +01:00
lqd b6263735b1 Add support for the default keyword (#1025)
Adds support for Defaultness on impl methods.
Fixes #945
2016-05-31 19:48:49 +02:00
Kamal Marhubi 9fa5a91fc5 visitor: Handle specified line ranges in visit_stmt
This commit adds a very rough implementation of handling the specified
line ranges in `config.file_lines_map` for statements. It reformats a
statement if its span is fully contained in the set of lines specified
for the file.

The implementation here is intended as a proof of concept, and
demonstration that the machinery added in the preceding commits is
functional. A final implementation would likely hook in via the
`Rewrite` trait.

Refs #434
2016-05-31 01:33:11 +02:00
Marcus Klaas 98c0570a28 Format non-statement if-else expressions on a single line 2016-05-29 17:58:38 +02:00
Nick Cameron bbb6038b92 Treat chains with just expr? specially.
Fixes #1004
2016-05-29 09:32:48 +01:00
Kamal Marhubi 66cac1f3e9 Handle pub(restricted) (#1013)
* Handle pub(restricted)

This commit properly handles pub(restricted) as introduced in RFC 1422
[0]. The syntax support was added in #971, but they were not correctly
formatted.

[0] https://github.com/rust-lang/rfcs/blob/master/text/1422-pub-restricted.md

Fixes #970

* Drop #[inline] attribute on format_visibility

* Make newly non-failing functions return String

The change to `format_visibiilty` means that `format_header` and
`format_unit_struct` can no longer fail. Their return type is updated to
reflect that.
2016-05-28 00:58:25 +02:00
Nick Cameron 6e01fac285 Merge pull request #1008 from rust-lang-nursery/hrtb
Don't ignore universal quantification in function types
2016-05-28 10:08:00 +12:00
Nick Cameron 0fae34dfa1 Don't ignore universal quantification in function types
Fixes #1006
2016-05-27 15:09:04 -07:00
Nick Cameron d633e831ba Merge pull request #1009 from rust-lang-nursery/fn-args-1
Fix off by 2 error in function sigs
2016-05-28 10:04:04 +12:00
Nick Cameron 882ef8cc82 Fix off by 2 error in function sigs
Fixes #1000

This is a little conservative in some cases, but better than being wrong in others.
2016-05-27 15:05:15 -07:00
Nick Cameron d6bcfceb7e Don't put a newline before ? when it is the second sub-expression in a chain (#1012)
Fixes #1003
2016-05-27 10:33:19 +02:00
Nick Cameron 775de8a62b Optionally put short struct variants on one line (#997)
Closes #418
2016-05-18 22:38:49 +02:00
Nick Cameron 9589cac62d Format inline attributes on out-of-line modules (#996)
Fixes #838
2016-05-18 22:36:59 +02:00
Srinivas Reddy Thatiparthy 952a6beb51 change normalise spelling to American version - normalize as American english is more common across programming community 2016-05-15 22:24:46 +05:30
Nick Cameron 9b05461666 Write each file as it is formatted (#991)
The old behaviour stored everything in memory until we were finished. Now we write as soon as we can.

This gives better behaviour when formatting large programs, since there is some progress indication. It also opens the door to optimising memory use by not storing everything in memory unless it is required (which it still might be). That is left as future work though.
2016-05-15 11:41:05 +02:00
Marcus Klaas eae2921e14 Bootstrap it. Hard. 2016-05-12 21:50:43 +02:00
Marcus Klaas cd158cecc8 Add try macro to try shorthand conversion tests 2016-05-12 21:15:06 +02:00
Marcus Klaas ee7b5805fc Format try shorthand 2016-05-09 20:07:59 +02:00
Aaron Gallagher 96d59366fc Don't misplace the :: on associated items.
The rewritten location of the :: on global paths for qpaths was wrong.
2016-05-02 17:11:22 -07:00
Nick Cameron c696dcf8da Handle attributes on modules (#968)
* Handle attributes (including doc comments) on inline modules

Closes #22
Closes #684

* Tweak the rules for changing indentation in comments (to do it less often).
2016-05-02 10:54:25 +02:00
Nick Cameron de2b8d98ea Merge pull request #960 from rust-lang-nursery/big-closures
Block indent large closures and field/method chains
2016-04-28 09:49:08 +12:00
Nick Cameron fcd2021583 Add visual indent tests for chains 2016-04-28 08:08:54 +12:00
Nick Cameron 9188ec0f7f Bail out on recovered errors. (#965)
Closes #915
Closes #930
Closes #931
2016-04-27 21:08:44 +02:00
Nick Cameron a9c3108c9c Change defaults and update tests and source
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-22 19:18:48 +12:00
Nick Cameron 9761cf71d8 Tests 2016-04-22 18:53:39 +12:00
mrBliss b0755581ca Format visibility of associated consts (#953)
Fixes #951.
2016-04-19 20:19:14 +02:00
Marcus Klaas f364a7ec43 Add option to force explicit extern ABI's 2016-04-18 18:39:40 +02:00
Thia Wyrod d773cc5327 Added loop/match brace style control option
This adds Allman style loop/match braces as an alternative to the current
default style.
2016-04-17 14:52:04 -06:00
Thia Wyrod 5bd6036218 Added option to configure if/else brace style 2016-04-17 14:48:51 -06:00
Marcus Klaas 63f0fc9641 Fix off-by-one error in pattern formatting 2016-04-16 22:42:52 +02:00
Nick Cameron 41e037da7e Merge pull request #941 from marcusklaas/type-ascription
Format type ascription
2016-04-16 16:42:56 +12:00
Marcus Klaas d98e22c971 Check length of break and continue expressions 2016-04-15 18:11:29 +02:00
Marcus Klaas 45a83d18cc Format type ascription 2016-04-15 17:56:43 +02:00
Nick Cameron 7a758ea20a Fix closures again (#937)
* Fix closures again

Closes #934

Oh god, the rules for parsing closures are even more messed up than I thought - whether or not there is an inner block or depends not only on if there are braces, but also if there is a return type for the closure (!) and if there are statements in the block.

* Fix overflow
2016-04-15 10:52:08 +02:00
Nick Cameron e1d33df302 Merge pull request #923 from matklad/proper-exit-code
return non-zero exit code if there are errors
2016-04-15 13:50:10 +12:00
Aleksey Kladov 77350e49b5 return non-zero exit code if there were errors 2016-04-15 02:51:50 +03:00
Nick Cameron 7bda8659ec Merge pull request #935 from marcusklaas/issue-770
Add regression test for issue 770
2016-04-15 08:13:26 +12:00
Marcus Klaas de Vries 320df84e96 Fix brace indentation for impl items (#927) 2016-04-14 20:42:38 +02:00
Marcus Klaas ba9d64aba5 Add regression test for issue 770 2016-04-14 20:41:23 +02:00
Nick Cameron c7780fdfd8 Be careful about where we change braces in closures
And some general refactoring of closure code.

Fixes #863
2016-04-14 09:05:42 +12:00
Nick Cameron 09440b55ef Merge pull request #921 from matklad/more-unification
unify format_string and format_file
2016-04-12 11:05:06 +12:00
Nick Cameron eadc878de0 Handle variadic function types
Closes #842
2016-04-12 10:47:35 +12:00