| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
Bases on commit to switch to libsyntax by @nrc
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
This commit removes duplicated definitions of `type_annotation_separator` and
`type_bound_colon`.
|
|
|
|
|
|
|
|
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
|
|
|
|
|
|
As a side-effect of the Path changes, we are now a bit more aggressive about normalising paths.
|
|
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.
|
|
Lots of changes to how closures work
|
|
+ Cargo update
+ 0.6.2 release
|
|
|
|
* 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
|
|
|
|
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
|
|
|
|
* 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.
|
|
|
|
|
|
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
|
|
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
|
|
|
|
The `ConfigType` trait is implemented for non-enum types, so the name no
longer makes perfect sense.
|
|
And some general refactoring of closure code.
Fixes #863
|
|
|
|
|
|
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.
|
|
utils: Add CodeMapExt extension trait for span_* methods
|
|
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.
|
|
|
|
Extended the test with the new possiblecomment positions
|
|
Clippy rustfmt
|
|
|
|
|
|
|
|
|