Commit Graph

246 Commits

Author SHA1 Message Date
David Alber
09d0ca4892 Using common execute rustfmt function 2017-12-20 23:24:28 -08:00
David Alber
f17556966c Reusing status-handling function 2017-12-20 22:36:36 -08:00
David Alber
655022c42b Factoring out status code values 2017-12-20 21:53:33 -08:00
David Alber
6aaed5b08f Adding --version option to cargo-fmt 2017-12-20 21:48:59 -08:00
Seiichi Uchida
85ef4638b6 Make 'cargo fmt' formats every workspace member 2017-12-20 22:47:51 +09:00
Oliver Schneider
fad903fd14 Move from String to PathBuf where applicable 2017-12-15 10:26:19 +09:00
Nick Cameron
4ee7911f4b
Merge pull request #2271 from topecongiro/refactorings
Refactorings from cargo clippy etc.
2017-12-15 08:53:48 +13:00
Seiichi Uchida
516f15aba1 Cargo clippy 2017-12-12 13:48:12 +09:00
topecongiro
32804c1f09 Do not print usage when rustfmt failed 2017-12-12 00:54:37 +09:00
Seiichi Uchida
e45c0c4815 Rename error_on_unformatted_comments_or_strings to error_on_unformatted 2017-12-11 11:48:17 +09:00
Seiichi Uchida
d3ee7f3f06 Set error_on_unformatted_comments_or_strings to true when --error-on-unformatted
option is passed
2017-12-11 11:48:17 +09:00
Seiichi Uchida
93a75de18e Print command line options in alphabetical order 2017-12-11 11:48:17 +09:00
Seiichi Uchida
1e982c66a0 Fix a typo 2017-12-11 11:48:17 +09:00
Seiichi Uchida
cbd3608c30 Organize command line options and start with upper case 2017-12-11 11:48:17 +09:00
Seiichi Uchida
d17168f4ba Add error-on-unformatted command line option 2017-12-11 11:48:17 +09:00
Seiichi Uchida
3ebe054362 Replace into() on &str with to_owned() 2017-12-08 13:07:42 +09:00
Seiichi Uchida
b8448f6223 Use package name instead of target name for --package filter 2017-12-06 12:41:04 +09:00
Nick Cameron
b07e4339f0
Merge pull request #2221 from topecongiro/rfc/blank-lines
Keep vertical spaces between items or statements within range
2017-12-06 15:52:19 +13:00
Seiichi Uchida
65c90dc08c Do not pass files as arguments to rustfmt when dumping the default config 2017-12-05 08:01:29 +09:00
Seiichi Uchida
89f27764ed Cargo fmt and update tests 2017-12-02 17:45:39 +09:00
topecongiro
22c9025027 Format source codes 2017-11-30 18:00:49 +09:00
topecongiro
8b53d7806c Cargo fmt 2017-11-29 17:37:51 +09:00
topecongiro
f06cb34022 Replace TargetKind with simple String 2017-11-27 22:09:01 +09:00
topecongiro
a5b647faa7 Allow '--package <package>' 2017-11-27 19:29:26 +09:00
topecongiro
bf87d9b79f Rename WorkspaceHitlist to CargoFmtStrategy 2017-11-27 18:57:46 +09:00
topecongiro
fbe06c6f77 Random formatting 2017-11-27 18:48:16 +09:00
topecongiro
33ab1f4927 Use cargo_metadata crate over json crate 2017-11-27 18:47:07 +09:00
topecongiro
58e83fb426 Implement PartialEq, Eq and Hash trait for Target
and move Target::from_json() to TargetKind::from_str()
2017-11-27 18:45:26 +09:00
topecongiro
1b1122654f Add cargo_metadata to dependency 2017-11-27 18:37:21 +09:00
topecongiro
34c2499029 Cargo fmt 2017-11-16 17:43:06 +09:00
topecongiro
b1a6dd6b83 Cargo fmr & update tests
Note that we are forcing vertical layout when there are attributes on top of a
variant.
2017-11-16 16:07:15 +09:00
clippered
794a215b27 rename to use_colored_tty; used match as well 2017-11-13 20:18:05 +11:00
clippered
d2f2f25463 add cli option for color 2017-11-13 20:18:03 +11:00
topecongiro
f45aba9ced Cargo clippy 2017-11-13 08:02:23 +09:00
Nick Cameron
bfa093d394 Fix formatting in git-fmt 2017-11-08 21:10:47 +13:00
Nick Cameron
e8bc2bf966 Tweak the uncommitted file rules for git-fmt 2017-11-08 18:17:12 +13:00
Nick Cameron
aafaa2fc2e Add git-fmt tool 2017-11-08 08:05:44 +13:00
topecongiro
10cb568c18 Remove redundant references 2017-11-06 13:52:25 +09:00
topecongiro
feeca8a724 Remove unnecessary format!() call 2017-11-06 13:52:25 +09:00
topecongiro
b023cc831c Remove static lifetime 2017-11-06 13:52:25 +09:00
topecongiro
fc4a51a242 Prefer println!() to println!("") 2017-11-06 13:52:25 +09:00
topecongiro
79c6f632ef Remove an unnecessary lifetime 2017-11-06 13:52:25 +09:00
topecongiro
b17de6228f Cargo fmt 2017-11-02 21:45:00 +09:00
Seiichi Uchida
fe39c0cd8c Fix a typo 2017-10-30 23:34:44 +09:00
Nick Cameron
cf0d494dda
Merge pull request #1998 from tmahmood/master
Implemented 'unstable options' command line option
2017-10-30 07:50:28 +13:00
topecongiro
5e30a0183f Filter packages only when '-p' was passed 2017-10-29 00:13:37 +09:00
topecongiro
98eb7da0d5 Format dependency crates only when '--all' was passed 2017-10-29 00:12:28 +09:00
Tarin Mahmood
685c9d332f Unstable options added 2017-10-28 16:26:33 +06:00
topecongiro
b0c7201c0e Do not propagate io error when dependencies are not found 2017-10-28 16:40:18 +09:00
topecongiro
d10df70138 Remove iter() in for loop 2017-10-28 01:39:01 +09:00
topecongiro
3b0d2c1426 %s/std::io/io/g 2017-10-28 01:38:28 +09:00
topecongiro
bdcd19d294 Read local dependencies from cargo metadata 2017-10-28 01:38:04 +09:00
topecongiro
8d86b0eaf8 Do not use 'cargo manifest' anymore as it is deprecated 2017-10-28 01:35:32 +09:00
Nick Cameron
73b079d3f6 Merge pull request #2079 from SingingTree/issue-1979-errors-go-to-stdout
Use stderr for various errors and warnings.
2017-10-27 01:02:44 +05:30
Bryce Van Dyk
adac9fb43c Use stderr for various errors and warnings.
Adjusts several error and warning report cases to output using eprintln!
instead of println! so that messages are sent to stderr.
2017-10-25 22:18:19 +13:00
Nick Cameron
9754bcb535 Merge pull request #2048 from japaric/required-version
add `required-version` option to rustfmt.toml
2017-10-20 11:23:27 +05:30
Seiichi Uchida
043ddf146d Fix a typo 2017-10-17 11:13:20 +09:00
Tamir Duberstein
f00c556263
correct --dump-default-config usage string 2017-10-14 08:08:52 -04:00
Jorge Aparicio
d2bf5b8068 run cargo fmt 2017-10-10 22:36:41 +02:00
Jorge Aparicio
0c36c59175 add required-version option to rustfmt.toml
This option specifies the rustfmt version that *must* be used to format the code. Trying to use a
different version raises an error.

