-
Notifications
You must be signed in to change notification settings - Fork 971
Closed
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issuegood first issueIssues up for grabs, also good candidates for new rustfmt contributorsIssues up for grabs, also good candidates for new rustfmt contributorshacktoberfest
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:
rustfmtdirectly on the file
(edited by calebcartwright to include inline reproduction snippet)
t-nelson
Metadata
Metadata
Assignees
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEE-help-wantedCall for participation: help is requested to fix this issueCall for participation: help is requested to fix this issuegood first issueIssues up for grabs, also good candidates for new rustfmt contributorsIssues up for grabs, also good candidates for new rustfmt contributorshacktoberfest