Commit graph

53 commits

Author SHA1 Message Date
Seiichi Uchida
10c3632078 Format source codes 2017-06-01 12:08:25 +09:00
topecongiro
86856491bc Format source codes 2017-05-25 16:08:08 +09:00
Nick Cameron
393ba27311 Remove dependency on Itertools 2017-05-25 16:23:07 +12:00
Nick Cameron
93c556c6ba Merge pull request #1578 from topecongiro/poor/macro
Use original code snippet for macro which contains invalid syntax
2017-05-24 11:43:10 +12:00
topecongiro
e3eec44690 Return original snippet when macro contains invalid syntax 2017-05-24 07:24:31 +09:00
topecongiro
04bb5d8929 Format source codes 2017-05-24 00:07:02 +09:00
topecongiro
13af774e55 Fix weird indentaion in chain 2017-05-23 11:37:12 +09:00
topecongiro
d16a0a399e Implement 'vec![expr; expr]' 2017-05-23 11:32:09 +09:00
Michael Killough
c3c2e823cb Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into config 2017-05-18 13:05:19 +07:00
topecongiro
d7b6f1199f Format source codes 2017-05-16 23:24:38 +09:00
Michael Killough
c0bdbfa531 Switch to accessing config items via method.
Preparation for #865, which proposes adding a flag which outputs which
config options are used during formatting.

This PR should not make any difference to functionality. A lot of this
was search-and-replace.

Some areas worthy of review/discussion:

 - The method for each config item returns a clone of the underlying
   value. We can't simply return an immutable reference, as lots of
   places in the code expect to be able to pass the returned value as
   `bool` (not `&bool). It would be nice if the `bool` items could
   return a copy, but the more complex types a borrowed reference... but
   unfortunately, I couldn't get the macro to do this.
 - A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding
   config items by modifying the fields of the `Config` struct directly.
   They now use the existing `override_value()` method, which has been
   modified to return a `Result` for use by `src/bin/rustfmt.rs`. This
   benefits of this are that the complex `file_lines` and `write_mode`
   strings are now parsed in one place (`Config.override_value`) instead
   of multiple. The disadvantages are that it moves the compile-time
   checks for config names to become run-time checks.
2017-05-16 15:47:09 +07:00
Seiichi Uchida
762db5138e Format source codes 2017-05-15 22:55:45 +09:00
Seiichi Uchida
7ec78711f2 Prevent rewriting closure block to expr inside macro 2017-05-13 18:32:25 +09:00
Nick Cameron
c546f1b396 Merge pull request #1454 from topecongiro/match
Format nested mathces properly.
2017-05-02 10:40:31 +12:00
topecongiro
02cf515be6 Format source codes 2017-04-24 16:50:11 +09:00
topecongiro
02c9ac93be Prohibit long return val from 'rewrite_closure_block' 2017-04-17 23:17:17 +09:00
Ryan1729
4c4f70957b fix bug by adding boolean argument
Signed-off-by: Ryan1729 <Ryan1729@gmail.com>
2017-04-03 17:39:14 -06:00
Nick Cameron
5305bc8436 test fallout 2017-03-28 11:25:59 +13:00
Nick Cameron
5fb1140688 fallout - source reformatting 2017-03-28 11:14:47 +13:00
Nick Cameron
e4efa22983 Source formatting fallout 2017-03-28 10:58:41 +13:00
Nick Cameron
9eb78a3333 Fallout 2017-02-23 13:15:48 +13:00
Nick Cameron
b35906dbce WIP 2017-02-21 16:35:05 +13:00
Nick Cameron
428339fdc3 Refactor indent and width into Shape struct 2017-01-31 08:35:23 +13:00
Erick Tryzelaar
e67ffcfb21 Update to the latest syntex module
One notable feature is this this adds support for the experimental
`let x = loop { ... break $expr; }` syntax. This also includes a
test for formatting all the break and continue variations.
2016-12-23 11:20:07 -08:00
Nick Cameron
d3eba76e4d update Serde, etc.
Lots of changes to how closures work
2016-11-21 11:02:18 +13:00
Bekh-Ivanov Aleksey
935286755c Stripping trailing commas and spaces from vec! elements (#1219)
* Stripping trailing commas and spaces from `vec!` elements

* Stripping trailing commas and spaces ONLY from `vec!` elements

* Added comment
2016-11-14 17:42:15 +13:00
Philip Craig
c4a7a7108e Preserve macro formatting if we can't rewrite it 2016-10-03 14:14:56 +10:00
Nick Cameron
4418fab4f2 Update to latest Syntex
+ Cargo update
+ 0.6.2 release
2016-09-16 15:28:02 +12:00
sinkuu
a3c63fdef9 Run clippy 2016-08-29 08:57:27 +09:00
Kamal Marhubi
bd10af127e utils: Move codemap related utilities to a dedicated module
This commit adds a `codemap` module, and moves the `CodemapSpanUtils`
added in #857 to it. This is preparation for adding more `Codemap`
specific utilities.

Refs #434
2016-05-31 00:49:26 +02:00
Marcus Klaas
cd158cecc8 Add try macro to try shorthand conversion tests 2016-05-12 21:15:06 +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
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
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
Kamal Marhubi
a8c27c7086 macros: Cancel DiagnosticBuilder when not emitting error
The error handling in libsyntax changed to use a `DiagnosticBuilder`
type in the `Err` variant of `PResult`. This type has `emit()` and
`cancel()` methods. Once created, errors must be emitted or canceled; if
not, the `Drop` impl on `DiagnosticBuilder` will panic.

The first syntex_syntax release to include this change was v0.25.0. The
bump from v0.23.0 to v0.29.1 in #847 did not add any `cancel()` calls,
even though at least one was required. There may be others not caught in
this commit.
2016-04-07 18:05:57 -04:00
Marcus Klaas de Vries
50820c6a43 Merge pull request #883 from marcusklaas/macro-with-name
Properly format macro's with an extra ident
2016-03-30 02:03:28 +02:00
Marcus Klaas
9e5c0390a0 Properly format macro's with an extra ident 2016-03-29 23:16:40 +02:00
Marcus Klaas
0e0cf976c9 Fix issues with empty macros with curly braces 2016-03-27 13:44:40 +02: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
Kamal Marhubi
8b601812a6 cleanup: Use const instead of static 2016-02-01 23:40:45 -05:00
Kevin Yeh
f01ed6f507 Format item macros 2016-01-22 13:43:18 -06:00
Seo Sanghyeon
17c8fb10ea Remove unused imports 2015-11-27 23:38:05 +09:00
Nick Cameron
56a765ef05 Rustup 2015-11-16 14:16:46 +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
Alex Crichton
579fb34417 Remove dependence on rustc/rustc_driver, use syntex
Instead just parse manually with the `syntex_syntax` crate which is a clone of
libsyntax on crates.io which builds on stable Rust.
2015-10-23 13:46:14 -07:00
Alex Crichton
36abfe5dc2 Remove usage of many unstable features
This removes usage of:

* PathExt
* split_last
* split_last_mut
* catch_panic

The catch_panic one was a little tricky as the ident interner needed to be
cloned across threads (a little unsafely), but it should otherwise be good to
go.
2015-10-23 13:46:14 -07:00
Marcus Klaas
a9bd695723 Format vec! macro using brackets 2015-10-16 22:55:42 +02:00
Marcus Klaas
8daf4c3a31 Prevent panics on list-like macro uses with trailing commas 2015-10-08 22:04:17 +02:00
Nick Cameron
99d71a164a Changes to source formatting 2015-09-26 13:58:12 +12:00