closes #1505
2017-10-09 23:07:53 +02:00
Jorge Aparicio
a1cfacdb12 output --dump-default-config to stdout if no path is given
closes #1988
2017-10-09 21:10:20 +02:00
topecongiro
1f1e037d8b Avoid panicking when calling 'cargo fmt --all' 2017-09-15 23:24:17 +09:00
Seiichi Uchida
4b79055a15 Apply refactoring from cargo clippy 2017-08-31 12:49:12 +09:00
Seiichi Uchida
404e2db046 Remove unused extern crate 2017-08-28 23:43:49 +09:00
sinkuu
fea3080f91 Format 2017-08-11 17:44:16 +09:00
topecongiro
c28df858c7 Format source codes and update tests 2017-08-09 00:16:35 +09:00
Emilio Cobos Álvarez
068bcad880
rustfmt-format-diff: Use logging macros instead of "-v" option. 2017-07-31 09:38:24 +01:00
Emilio Cobos Álvarez
c12b4e9031
bin: Add a very simple rustfmt-format-diff.
This patch introduces a super-simple format-diff tool, that allows you to do:

```
git diff | rustfmt-format-diff -p 1
```

To format your current changes.

For now it doesn't accept too much customisation, and it basically calls rustfmt
with the default configuration, but more customisation can be added in the
future if needed.
2017-07-31 09:15:35 +01:00
Nick Cameron
6984c05e69 Change the writemode to overwrite 2017-07-21 11:22:51 +12:00
topecongiro
6fd291981e Sort imports in alphabetical and consistent order 2017-07-13 18:42:14 +09:00
topecongiro
e3310a6a18 Format source codes 2017-07-11 21:53:10 +09:00
Seiichi Uchida
bc63d69c3f Format source codes 2017-07-10 02:24:59 +09:00
topecongiro
57466dc687 Format source codes 2017-07-07 09:04:06 +09:00
topecongiro
747481068c Add an option to inhibit warning on write-mode change 2017-06-27 11:28:28 +09:00
Georg Brandl
b95666b20c Handle proc-macro crates in cargo-fmt 2017-06-21 07:32:23 +02:00
topecongiro
64fc9e31e7 Fix a typo 2017-06-20 22:38:14 +09:00
Nick Cameron
90251c32ff Add warning about write-mode change 2017-06-20 18:47:32 +12:00
Seiichi Uchida
53202b4029 Do not run cargo fmt if there are unnecessary arguments 2017-06-19 23:39:59 +09:00
Seiichi Uchida
75d86eb1a0 Format source codes 2017-06-18 22:45:08 +09:00
Nick Cameron
5f1bab26c4 Move to Libsyntax 2017-06-14 14:01:56 +12:00
Nick Cameron
1f512948a0 Reformat source code using new defaults 2017-06-13 14:41:49 +12:00
Ravi Khadiwala
17995e1539 Expose methods to locate and load config
* Make method for searching parents for toml file public
* Make method for loading config from path directly public, tweak the
  API since it was never returning None
