about summary refs log tree commit diff
path: root/src/utils.rs
AgeCommit message (Collapse)AuthorLines
2017-06-06RebasingNick Cameron-1/+1
2017-06-06Format pub(restricted) properlytopecongiro-1/+4
2017-06-06Update syntex_syntaxest31-3/+13
Bases on commit to switch to libsyntax by @nrc
2017-05-25Format source codestopecongiro-2/+1
2017-05-25Remove dependency on ItertoolsNick Cameron-4/+2
2017-05-24Format source codestopecongiro-1/+2
2017-05-23Implement combining for tuple and blocktopecongiro-20/+23
2017-05-16Add methods to serialize Config to TOML.Michael Killough-2/+21
Two different modes: - Serialize the full Config object. This is useful as `Config::default().to_toml()` to output a rustfmt.toml with defaults (#317). - Serialize only the options that have been accessed. This could be useful to output a minimal rustfmt.toml for a project. (If the default value of any unused config item changes, you'll then get the new default when you come to use it). This commit doesn't expose this anywhere - deciding a sensible CLI is a bit trickier. This commit also has very simple error reporting (Result<String, String>) - once the CLI is decided, a more sensible method of reporting errors might become obvious.
2017-05-16Switch to accessing config items via method.Michael Killough-1/+1
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-08Replace 'try!' with '?'topecongiro-1/+1
2017-05-03Format fixest31-1/+1
2017-05-03Simplificationsest31-4/+4
2017-05-03Drop rustc-serialize, use serde, update toml dependencyest31-4/+20
2017-03-29Fix a typotopecongiro-1/+1
2017-03-28Remove duplicate definitionstopecongiro-0/+10
This commit removes duplicated definitions of `type_annotation_separator` and `type_bound_colon`.
2017-03-28test falloutNick Cameron-6/+2
2017-03-28fallout - source reformattingNick Cameron-10/+15
2017-03-28Source formatting falloutNick Cameron-2/+4
2017-03-07Formatting falloutNick Cameron-1/+5
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-02-21WIPNick Cameron-3/+3
2017-01-31Refactor indent and width into Shape structNick Cameron-8/+8
2017-01-20Update to latest SyntexNick Cameron-3/+5
As a side-effect of the Path changes, we are now a bit more aggressive about normalising paths.
2016-12-23Update to the latest syntex moduleErick Tryzelaar-4/+4
One notable feature is this this adds support for the experimental `let x = loop { ... break $expr; }` syntax. This also includes a test for formatting all the break and continue variations.
2016-11-21update Serde, etc.Nick Cameron-25/+8
Lots of changes to how closures work
2016-09-16Update to latest SyntexNick Cameron-7/+38
+ Cargo update + 0.6.2 release
2016-08-29Run clippysinkuu-1/+1
2016-07-26Add `use` declaration re-ordering (#1104)Stuart Dootson-0/+7
* Add config options for combinations of lines and items * Reordering of import lines implemented. * Changed nested matches to tuple pattern matching * Added ordering of path list items to the ordering of use declarations * Move `format_imports` and `format_import` methods to `imports.rs` * Add comment to explain how `use` declarations are split off while walking through a module * Change `ImportReordering` config option to separate boolean options
2016-06-10Fix integer underflow in extra_offsetMarcus Klaas-2/+1
2016-05-31utils: Move codemap related utilities to a dedicated moduleKamal Marhubi-38/+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-29Format non-statement if-else expressions on a single lineMarcus Klaas-5/+1
2016-05-28Handle pub(restricted) (#1013)Kamal Marhubi-8/+20
* 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-05deps: Update syntex_syntax to 0.32.0Kamal Marhubi-1/+1
2016-05-02Handle new visibility types more gracefullyKamal Marhubi-6/+6
2016-05-01deps: Update syntex_syntax to 0.31.0Kamal Marhubi-2/+5
Most of the churn on this bump comes from the `Visibility` enum changing from pub enum Visibility { Public, Inherited, } to pub enum Visibility { Public, Crate, Restricted { path: P<Path>, id: NodeId }, Inherited, } which require taking `Visibility` by reference in most places. The new variants are not handled at this point. Refs #970
2016-04-22Change defaults and update tests and sourceNick Cameron-8/+8
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-18Add option to force explicit extern ABI'sMarcus Klaas-3/+6
2016-04-15config: Rename get_variant_names to doc_hintKamal Marhubi-1/+1
The `ConfigType` trait is implemented for non-enum types, so the name no longer makes perfect sense.
2016-04-14Be careful about where we change braces in closuresNick Cameron-0/+19
And some general refactoring of closure code. Fixes #863
2016-04-12Reviewer comments - mostly fix rewrite_guardNick Cameron-0/+7
2016-04-06use std::error instead std::outSrinivas Reddy Thatiparthy-0/+10
2016-03-28Use checked_next_power_of_two from std instead of custom methodKamal Marhubi-35/+0
NB The custom method returned 0 on an input of 0, which is arguably incorrect: 0 is not a power of two; the method in `std` returns 1 in that case.
2016-03-14Merge pull request #857 from kamalmarhubi/codemap-extNick Cameron-27/+35
utils: Add CodeMapExt extension trait for span_* methods
2016-03-13utils: Add CodeMapSpanUtils trait for span_* methodsKamal Marhubi-27/+35
This commit adds a CodeMapSpanUtils extension trait on CodeMap, and moves some functions to methods there: - span_after - span_after_last - span_before This better reflects them being lookup methods on the codemap.
2016-03-02deps: Update syntex_syntax to 0.29.1Kamal Marhubi-14/+14
2016-01-12Handle more possible comment position for if elseDarkDrek-0/+8
Extended the test with the new possiblecomment positions
2016-01-07Merge pull request #747 from Manishearth/clippyNick Cameron-2/+1
Clippy rustfmt
2016-01-07Clippy rustfmtManish Goregaokar-2/+1
2016-01-02ignore case for config enums. Fixes #738Victor M. Suarez-12/+14
2015-12-27Make fn argument formatting more resilient for complex self typesMarcus Klaas-0/+12
2015-11-25Reformat trim_newlinesKevin Yeh-6/+6