Rather than the versions shipping with the compiler. These are still unstable,
so nightly is still required, but we can control when we update so breakage should
happen less often.
This was a bug in the `diff` crate which has been fixed in 0.1.11. This PR
simply bumps `diff` to that version.
Fixes#1753.
$ xxd main.rs
00000000: 666e 206d 6169 6e28 2920 7b7d fn main() {}
$ cargo run --bin rustfmt -- main.rs --write-mode=diff
$ echo $?
0
$ git checkout issue-1753
Switched to branch 'issue-1753'
$ cargo run --bin rustfmt -- main.rs --write-mode=diff
Diff in /Users/utkarsh/dev/git/rustfmt/main.rs at line 1:
fn main() {}⏎
+⏎
$ echo $?
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.
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.
On unix, `term::stdout()` just reads the `TERM` environment variable to
decide what features are available. It does not check if the output file
descriptor is in fact a tty. This resulted in printing escape codes when
redirecting output.
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
* 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.
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