Commit Graph

918 Commits

Author SHA1 Message Date
Gaëtan Cassiers
76ea7e3b64 Fix #190 for submodules 2015-08-24 22:01:01 +02:00
cassiersg
cf046b734c Merge pull request #200 from sinhpham/master
Fix https://github.com/nrc/rustfmt/issues/190
2015-08-24 19:06:02 +02:00
Sinh Pham
49cae9c485 Fix https://github.com/nrc/rustfmt/issues/190 2015-08-23 08:37:43 -04:00
Nick Cameron
8319e33573 Merge pull request #198 from marcusklaas/parameterized-paths-matter
Fix bug in path formatting
2015-08-23 19:52:39 +12:00
Léo Stefanesco
5047091f08 Don't format raw strings 2015-08-21 19:13:46 +02:00
Marcus Klaas
150c333e6c Fix bug in path formatting 2015-08-21 16:28:32 +02:00
Marcus Klaas
e0ae162ae1 Reduce code duplication for block indentation helpers 2015-08-21 12:57:17 +02:00
Marcus Klaas
c8fd23ca68 Refactor closure formatting routine 2015-08-20 23:05:41 +02:00
Marcus Klaas
5fcd313b08 Format closures 2015-08-19 23:15:56 +02:00
Nick Cameron
43ad7ad7a0 Re-jig binop formatting
and misc other fixes from the reviews.
2015-08-20 08:18:02 +12:00
Nick Cameron
df0fd0e119 reformatting/rebasing 2015-08-20 08:11:14 +12:00
Nick Cameron
81f2e449d7 Handle span error with continue
This should be properly addressed by #184, but requires a change to the rustc parser, so this patch just works around the issue.
2015-08-20 08:11:14 +12:00
Nick Cameron
ae1eec81af Rewrite match expressions (continued). 2015-08-20 08:11:14 +12:00
Nick Cameron
a43e2b5ae8 Formatting 2015-08-20 08:11:14 +12:00
Nick Cameron
d10629d8a5 Allow {} to remain. 2015-08-20 08:08:11 +12:00
Nick Cameron
dc2544712c Rewrite match expressions 2015-08-20 08:08:11 +12:00
Marcus Klaas
8e22a73cb7 Add option to override single configuration lines for tests 2015-08-19 21:51:03 +02:00
Marcus Klaas de Vries
2ef0b17955 Merge pull request #176 from marcusklaas/no-backup
Add an option to forgo backups
2015-08-19 21:34:07 +02:00
Marcus Klaas
10a80bb8be Add an option to forgo backups 2015-08-19 21:31:27 +02:00
Marcus Klaas
4e0a8da447 Refactor itemize list so that it produces an iterator 2015-08-19 18:40:02 +02:00
Alex Newman
2f4ef7dd1e Provide information about default.toml 2015-08-18 11:35:18 -07:00
Marcus Klaas
41bca58100 Format paths 2015-08-16 22:53:06 +02:00
Marcus Klaas
82b27fc4ab Correctly format typed self in function arguments 2015-08-14 11:56:27 +02:00
Gaëtan Cassiers
5a29d2f081 Fix nits for filemap 2015-08-02 14:49:35 +02:00
Gaëtan Cassiers
5b5927996f Kill ChangeSet and replace remaining part by FileMap
Also fix style issues
Cargo update to get fixes of strings.rs (was cause of a misformatted
function call).
2015-08-02 13:33:01 +02:00
Gaëtan Cassiers
0eab4bf430 Remove ChangeSet of FmtVisitor 2015-08-02 13:12:51 +02:00
Gaëtan Cassiers
0e10329dc7 Separate modules and files listing of reformatting
As suggested in #141
Closes #156
2015-08-02 13:07:27 +02:00
Marcus Klaas
0f640b06dd Properly format unsafe blocks 2015-08-02 12:40:02 +02:00
Marcus Klaas
54a96355dd Phase out token::get_ident in favour of ToString
token::get_ident was removed in rust commit 00a5e66f81
2015-07-31 13:10:19 +02:00
Marcus Klaas
397d0d3d72 Format simple imports 2015-07-25 23:17:56 +02:00
cassiersg
92b3f69934 Add a helper method to format imports 2015-07-25 19:00:38 +02:00
cassiersg
5168d7458a Indent fix 2015-07-25 19:00:38 +02:00
Gaëtan Cassiers
30b16bc474 Move 'use' to Rewrite
Implements Rewrite for ViewPath

