Closed
Description
I tried this code:
fn main() {
if "a" != "a" {
panic!();
}
}
I expected to see this happen: The --fix
operation to be successful.
Instead, this happened:
$ cargo +nightly clippy --fix
Checking clippy-bug v0.1.0 (clippy-bug)
warning: failed to automatically apply fixes suggested by rustc to crate `clippy_bug`
after fixes were automatically applied the compiler reported errors within these files:
* 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/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[E0600]: cannot apply unary operator `!` to type `&'static str`
--> src/main.rs:2:13
|
2 | assert!(!"a" != "a", ..);
| ^^^^ cannot apply unary operator `!`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0600`.
Original diagnostics will follow.
warning: only a `panic!` in `if`-then statement
--> src/main.rs:2:5
|
2 | / if "a" != "a" {
3 | | panic!();
4 | | }
| |_____^ help: try: `assert!(!"a" != "a", ..);`
|
= note: `#[warn(clippy::if_then_panic)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_then_panic
warning: equal expressions as operands to `!=`
--> src/main.rs:2:8
|
2 | if "a" != "a" {
| ^^^^^^^^^^
|
= note: `#[warn(clippy::eq_op)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
warning: `clippy-bug` (bin "clippy-bug") generated 2 warnings
warning: `clippy-bug` (bin "clippy-bug" test) generated 2 warnings (2 duplicates)
Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Meta
Rust version (rustc -Vv
):
rustc 1.57.0-nightly (9dbb26efe 2021-10-03)
binary: rustc
commit-hash: 9dbb26efe8a886f7bba94c2b996c9535ce07f917
commit-date: 2021-10-03
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0