about summary refs log tree commit diff
path: root/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2017-06-10Reset the error count of parser from the previous filetopecongiro-6/+15
2017-06-06Update syntex_syntaxest31-3/+3
Bases on commit to switch to libsyntax by @nrc
2017-06-04Format source codestopecongiro-1/+1
2017-06-01Format source codesSeiichi Uchida-15/+17
2017-05-25Remove dependency on ItertoolsNick Cameron-1/+0
2017-05-25Remove multimap depNick Cameron-1/+0
2017-05-18Provide `config.set().item(value)` API.Michael Killough-3/+1
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-16Switch to accessing config items via method.Michael Killough-22/+24
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-15Merge pull request #1510 from fintelia/better-filelinesNick Cameron-16/+24
Better file_lines
2017-05-08Replace 'try!' with '?'topecongiro-8/+8
2017-05-08Refactor Shapetopecongiro-16/+5
2017-05-08Add indented and with_max_widthtopecongiro-13/+23
2017-05-06Respect file_lines within format_lines() functionJonathan Behrens-16/+24
2017-05-05Block format control flow discriminant expressions and binopsNick Cameron-0/+8
Fixes #1450 Adds control_style option
2017-05-03Drop rustc-serialize, use serde, update toml dependencyest31-1/+5
2017-05-01Remove TODO from 'format_tuple_struct'topecongiro-1/+1
2017-05-01Refactor Shapetopecongiro-20/+5
2017-04-18format_lines: fix line_len for config.max_widthEvgeny Duzhakov-2/+2
2017-04-02Do not count `\r` as part of line width.Mike Boutin-1/+0
Resolves #1335. Does not attempt to handle a `\r` not followed by a `\n` nor attempt to handle Unicode intricacies (#6) including zero-width or multi-byte characters.
2017-03-28test falloutNick Cameron-3/+1
2017-03-28fallout - source reformattingNick Cameron-1/+3
2017-03-22Block indenting for struct lit patternsNick Cameron-0/+8
Now follows struct_lit_style (and most other struct_lit_ options). Required a fair bit of refactoring and bug fixes. Fixes #1311
2017-03-07Formatting falloutNick Cameron-1/+4
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-06added unit tests for Indent and Shape (#1353)Andy Librian-0/+85
2017-02-23Merge pull request #1325 from C4K3/masterNick Cameron-1/+1
Add error_on_line_overflow option
2017-02-23FalloutNick Cameron-18/+18
2017-02-21WIPNick Cameron-3/+93
2017-02-19Add error_on_line_overflow optionSebastian Blunt-1/+1
Makes it configurable whether to error if unable to get all lines within the max_width.
2017-02-07New `disable_all_formatting` config option (#1297)Craig M. Brandenburg-0/+3
* New `disable_all_formatting` config option * Resolve code review comments
2017-01-31Refactor indent and width into Shape structNick Cameron-0/+44
2017-01-20process cfg'ed off modulesNick Cameron-2/+9
Fixes #1229 Fixes #1277
2017-01-09Better message for LineOverflow error (#1268)Stepan Koltsov-6/+11
(with current length and configured limit)
2016-11-21update Serde, etc.Nick Cameron-2/+2
Lots of changes to how closures work
2016-09-16Update to latest SyntexNick Cameron-4/+5
+ Cargo update + 0.6.2 release
2016-08-29Run clippysinkuu-3/+3
2016-06-21Return failure exit code on found diffs (fix #906)Johann Hofmann-7/+13
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-05-31Add type to represent collection of lines in filesKamal Marhubi-0/+2
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-31utils: Move codemap related utilities to a dedicated moduleKamal Marhubi-0/+1
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-31Derive Debug for the Input enumKamal Marhubi-0/+1
2016-05-28Handle pub(restricted) (#1013)Kamal Marhubi-0/+1
* 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-18Handle parser errors betterNick Cameron-5/+10
2016-05-15Write each file as it is formatted (#991)Nick Cameron-96/+120
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-12Bootstrap it. Hard.Marcus Klaas-5/+2
2016-05-06Changed modules & visitor mods to public, set filemap::write_file publicDaniel Campbell-2/+2
2016-04-28Always skip children when using Plain write modeMicah Chalmer-1/+4
Outputting child module contents in the "Plain" write mode does not make sense, since there is no way to differentiate code that came from a child module from that which came from the parent file.
2016-04-27Bail out on recovered errors. (#965)Nick Cameron-4/+15
Closes #915 Closes #930 Closes #931
2016-04-15Don't print empty lines to stderr (#940)Aleksey Kladov-1/+3
2016-04-15return non-zero exit code if there were errorsAleksey Kladov-11/+32
2016-04-14don't silence error unnecessary Aleksey Kladov-5/+1
This `if` was used to separate error output from the formatting output, when they both used stdout. It was useful for integration with tools, which can submit input to stdin and read pretty printed result from stdout without worrying about errors intermingled with the actual result. But now we write errors to `stderr`, so the problem disappears and we can safely remove this `if`. Errors should never pass silently, unless explicitly silenced.
2016-04-13Change stdout to stderr (#925)Srinivas Reddy Thatiparthy-1/+1