Behavior change: always use max_width instead of ideal_width for use
list rewrite. I think it looks better, was also suggested by @nrc in
https://github.com/nrc/rustfmt/issues/82#issuecomment-105314265
2015-07-25 19:00:38 +02:00
Gaëtan Cassiers
ff301efa4e Fix width computation in rewrite_binary_op
Operator width was counted twice.
2015-07-25 18:58:16 +02:00
Nick Cameron
8461e8a0a8 Merge pull request #147 from marcusklaas/even-more-expr
Format if expressions & loops
2015-07-25 09:51:59 +12:00
Nick Cameron
4aa24f5962 Merge pull request #158 from marcusklaas/modules
Use new module code from libsyntax
2015-07-25 09:48:58 +12:00
Marcus Klaas
3aa03dcc25 Use new module code from libsyntax 2015-07-24 19:25:01 +02:00
Marcus Klaas
c4101de53d Refactor some things; add extra tests. 2015-07-24 19:00:14 +02:00
Marcus Klaas
d7fe47d858 Preserve box syntax 2015-07-23 23:08:41 +02:00
Marcus Klaas
d13fc2289a Fix underflow bug in rewrite_call
Fixes https://github.com/nrc/rustfmt/issues/148.
Now properly propagates the rewrite failure instead of panicking. Added regression test from servo code. This example will be properly rewritten when https://github.com/nrc/rustfmt/issues/17 is addressed.
2015-07-22 23:43:24 +02:00
Nick Cameron
c10c732425 Simplify CompilerCalls impl 2015-07-23 08:07:57 +12:00
Marcus Klaas
500fb78a33 Format unnamed function arguments 2015-07-20 20:07:54 +02:00
Marcus Klaas
2fa6220f57 Format all the loops! 2015-07-19 23:43:32 +02:00
Marcus Klaas
2fda8dd883 Format if-let-else expressions 2015-07-19 23:43:03 +02:00
Marcus Klaas
b161815fe0 Format if-else expressions 2015-07-19 23:42:54 +02:00
Marcus Klaas
e47e91013e Format while loops, including labels 2015-07-18 12:25:41 +02:00
Nick Cameron
979d0c9756 Resolve some warnings 2015-07-17 18:26:10 +12:00
Nick Cameron
c3375078e5 Merge pull request #137 from nrc/struct-lit-opt
Options for formatting struct literals
2015-07-17 06:57:01 +12:00
Nick Cameron
f2bcee9d87 Tidy up some overrunning lines 2015-07-16 14:23:48 +12:00
Nick Cameron
9ab1587a98 Don't apologise if its not our fault in warnings 2015-07-16 14:17:07 +12:00
Nick Cameron
a32b0e7627 Fix some bugs 2015-07-16 14:05:10 +12:00
Nick Cameron
018fa85453 Reformat code to new struct lit style 2015-07-16 14:05:10 +12:00
Nick Cameron
7518f68861 Add an option to format struct lits with either block or visual indent 2015-07-16 14:05:05 +12:00
Nick Cameron
e4a6f96d70 Merge pull request #128 from marcusklaas/subexpr
Format loops
2015-07-16 10:08:36 +12:00
Marcus Klaas
b473c2bd2a Format loops 2015-07-15 23:33:01 +02:00
Gaëtan Cassiers
b93b64381f Fix bug in rewrite_tup_lit
Wasn't using all width available when the lenght is more than 1.
2015-07-15 00:38:54 +02:00
Gaëtan Cassiers
990a123e1c Run rustfmt on the code 2015-07-03 11:13:28 +02:00
Gaëtan Cassiers
3de366d282 Format modules into separate files 2015-07-03 11:12:21 +02:00
Gaëtan Cassiers
83290f15ad Add comma after struct-like enum variant
This is mandatory.
2015-07-03 10:30:42 +02:00
Gaëtan Cassiers
fc4483748c Fix fn decl rewriting in case of generics
An opening paren in generics caused a false-positive detection of args
beginning. The result was the creation of comments with some code into
it.
2015-07-03 10:30:42 +02:00
Gaëtan Cassiers
163fbf62ee Fix bugs in width computation 2015-07-03 02:55:43 +02:00
Marcus Klaas
2d4b4b856a Format expressions with binary and unary operators 2015-07-02 22:44:55 +02:00
Marcus Klaas
482f200b0b Update import list formatting
Include comments and sort items alphabetically.
2015-06-26 03:43:12 +02:00
Marcus Klaas
28f7bd4205 Fixup comment wrapping in lists 2015-06-24 21:14:08 +02:00
Marcus Klaas
9f3ab0b5fe Format comments in struct literals 2015-06-24 01:11:29 +02:00
Marcus Klaas
0ef5db9496 Format tuple-like structs 2015-06-23 16:54:42 +02:00
Marcus Klaas
d7b49fd76c Remove global mutable config to allow for concurrency 2015-06-23 13:26:04 +02:00
Nick Cameron
1488d5eadb Merge pull request #90 from marcusklaas/empty-imports
Remove empty list imports
2015-06-22 17:32:55 -07:00
Gaëtan Cassiers
b7ead806f4 Use FromIterator implementation for Option
Combined with try_opt!, this avoid an explicit for loop or another macro.
2015-06-23 02:15:46 +02:00
Gaëtan Cassiers
ad658885d4 Comments for Rewrite 2015-06-23 02:15:46 +02:00
Gaëtan Cassiers
2161400c7d Add a try_opt! macro for ease of work with Rewrite 2015-06-23 02:15:46 +02:00
Gaëtan Cassiers
c012d311c4 A basic impl of Rewrite for ast::Expr 2015-06-23 02:15:46 +02:00
Nick Cameron
c10bfecdc2 Merge pull request #114 from marcusklaas/rustup
Rustup
2015-06-22 15:36:20 -07:00
Gaëtan Cassiers
35c996054a Use wrapping operations for bit-level functions
This handles a underflow panic on round_up_to_power_of_two(0).
2015-06-22 17:42:05 +02:00
Marcus Klaas
5924b83829 Rustup 2015-06-22 14:52:23 +02:00
Nick Cameron
b74cdb7b53 Merge pull request #109 from marcusklaas/fix-string-lit
Fix off-by-one errors in rewrite_string_lit
2015-06-16 09:59:24 +12:00
Marcus Klaas
74f050bb5a Fix off-by-one bugs in rewrite_string_lit
Multi-line literals would typically have a character too many. Splitting of escape sequences also wasn't working correctly.
2015-06-15 21:37:04 +02:00
Marcus Klaas
b17c920e46 Deal with problematic characters in comments 2015-06-15 15:07:47 +02:00
Marcus Klaas
d335d04575 Implement checks for unnumbered TODOs and FIXMEs 2015-06-12 20:58:23 +02:00
Gaëtan Cassiers
4d6d0b81a7 Fix mod ordering + formatting 2015-06-08 20:23:24 +02:00
Gaëtan Cassiers
adedba45a8 Use impl_enum_decodable for SeparatorTactic 2015-06-08 19:40:22 +02:00
Marcus Klaas
13141e261b Remove duplicate statement in make_comments_for_list 2015-06-04 15:05:50 +02:00
Marcus Klaas
227322ddba Add macro for enum implementations of Decodable 2015-06-04 14:08:32 +02:00
Marcus Klaas
1ef7e23dd1 Move vertical mode override to write_list 2015-06-04 13:47:35 +02:00
Marcus Klaas
27d6558964 Remove empty list imports 2015-06-02 23:55:16 +02:00
Marcus Klaas
90bc40a111 Implement basic enum formatting 2015-06-02 15:52:07 +02:00
Nick Cameron
fb40a2796e Merge pull request #85 from cassiersg/tuple
Implement reformat of tuple litterals
2015-05-31 20:11:10 +12:00
Gaëtan Cassiers
7a6b4db819 Handle tuples of length 1 2015-05-30 16:52:46 +02:00
Gaëtan Cassiers
38f421b764 fix : width available 2015-05-30 16:44:07 +02:00
Nick Cameron
90494132c2 Merge pull request #81 from tdudziak/issue_31
Optionally put the opening paren on the previous line for args (Issue #31)
2015-05-29 11:59:37 +12:00
Gaëtan Cassiers
092d6be368 Implement reformat of tuple litterals 2015-05-28 21:30:28 +02:00
Tomasz Dudziak
1bb3c9e555 Use config!(tab_spaces) instead of hardcoded 4. 2015-05-26 09:31:16 +02:00
Tomasz Dudziak
21a0f1b787 Clarify indent calcs in compute_budget_for_args 2015-05-25 21:29:02 +02:00
Tomasz Dudziak
fdd7baeae9 Optionally put the opening paren on the previous line for args 2015-05-25 16:39:19 +02:00
Gaëtan Cassiers
113bdaa119 Fix #79 2015-05-25 13:22:10 +02:00
Nick Cameron
46818d405a Struct literals 2015-05-25 19:14:20 +12:00
Nick Cameron
972f494e4e Pref for comma on the last field 2015-05-25 17:14:39 +12:00
Nick Cameron
e7adf64155 Format structs 2015-05-25 17:07:55 +12:00
Gaëtan Cassiers
09bd4a74e4 Avoid dangling ) 2015-05-24 23:46:02 +02:00
Gaëtan Cassiers
c1fc693c5e syle correction 2015-05-24 23:35:40 +02:00
Gaëtan Cassiers
0baeca5829 Add rewrite for ExprParen 2015-05-24 19:57:13 +02:00
Nick Cameron
6a5ef17eb1 Add config.rs which I forgot for the last commit
Closes #73
2015-05-23 22:25:36 +12:00
Nick Cameron
1a09a6d00a Use config file for constants 2015-05-23 17:53:53 +12:00
Nick Cameron
aa6f7e8d3c Add default.toml and modify the build system for it 2015-05-23 15:28:41 +12:00
Alex HotShot Newman
2fbb445b67 Remove old box syntax 2015-05-20 11:20:15 -07:00
Marcus Klaas
4aa3518703 Format required methods on traits 2015-05-12 02:37:05 +02:00
Nick Cameron
6b1494885c Merge pull request #48 from oli-obk/newlines
handle windows newlines
2015-05-12 10:33:42 +12:00
Nick Cameron
3b383a4c22 Merge branch 'single-import' of https://github.com/mattyhall/rustfmt into mattyhall-single-import
Rebased:
	src/imports.rs
