Closed
Description
Describe the bug
Attributes on expressions become doubled every time rustfmt
is ran when preceeded by a comment and the expression contains a cast, i.e. as i64
.
To Reproduce
trait FooBar {
fn foo(&self) -> i64 {
// some comment
#[allow(clippy::cast_possible_wrap)]
1u64 as i64
}
}
Running rustfmt
under tools
on the above playground link causes the attribute to double on every invocation.
Playing around with it, removing either the comment and as i64
cause this not to reproduce, so it seems like it's the combination of them both that is causing this bug.
Expected behavior
The attribute isn't doubled every time.
Meta
- rustfmt version:
rustfmt 1.4.21-nightly (01f2ead 2020-09-04)
and latest stable - From where did you install rustfmt?: rustup
- How do you run rustfmt:
rustfmt
directly on the file
(edited by calebcartwright to include inline reproduction snippet)