Remove possible whitespace from the `CommentStyle::opener()` so that the literal itself has control over the comment's leading spaces.
This is most useful for tools, such as bindgen, to allow for example: machine-readable comments with precise syntax rules, or idempotently round-tripping between the proc-macro API and rustfmt.
- rewrite_with_alignment was called from the expr module with the wrong
shape that missed the extra offset needed for the visual style
- rewrite_with_alignment was indenting the given shape although that
should have been the caller's responsability
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>