* 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.
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.
* Handle attributes (including doc comments) on inline modules
Closes#22Closes#684
* Tweak the rules for changing indentation in comments (to do it less often).