Commit Graph

207 Commits

Author SHA1 Message Date
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
Emil Gardström
6971b4b5c9 Implemented support for workspaces
closes rust-lang-nursery/rustfmt#1244
2017-03-30 03:29:32 +02: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
Casey Rodarmor
4f939ddf0c Don't print config file by default (#1313)
Supress `Using rusftmt config file...` messages unless the --verbose
flag is given.
2017-02-13 12:50:10 +13:00
Ivan Ukhov
56e0c463d5 Process build scripts 2017-01-25 08:29:48 +01:00
Jason Dusek
22ddc36b17 Recognize "rlib" and "cdylib" crates (#1238)
Addresses #828 and https://github.com/lunaryorn/emacs-module.rs/issues/4 and probably numerous others.
2016-12-16 08:56:15 -10:00
Nick Cameron
d3eba76e4d update Serde, etc.
Lots of changes to how closures work
2016-11-21 11:02:18 +13:00
Mason Smith
764100361e cargo-fmt processes bench, test, example files 2016-11-02 02:28:06 -07:00
sinkuu
a3c63fdef9 Run clippy 2016-08-29 08:57:27 +09:00
Daniel Campoverde
6380937b59 Multiple config file names feature (#1101)
* Add multiple configuration file names feature

* Add '.rustfmt.toml' in README file

* Clean up configuration file code

* Make config file names constant

* Use only one blank line
2016-08-01 09:32:35 +12:00
Nick Cameron
ffa5a22d1c Merge pull request #1084 from johannhof/rustfmt-not-found
Show more helpful error if rustfmt is not in PATH.
2016-07-04 21:30:52 +12:00
Johann Hofmann
033741246c
Show more helpful error if rustfmt is not in PATH.
This fixes #1071.
2016-07-04 07:42:18 +02:00
Nick Cameron
ddda46d265 rustup 2016-07-04 15:46:58 +12:00
Johann Hofmann
8260d277c8
Return failure exit code on found diffs (fix #906)
This changes rustfmt to return exit code 4
when run with write mode diff and differences between
the formatted code and the original code are found.

Useful for CI to make sure your contributors actually ran rustfmt.
2016-06-21 23:01:15 +02:00
Kamal Marhubi
5361f61110 Include git commit and worktree status in version output (#1060)
This will help in debugging issues as rustfmt gets more users.

If the working tree is clean, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b)

If the working tree is dirty, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (9f5ed3b worktree dirty)

If git is unavailable, output looks like

    $ target/debug/rustfmt -V
    0.5.0 (git commit unavailable)

To avoid rebuilds on changing tests, the build script will only rerun if
files under src/ are changed. This means the actual git status may show
changed files and this would not show up in the version. This should not
be an issue as files not in src/ should not affect the build output.
2016-06-12 10:38:03 +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
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
9761cf71d8 Tests 2016-04-22 18:53:39 +12:00
Kamal Marhubi
27c91ee35b rustfmt: Parse options once instead of once per file argument (#944)
`update_config()` was parsing the `write-mode` option once for each file
argument. This commit parses them once up front into a `CliOptions`
struct, which is then applied to the config before calling `run()`.
2016-04-16 22:34:15 +02:00
Aleksey Kladov
77350e49b5 return non-zero exit code if there were errors 2016-04-15 02:51:50 +03:00
Kamal Marhubi
72427356eb rustfmt: Simplify match in project file lookup loop
This commit changes the match in `lookup_project_file` to use pattern
guards.
2016-04-10 18:42:55 -04:00
Kamal Marhubi
fe5fa874da rustfmt: Make error handling more idiomatic
This commit replaces the `Operation::InvalidInput` variant with
`Result`, and uses the `try!()` macro instead of explicit matching.
2016-04-10 17:58:14 -04:00
Kamal Marhubi
b55e50f387 rustfmt: Move getopts::Options creation to its own function 2016-04-10 17:57:44 -04:00
Srinivas Reddy Thatiparthy
901c5b1a5d use std::error instead std::out 2016-04-06 23:23:02 +05:30
Nick Cameron
4fdf859787 Merge pull request #897 from matklad/refactor-run
Refactor run family of functions
2016-04-05 11:25:13 +12:00
0x0G
6e393b3d53 Fix. rustfmt write to stderr instead stdout
Fix. rustfmt write to stderr instead stdout
2016-04-04 12:49:16 +02:00
Aleksey Kladov
84fb2f402e refactor: unify run and run_from_stdin 2016-04-02 22:24:38 +03:00
Aleksey Kladov
c7e51d3994 minor: use enum instead of pair of booleans
This is a bit more typing, but statically forbids using both verbose and
quiet
2016-03-29 02:37:43 +03:00
Aleksey Kladov
ac7778cc51 cargo-fmt: don't return zero on failure 2016-03-29 02:11:43 +03:00
Jason Dusek
867b5074aa Use braces, not parens, for macro def 2016-03-11 00:41:11 -08:00
Jason Dusek
223df90c81 Align arguments 2016-03-11 00:15:26 -08:00
Jason Dusek
d216c358ef Write non-output to stderr when there is output 2016-03-11 00:15:26 -08:00
Kamal Marhubi
de1fc319c1 rustfmt: Use struct-like enum variants for Operation 2016-03-02 13:08:08 -05:00
Kamal Marhubi
14dbac5fd7 config: Use write_mode from config
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
2016-02-08 22:52:44 -05:00