Commit Graph

121 Commits

Author SHA1 Message Date
Seiichi Uchida
89f27764ed Cargo fmt and update tests 2017-12-02 17:45:39 +09:00
topecongiro
8b53d7806c Cargo fmt 2017-11-29 17:37:51 +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
feeca8a724 Remove unnecessary format!() call 2017-11-06 13:52:25 +09:00
Seiichi Uchida
fe39c0cd8c Fix a typo 2017-10-30 23:34:44 +09:00
Tarin Mahmood
685c9d332f Unstable options added 2017-10-28 16:26:33 +06: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
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
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
747481068c Add an option to inhibit warning on write-mode change 2017-06-27 11:28:28 +09: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
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
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
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
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
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
488c0b9546 Test and source fallout 2017-03-22 09:25:26 +13:00
Nick Cameron
33b83ae7df Formatting fallout
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-07 09:50:41 +13:00
Nick Cameron
a7612cc773 more fallout 2017-02-23 13:15:48 +13:00
Nick Cameron
ba1202f6b3 test fallout 2017-02-23 13:15:48 +13:00