I don't really know what it's trying to do, but forgetting about everything
you've seen before when you see whitespace followed by a semicolon doesn't look
right to me, and absolutely no tests were hitting that.
This check was introduced in 5ecdd072d6, however
it was wrong even at that point, and now rustfmt still passes that test,
regardless of macro name.
Fixes#3154.
`tool_attributes` are stable since 1.30. The old `cfg_attr(rustfmt, rustfmt_skip)` attributes aren't necessary anymore and everyone should switch to `#[rustfmt::skip]` sooner or later.
There is also a Clippy lint in the making for this: rust-lang-nursery/rust-clippy#3123
When newline_style is set to Windows, an empty line inside of a macro
results in `\r` being passed to the `fold()` in `MacroBranch::rewrite()`.
`\r` is technically not an empty string, so we try to indent it, leaving
trailing whitespaces behind, even though that was not intended
(as far as I can see).
This commit replaces the `!l.is_empty()` check with calling
`is_empty_line()`, since trying to indent any whitespace-only string
will probably result in problematic trailing whitespaces.
Fixes: #2810
When I reworked the code, it ended not generating the complete list of
need targets. Fix it.
Fixes: #3143.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
By mistake, it was forgotten to print out the edition in use when
printing the rustcmd command. Fix it.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
From now on, the `Cargo.toml` is taken into account when triggering
formatting using `cargo fmt`.
It is considered editor's duty to pass the proper `--edition` argument
for `rustfmt` if it is being called manually.
Refs: #3104.
Refs: #3129.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
When formatting the crate, with `cargo fmt`, it parses each target
with the specific Rust edition.
Fixes: #3104.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
A rustfmt::skip'ed block is indented although original lines are
returned. In order to resolve this, the leading whitespaces are trimmed
on each line while retaining the layout; this leaves the skipped code
to be indented as necessary by the caller.
The new `--edition` command line argument allow the setting of the
desired Rust edition to be used.
Refs: #3104.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
The update is especially important as it adds support for the
`edition` field handling, when parsing `cargo` metadata.
Refs: #3104.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
There is no need to produce the error message again as it is already
produced by the helper method that does the emit mode validation.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
simplify a comparison with "true"
fn can_be_overflowed: remove unused lifetime
fn rewrite_pairs_one_line: pass "list" by reference (it is not consumed in the function)
fn span_for_token_stream: pass "token_stream" by reference since it is not consumed
use tool lints for clippy suppressions