2017-05-30 21:41:30 -05:00
Nick Cameron
a7b8dcc60d Simplify --version info 2017-05-25 16:39:44 +12:00
Michael Killough
31c8fb4e76 Add --dump-default-config and --dump-minimal-config.
- `--dump-default-config` outputs the default configuration to the
   specified file as TOML and then exits.
 - `--dump-minimal-config` is checked after formatting files as normal.
   If present, any configuration options that were checked during
   formatting are written to the specified file as TOML.
 - These options were added only to `rustfmt`, not to `cargo fmt`. They
   can be specified when using `cargo fmt` by placing them after `--`.
 - It would have been nice if the filename was optional, so you could
   run just `rusfmt --dump-minimal-config build.rs` to have it output to
   `rustfmt.toml`. However, this doesn't do what you might expect: it
   outputs the config to `build.rs`!
2017-05-18 12:56:49 +07:00
Michael Killough
222bac1397 Provide config.set().item(value) API.
This API isn't fantastic, but it's the best I can come up with without
something like `concat_idents!()`. There are relatively few places where
config is set, to hopefully the ugliness isn't disastrous.

Change previous occurences of `config.item = value` to this new API,
rather than using `config.override_value()`. Undo the changes to
`override_value()`, as it's no longer important to propogate the error
to the caller. Add a test for the new interface.
2017-05-18 11:42:32 +07: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
topecongiro
2776615dc9 Replace 'try!' with '?' 2017-05-08 13:14:23 +09:00
topecongiro
5e832acdc4 Allow config-path to point to a file 2017-05-08 07:02:23 +09:00
est31
78d4ef1992 Drop rustc-serialize, use serde, update toml dependency 2017-05-03 10:23:50 +02:00
Nick Cameron
7a2577322d Merge pull request #1473 from topecongiro/bug/no-such-file-or-directory
Prevent panicking against directories or non-existent files
2017-05-01 16:38:43 +12:00
Seiichi Uchida
4cec3ab71d Prevent panicking against directories or non-existent files 2017-04-26 17:29:56 +09:00
Sheng Hau
0653b8413e Show exit codes' meanings with the rustfmt help message 2017-04-19 00:25:48 +08:00
Jay Lee
c5f07eda41 fix path check 2017-04-10 05:25:12 +08:00
Nick Cameron
bdcb8d663e Merge pull request #1438 from topecongiro/poor-formatting/method-chains
Lookup the last element of 'subexpr_list' instead of the first one
2017-04-06 21:26:13 +12:00
topecongiro
8d22e85e48 Lookup the last element of 'subexpr_list' instead of the first one
Closes #1217, #1236, #1389 and #1434.
2017-04-06 09:26:25 +09:00
Nick Cameron
b3a4ba570e Merge pull request #1432 from topecongiro/parse-config
Print error and usage when decoding config file failed
2017-04-06 11:30:33 +12:00
topecongiro
6af0968511 Change return type of 'from_toml' from 'Config' to 'Result<Config>'
Closes #1426.
2017-04-03 13:58:46 +09:00
Nick Cameron
20395c5c55 Merge pull request #1430 from fintelia/stdin_lines
The --file_lines argument now supports "stdin"
2017-04-03 08:27:35 +12:00
Jonathan Behrens
6241469a69 Warn about extra files listed in file_lines argument 2017-03-31 13:34:53 -04:00
Jonathan Behrens
56da223dc2 --file_lines argument now supports "stdin" 2017-03-30 19:35:58 -04:00