Commit Graph

1325 Commits

Author SHA1 Message Date
Nick Cameron
240dba5467 Merge pull request #1007 from kamalmarhubi/basic-line-ranges-v2
Add infrastructure for formatting specific line ranges
2016-05-31 08:45:45 +01:00
Kamal Marhubi
e252100cf6 README: Explain that --file-lines ranges are 1-based 2016-05-31 01:35:54 +02:00
Kamal Marhubi
66483017f6 Explain that FileLines cannot be given in rustfmt.toml
This adds a note to both the `--config-help` output for `file_lines`,
and to the panic message on attempting to deserialize a `FileLines`
struct.
2016-05-31 01:35:18 +02:00
Kamal Marhubi
8775fe4172 codemap: Add module description 2016-05-31 01:34:42 +02:00
Kamal Marhubi
a83f1a197e Add copyright notices to added files 2016-05-31 01:34:07 +02:00
Kamal Marhubi
bef5d095a4 rustfmt: Add option to specify line ranges for formatting
This commit adds the `--experimental-file-lines` option to rustfmt. This
allows specifying line ranges to format from the command line.

Refs #434
2016-05-31 01:33:58 +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
Kamal Marhubi
c311b30cac Add type to represent collection of lines in files
This commit adds a type to represent lines in files, and adds it to the
`Config` struct. It will be used for restricting formatting to specific
lines.

Refs #434
2016-05-31 01:24:38 +02:00
Kamal Marhubi
ed27b4799a codemap: Add utilities for looking up line ranges of spans
This commit adds extension methods to `Codemap` to allow looking up line
ranges for spans.

Refs #434
2016-05-31 00:49:31 +02: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
Kamal Marhubi
80c56a01ff visitor: Add debug log for FmtVisitor::visit_stmt() 2016-05-31 00:43:48 +02:00
Kamal Marhubi
7f0d87cc51 Derive Debug for the Input enum 2016-05-31 00:43:48 +02:00
Nick Cameron
5436977bd5 Merge pull request #1017 from marcusklaas/tweak-if-else
Format non-statement if-else expressions on a single line
2016-05-31 01:57:29 +12:00
Nick Cameron
3a87aa5318 Merge pull request #1022 from kamalmarhubi/update-syntex-syntax
deps: Update syntex_syntax to 0.33
2016-05-31 01:25:09 +12:00
Nick Cameron
0678152e73 Merge pull request #1015 from srinivasreddy/readme
Add section - Installing from source
2016-05-31 01:24:07 +12:00
Kamal Marhubi
120e1a0b51 deps: Update syntex_syntax to 0.33
This bump brings syntex_syntax support for `..` in tuple and tuple
struct patterns, which come from RFC 1492:
  https://github.com/rust-lang/rfcs/blob/master/text/1492-dotdot-in-patterns.md

These new patterns are not properly handled in this PR; instead #1021
tracks supporting them.

Refs #1021
2016-05-30 14:53:04 +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
Srinivas Reddy Thatiparthy
18489b3648 Add section - Installing from source 2016-05-28 21:08:33 +05:30
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
Nick Cameron
78f8b6c2e3 Merge branch 'master' of github.com:rust-lang-nursery/rustfmt 2016-05-18 10:02:04 +12:00
Nick Cameron
ff3ff5aa87 Handle parser errors better 2016-05-18 09:58:51 +12:00
Nick Cameron
d0720a00a1 Fall back to basic stdout if we can't unwrap a fancy terminal (#995)
fixes #978
2016-05-17 23:25:57 +02:00
Nick Cameron
c8ba6ee5a2 Merge pull request #992 from srinivasreddy/master
change  normalise spelling to American version -
2016-05-16 10:15:29 +12:00
Nick Cameron
fcf33fbc2a Note in te README about compiler version
Closes #990
2016-05-16 10:09:53 +12: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
Nick Cameron
67edc325c6 0.5 release 2016-05-13 12:34:55 -07:00
Nick Cameron
c1949f52e1 Merge pull request #893 from marcusklaas/try-shorthand
Try shorthand
2016-05-12 16:07:42 -07: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
Nick Cameron
fc2549b576 Merge pull request #981 from DanielJCampbell/generated
Altered FmtVisitor to function correctly on generated code
2016-05-06 14:02:56 +12:00
Daniel Campbell
238fc500ae Altered FmtVisitor to function correctly on generated code 2016-05-06 13:51:48 +12:00
Nick Cameron
b59b0497d3 Merge pull request #980 from DanielJCampbell/visibility
Changed modules & visitor mods to public, set filemap::write_file public
2016-05-06 13:09:46 +12:00
Daniel Campbell
4a2db3ec6c Changed modules & visitor mods to public, set filemap::write_file public 2016-05-06 12:44:18 +12:00
Nick Cameron
635581432f Merge pull request #979 from kamalmarhubi/update-syntex-syntax
deps: Update syntex_syntax to 0.32.0
2016-05-06 08:59:02 +12:00
Kamal Marhubi
8309d1a74c deps: Update syntex_syntax to 0.32.0 2016-05-05 16:39:34 -04:00
Nick Cameron
47631e2a5c Merge pull request #974 from sanxiyn/unused-trait-import
Remove unused trait imports
2016-05-04 08:32:26 +12:00
Seo Sanghyeon
f85c603c63 Remove unused trait imports 2016-05-03 21:52:55 +09:00
Nick Cameron
15d35a04b4 Merge pull request #973 from habnabit/fix-associated-items
Don't misplace the :: on associated items.
2016-05-03 17:22:50 +12: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
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