2015-05-12 10:03:25 +12:00
Nick Cameron
e2a5d94e3f Merge pull request #68 from marcusklaas/import-breaks
Keep import lists on a single line when possible
2015-05-12 09:39:22 +12:00
Oliver Schneider
853b58901b typo 2015-05-11 15:05:12 +02:00
Marcus Klaas
c790d7d550 Keep import lists on a single line when possible 2015-05-04 22:22:31 +02:00
Oliver Schneider
cd3b032e11 prevent bogus whitespace error messages due to \r 2015-05-04 14:32:48 +02:00
Oliver Schneider
1655583b02 handle windows newlines 2015-05-04 12:50:24 +02:00
Marcus Klaas
58a14fbc79 Correctly indent use items and functions 2015-05-04 09:25:20 +02:00
Matthew Hall
59352172b3 Change import lists with one item to single import
Changes lists such as ``use std::{fmt}`` to a form without a list, eg
``use std::fmt``.
2015-05-02 20:28:38 +01:00
defyrlt
59554dd5e1 Resolved #56 -- mut was eaten out of mut self in fn args. 2015-05-02 20:27:08 +01:00
Oliver Schneider
62e583d4cf split main function and test function into their own files
small modifications to make executable and test compile properly
2015-05-01 22:28:58 +02:00
Oliver Schneider
e6e7ce178f main.rs -> lib.rs 2015-05-01 22:24:53 +02:00
Steven Allen
c006b84d87 Trust the borrow checker. 2015-05-01 12:17:14 -04:00
Nick Cameron
2b73dcd662 Merge pull request #57 from defyrlt/issue_56
`mut` was eaten out of `mut self` in fn args.
2015-05-01 23:16:54 +12:00
defyrlt
81c9db3275 Resolved #56 -- mut was eaten out of mut self in fn args. 2015-05-01 14:14:04 +03:00
Theodore DeRego
4f75227714 Spaces around in type bounds 2015-04-30 16:52:11 -10:00
Tobias Bucher
2145108043 Rename src/mod.rs to src/main.rs to adhere to the standard crate format 2015-04-30 13:37:09 +02:00
Nick Cameron
4560df2567 Merge pull request #43 from tbu-/pr_nostaticmut
Use `AtomicUsize` instead of `static mut` that require `unsafe`
2015-04-30 21:13:36 +12:00
Nick Cameron
0931b7c6df Merge pull request #45 from tbu-/pr_toowned
Change `to_string` to `to_owned` when it just creates a `String` from a `&str`
2015-04-30 21:10:54 +12:00
Nick Cameron
8a0a1bdcd1 Merge pull request #46 from tbu-/pr_testwarnings
Fix warnings in `cargo test`
2015-04-30 21:10:25 +12:00
Tobias Bucher
2f221fd095 Use AtomicUsize instead of static mut that require unsafe 2015-04-30 10:40:37 +02:00
Tobias Bucher
5247d98d31 Change to_string to to_owned when it just creates a String from a &str
This means that it doesn't have to go through the formatting hierarchy and can
just immediately reserve enough memory.
2015-04-30 10:31:42 +02:00
Manish Goregaokar
9398aed82c Handle pub use (fixes #23) 2015-04-30 13:52:28 +05:30
Tobias Bucher
dc3e236599 Fix warnings in cargo test 2015-04-30 09:32:38 +02:00
Nick Cameron
25fcb7754a Add README.md 2015-04-30 15:09:33 +12:00
Nick Cameron
2d5226b825 Use + for type bounds 2015-04-29 16:44:29 +12:00
Nick Cameron
f61ad35494 Preserve linebreaks in doc comments 2015-04-29 16:25:52 +12:00
Nick Cameron
16f9057975 Better handle trait items 2015-04-29 15:24:20 +12:00
Nick Cameron
2e485ea086 Better attribute handling 2015-04-29 15:03:15 +12:00
Nick Cameron
decafbbaea Fix trailing commas in where clauses 2015-04-29 09:55:24 +12:00
Nick Cameron
40be79304e Tweak rules around attributes for modules 2015-04-28 22:19:25 +12:00
Nick Cameron
81b8eb7993 Comments on their own lines between args 2015-04-28 21:57:16 +12:00
Nick Cameron
cdfda8801e Absolute paths 2015-04-28 21:36:31 +12:00
Nick Cameron
9070a055de Comments after return 2015-04-28 21:24:56 +12:00
Nick Cameron
a84287c6b0 Comments in function decls and annotations/doc comments 2015-04-28 20:56:01 +12:00
Nick Cameron
c00970f5e9 Indenting for modules
rustfmt now bootstraps!
2015-04-23 18:43:46 +12:00
Nick Cameron
daff43f761 Arg/line length bug 2015-04-23 18:35:56 +12:00
Nick Cameron
4faaa4dab2 minor reformatting 2015-04-23 18:10:43 +12:00
Nick Cameron
28d90bc439 trailing newline hell fixed 2015-04-23 18:02:55 +12:00
Nick Cameron
0c5f5082dc terminating newline bug 2015-04-23 17:04:07 +12:00
Nick Cameron
2819738ff1 Fix formatting in changes.rs 2015-04-23 16:30:19 +12:00
Nick Cameron
bc7855d347 Idempotent tests and comments in function decls 2015-04-23 16:22:48 +12:00
Nick Cameron
854b52dbed Keep comments on fn arguments 2015-04-21 22:50:43 +12:00
Nick Cameron
4c869a1b9d Extract out more files 2015-04-21 21:01:19 +12:00
Nick Cameron
8ca3dc063e Refactor missing spans and fix bug with trailing whitespace 2015-04-21 20:40:36 +12:00
Nick Cameron
6e082f7aad Extract some methods for functions. 2015-04-21 19:59:48 +12:00
Nick Cameron
a652a83ffd Trivial reformatting 2015-04-21 16:49:16 +12:00
Nick Cameron
defcceb879 Pull out some functionality into separate files 2015-04-21 16:47:15 +12:00
Nick Cameron
986de65b97 Write output to files 2015-04-21 16:28:10 +12:00
Nick Cameron
eccf43536b Some configuration options for function layout 2015-04-21 12:02:30 +12:00
Nick Cameron
5ff6a45022 By value self in functions 2015-04-21 09:54:04 +12:00
Nick Cameron
6dbb3ef2f1 Function visibility 2015-04-21 09:38:16 +12:00
Nick Cameron
0a67babb95 Work across multiple files 2015-04-14 21:52:12 +12:00
Nick Cameron
8f5b899c85 Use strings.rs rather than local modules 2015-04-14 13:13:35 +12:00
Nick Cameron
76854677c1 New reformatting of fns 2015-04-14 13:00:46 +12:00
Steven Allen
0fd4b6a150 Update for new FnKind::FkMethod signature 2015-03-22 09:30:04 -07:00
Dan Glastonbury
33e12c58b9 Update from Path to PathBuf 2015-03-09 16:17:14 +10:00
Nick Cameron
3f58f829f3 A different, more pretty printing approach.
No longer uses the Rope data strucure.
2015-03-09 17:18:48 +13:00
Nick Cameron
4fd5f86732 Add string_buffer (not used yet) 2015-03-08 19:24:56 +13:00
Nick Cameron
7417ab5aed Working prototype
Implements a few formatting options using an approach where we modify the source using a rope. Uses very ad-hoc rules for formatting.
2015-03-08 11:46:35 +13:00
Nick Cameron
f1e698c838 Save changes in the rope.
Also changes to using the new rustc interface
2015-02-02 21:59:03 +13:00
Nick Cameron
5caf49ff63 Commit changes code using map of adjustments 2015-01-26 15:20:30 +13:00