Closed
Description
Summary
When running cargo clippy --fix
on the provided test module, cargo writes an additional assert_eq! statement like this
assert_eq!assert_eq!(
, leading to reported errors:
error: expected one of `(`, `[`, or `{`, found `assert_eq`
--> validator-api/src/main.rs:166:19
|
166 | assert_eq!assert_eq!(
| ^^^^^^^^^ expected one of `(`, `[`, or `{`
Reproducer
I tried this code:
#[cfg(test)]
mod test {
#[tokio::test]
async fn foo() {
assert_eq!(2 + 2, 4)
}
}
I expected to see this happen:
$ cargo clippy --fix --allow-dirty --allow-staged
Checking validator-api v0.1.0
Finished `dev` profile [unoptimized + debuginfo] target(s) in 7.04s
Instead, this happened:
$ cargo clippy --fix --allow-dirty --allow-staged
Checking validator-api v0.1.0
warning: failed to automatically apply fixes suggested by rustc to crate `validator_api`
after fixes were automatically applied the compiler reported errors within these files:
* validator-api/src/main.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error: expected one of `(`, `[`, or `{`, found `assert_eq`
--> validator-api/src/main.rs:332:19
|
332 | assert_eq!assert_eq!(2 + 2, 4)
| ^^^^^^^^^ expected one of `(`, `[`, or `{`
error: aborting due to 1 previous error
Original diagnostics will follow.
warning: unneeded `return` statement
--> validator-api/src/main.rs:332:19
|
332 | assert_eq!(2 + 2, 4)
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
332 | assert_eq!assert_eq!(2 + 2, 4)
| ~~~~~~~~~~~~~~~~~~~~
warning: `validator-api` (bin "validator-api" test) generated 1 warning (run `cargo clippy --fix --bin "validator-api" --tests` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.94s
Version
rustc 1.83.0-nightly (7608018cb 2024-09-29)
binary: rustc
commit-hash: 7608018cbdac9e55d0d13529cf43adc33d53efcf
commit-date: 2024-09-29
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Additional Labels
No response