Commit graph

128 commits

Author SHA1 Message Date
Nick Cameron
9589cac62d Format inline attributes on out-of-line modules (#996)
Fixes #838
2016-05-18 22:36:59 +02:00
Daniel Campbell
238fc500ae Altered FmtVisitor to function correctly on generated code 2016-05-06 13:51:48 +12:00
Nick Cameron
90c0f708f5 Merge pull request #971 from kamalmarhubi/update-syntex-syntax
deps: Update syntex_syntax to 0.31.0
2016-05-03 09:19:50 +12: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
Kamal Marhubi
6285d53885 Handle new visibility types more gracefully 2016-05-02 01:05:23 -04:00
Kamal Marhubi
fd38acb86f deps: Update syntex_syntax to 0.31.0
Most of the churn on this bump comes from the `Visibility` enum changing
from

    pub enum Visibility {
        Public,
        Inherited,
    }

to

    pub enum Visibility {
        Public,
        Crate,
        Restricted { path: P<Path>, id: NodeId },
        Inherited,
    }

which require taking `Visibility` by reference in most places. The new
variants are not handled at this point.

Refs #970
2016-05-01 23:06:58 -04: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
mrBliss
b0755581ca Format visibility of associated consts (#953)
Fixes #951.
2016-04-19 20:19:14 +02:00
Nick Cameron
afc8be1d79 Change the logic around breaking multiple patterns in match arms
Refactor to use the list code, don't preserve original stacking-ness, base vertical vs mixed formatting on complexity of the patterns.

Closes #386
2016-04-12 09:23:37 +12:00
Marcus Klaas
9e5c0390a0 Properly format macro's with an extra ident 2016-03-29 23:16:40 +02:00
Connor Brewster
0a665aaceb Fixed nitpicks
Removed unneeded comment
Commented line wrapping conditions
Removed prefix param on `rewrite_associated_type`
Merged `rewrite_associated_static` into `rewrite_static`
Added extra tests
2016-03-15 14:08:12 -06:00
Connor Brewster
7a6eb2197e Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into add-trait-formatting 2016-03-14 20:49:14 -06:00
Connor Brewster
2793b4090c Added tests 2016-03-14 20:05:20 -06:00
Connor Brewster
7ba43ff06e Finished implementing impl and trait type/const 2016-03-14 19:52:07 -06:00
Nick Cameron
da65090050 Merge pull request #857 from kamalmarhubi/codemap-ext
utils: Add CodeMapExt extension trait for span_* methods
2016-03-14 18:00:51 +13:00
Kamal Marhubi
d82d9fc808 utils: Add CodeMapSpanUtils trait for span_* methods
This commit adds a CodeMapSpanUtils extension trait on CodeMap, and
moves some functions to methods there:
  - span_after
  - span_after_last
  - span_before

This better reflects them being lookup methods on the codemap.
2016-03-13 18:14:07 -04:00
Connor Brewster
3163071c75 Updated to latest rustfmt 2016-03-12 11:09:27 -07:00
Connor Brewster
de95b4cefb Removed unneeded pattern matching 2016-03-11 22:50:30 -07:00
Connor Brewster
34651c4f78 Fixed formatting 2016-03-11 22:41:22 -07:00
Connor Brewster
d24c31f74c Added support for associated type rewriting 2016-03-11 22:32:08 -07:00
Connor Brewster
35dfcc0078 Adding trait formatting
trait header formatting finished
generic formatting finished
added basic trait bounds formatting
2016-03-11 14:18:30 -07:00
Kamal Marhubi
589dabda2f deps: Update syntex_syntax to 0.29.1 2016-03-02 13:08:21 -05:00
Kamal Marhubi
14dbac5fd7 config: Use write_mode from config
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
2016-02-08 22:52:44 -05:00
Nick Cameron
a0e85f9a5f Put empty modules on one line
Fixes #463
2016-01-28 19:53:41 +13:00
Kevin Yeh
f01ed6f507 Format item macros 2016-01-22 13:43:18 -06:00
Victor M. Suarez
4f8938c616 Allow for setting of write-mode via config file. FIxes #215
Also from @marcusklaas:
 Refactor code output functions

 Specifically, `write_all_files` no longer returns a HashMap. It would sometimes
 contain items, and sometimes be empty. When "fixed" newlines are required, this
 must now be done with a separate call. The tests use this strategy and should now pass!
2016-01-12 18:12:48 -05:00
Nick Cameron
f8cb1baadd Add normalise_comments option.
So block comments are not converted to line comments
2015-12-10 09:29:03 +13:00
Nick Cameron
e94bd34a06 cargo upgrade, bug fix, and prepare for packaging 2015-12-08 16:19:23 +13:00
Nick Cameron
db72e0390c Merge pull request #664 from marcusklaas/fix-reformat-failurez
Don't include failed item rewrites in missed spans
2015-12-07 08:33:02 +13:00
Ms2ger
1ed36a3a6b Use starts_with to avoid panics. 2015-12-04 16:10:14 +01:00
Marcus Klaas
0fb9611786 Don't include failed item rewrites in missed spans 2015-11-30 23:12:50 +01:00
Markus Westerlind
c61d6d4c3a Format type aliases
Fixes #486
2015-11-26 21:04:49 +01:00
Seo Sanghyeon
2b11d84119 Apply Clippy 2015-11-25 15:39:15 +09:00
Marcus Klaas de Vries
5a3f5bc1f6 Merge pull request #646 from rust-lang-nursery/mulit-file
Handle multiply-referenced files
2015-11-23 21:35:09 +01:00
Jakko Sikkar
411fa40988 update dependencies and fix compile errors 2015-11-23 20:54:33 +02:00
Nick Cameron
2661592d59 Handle multiply-referenced files
Fixes #645
2015-11-23 15:22:00 +13:00
Nick Cameron
9cf8529e33 Implement formatting for impls
Fixes #614
2015-11-23 13:09:00 +13:00
Nick Cameron
ba936766c6 Take rustfmt_skip attribute into account on modules
Closes #632
2015-11-23 09:20:53 +13:00
Marcus Klaas
1b0ae00488 Extract fn rewrite methods from RewriteVisitor 2015-11-22 13:45:51 +01:00
Marcus Klaas
49e2a146b1 Rewrite module declarations 2015-11-21 21:06:29 +01:00
Kevin Yeh
2e9b6dfab4 Combine rewrite_single_line_fn and rewrite_fn 2015-11-19 20:49:24 -06:00
Kevin Yeh
15ec5b2912 Fix empty body format, add fn_empty_single_line option, refactor block tests 2015-11-19 20:45:02 -06:00
Kevin Yeh
fbd1398c92 Implement Rewrite for ast::Stmt 2015-11-19 14:23:56 -06:00
Kevin Yeh
4d7de5a16e Support single-line functions
By default, places functions with empty bodies on one line.
If the function has only one expression or statement that fits on one line, the 'fn_single_line' option can be used.
2015-11-19 14:23:56 -06:00
Nick Cameron
56a765ef05 Rustup 2015-11-16 14:16:46 +13:00
Nick Cameron
3dc0b804f1 Don't strip semi-colons from expressions with non-void type since it can change semantics 2015-11-09 13:23:19 +13:00
Eli Friedman
1c235de97d Fix crash speculatively parsing macro arguments as expressions.
The problem is essentially that if we try to parse a token tree using a
CodeMap different from the one the tree was originally parsed with,
spans become nonsense. Since CodeMaps can't be cloned, we're basically
forced to use the original ParseSess for additional parsing.

Ideally, rustfmt would be a bit more clever and figure out how to parse
macro arguments based on the definition of the macro itself, rather than
just guessing that a particular token sequence looks like an expression,
but this is good enough for now.

Fixes #538.
2015-10-27 23:41:32 -07:00
Marcus Klaas
d122ad5adc Address some issues with multiline patterns in let statements 2015-10-24 13:13:15 +02:00
Ravi Shankar
d135217db2 show rustfmt coverage! 2015-10-24 15:22:37 +05:30
Eli Friedman
be9e7dc689 Don't use visit::walk_*. Instead, recurse by hand.
This is much more straightforward to understand given how rustfmt
rewriting works, and it avoids walking into expressions in unexpected
places.

Fixes #513. Fixes #514.
2015-10-21 13:46:13 -07:00