Closed
Description
Note: tools are broken since some time now which is why I'm using a fairly outdated version of clippy: clippy 0.0.212 (c3e9136 2019-07-30)
code:
fn main() {
let foo = if let None = a() {
println!("hi");
a()
} else {
Some(3)
};
}
fn a() -> Option<u32> {
Some(3)
}
cargo fix fails to apply clippys suggestion:
warning: redundant pattern matching, consider using `is_none()`
--> src/main.rs:2:22
|
2 | let foo = if let None = a() {
| _______________- ^^^^
3 | | println!("hi");
4 | | a()
5 | | } else {
6 | | Some(3)
7 | | };
| |_____- help: try this: `if a().is_none()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
If I run cargo fix -Z unstable-options --clippy
, I get an error:
warning: failed to automatically apply fixes suggested by rustc to crate `b`
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: expected `{`, found `;`
--> src/main.rs:2:32
|
2 | let _foo = if a().is_none();
| -- ^ expected `{`
| |
| this `if` statement has a condition, but no block
error: aborting due to previous error
Original diagnostics will follow.
warning: unused variable: `foo`
--> src/main.rs:2:9
|
2 | let foo = if let None = a() {
| ^^^ help: consider prefixing with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default
warning: redundant pattern matching, consider using `is_none()`
--> src/main.rs:2:22
|
2 | let foo = if let None = a() {
| _______________- ^^^^
3 | | println!("hi");
4 | | a()
5 | | } else {
6 | | Some(3)
7 | | };
| |_____- help: try this: `if a().is_none()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: use of a blacklisted/placeholder name `foo`
--> src/main.rs:2:9
|
2 | let foo = if let None = a() {
| ^^^
|
= note: `#[warn(clippy::blacklisted_name)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name
warning: unused variable: `foo`
--> src/main.rs:2:9
|
2 | let foo = if let None = a() {
| ^^^ help: consider prefixing with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default
warning: redundant pattern matching, consider using `is_none()`
--> src/main.rs:2:22
|
2 | let foo = if let None = a() {
| _______________- ^^^^
3 | | println!("hi");
4 | | a()
5 | | } else {
6 | | Some(3)
7 | | };
| |_____- help: try this: `if a().is_none()`
|
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: use of a blacklisted/placeholder name `foo`
--> src/main.rs:2:9
|
2 | let foo = if let None = a() {
| ^^^
|
= note: `#[warn(clippy::blacklisted_name)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name
Finished dev [unoptimized + debuginfo] target(s) in 0.68s