* Add custom comments
This allows users to use custom comments such as
```
//@ this is a custom comment
//@ with multiple lines
```
without having them destroyed by rustfmt.
* Fix issues with empty lines
* Check non-whitespace right after custom comments
Only change multiline comments of the form
```rust
/*
* Text
*/
```
while not affecting comments of the form
```rust
/*
Text
*/
```
when normalize_comments is off. In the first case,
we have a known character we can align against, while
we don't have one in the second case.
Before, we have converted the second form into the first,
but this is against the spirit of normalize_comments being
turned off.
Fixes#956
* Split impl at 'for' if a line break is needed
* Fix formatting
* Improve comments
* Skip second try if there is no 'for'
* Restore intentional trailing whitespace
* Change test source to be incorrectly formatted
* Restore more missing trailing whitespace
* Remove too much whitespace...
Really should learn how to use git revert.
* Change required to prevent a trailing space at the end of a separate module being propagated
* Detect the start of the output file rather than the start of the input file when deciding whether to output preceding snippets - this stops unnecessary whitespace and blank lines from being inserted when spans and statements are output in an order other than that from the input file.
* Add code to prevent space from being added with the prefix snippet if a) the snippet is entirely horizontal whitespace, or b) the snippet contains whitespace followed by a newline. This prevents trailing spaces at the end of a line from being added.
* Tests for this issue
* Tidy up `match` statements
* Add test with blank lines between `use` statements
* Fix issue-1049
* Add testcase suggested by pepyakin
* Fix last commit
* Handle special case
* Remove debugging println
* Fix grammar in comment
* Change word in comment
* Add test for long func without ret type
* Add one more test
* 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 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.
This commit adds a very rough implementation of handling the specified
line ranges in `config.file_lines_map` for statements. It reformats a
statement if its span is fully contained in the set of lines specified
for the file.
The implementation here is intended as a proof of concept, and
demonstration that the machinery added in the preceding commits is
functional. A final implementation would likely hook in via the
`Rewrite` trait.
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.mdFixes#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.