Run cargo dev bless to update fixes & stderr

This commit is contained in:
Nahua Kang 2022-08-23 19:50:34 +02:00
parent 5ee1c24f28
commit 4eaadd622d
3 changed files with 44 additions and 19 deletions

View File

@ -96,18 +96,18 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
); );
} else { } else {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
EQUATABLE_IF_LET, EQUATABLE_IF_LET,
expr.span, expr.span,
"this pattern matching can be expressed using `matches!`", "this pattern matching can be expressed using `matches!`",
"try", "try",
format!( format!(
"matches!({}, {})", "matches!({}, {})",
snippet_with_context(cx, let_expr.init.span, expr.span.ctxt(), "..", &mut applicability).0, snippet_with_context(cx, let_expr.init.span, expr.span.ctxt(), "..", &mut applicability).0,
snippet_with_context(cx, let_expr.pat.span, expr.span.ctxt(), "..", &mut applicability).0, snippet_with_context(cx, let_expr.pat.span, expr.span.ctxt(), "..", &mut applicability).0,
), ),
applicability, applicability,
) );
} }
} }
} }

View File

@ -23,6 +23,11 @@ struct Struct {
b: bool, b: bool,
} }
struct NoPartialEqStruct {
a: i32,
b: bool,
}
enum NotPartialEq { enum NotPartialEq {
A, A,
B, B,
@ -47,6 +52,7 @@ fn main() {
let e = Enum::UnitVariant; let e = Enum::UnitVariant;
let f = NotPartialEq::A; let f = NotPartialEq::A;
let g = NotStructuralEq::A; let g = NotStructuralEq::A;
let h = NoPartialEqStruct { a: 2, b: false };
// true // true
@ -66,10 +72,11 @@ fn main() {
if let Some(3 | 4) = c {} if let Some(3 | 4) = c {}
if let Struct { a, b: false } = d {} if let Struct { a, b: false } = d {}
if let Struct { a: 2, b: x } = d {} if let Struct { a: 2, b: x } = d {}
if let NotPartialEq::A = f {} if matches!(f, NotPartialEq::A) {}
if g == NotStructuralEq::A {} if g == NotStructuralEq::A {}
if let Some(NotPartialEq::A) = Some(f) {} if matches!(Some(f), Some(NotPartialEq::A)) {}
if Some(g) == Some(NotStructuralEq::A) {} if Some(g) == Some(NotStructuralEq::A) {}
if matches!(h, NoPartialEqStruct { a: 2, b: false }) {}
macro_rules! m1 { macro_rules! m1 {
(x) => { (x) => {

View File

@ -1,5 +1,5 @@
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:53:8 --> $DIR/equatable_if_let.rs:59:8
| |
LL | if let 2 = a {} LL | if let 2 = a {}
| ^^^^^^^^^ help: try: `a == 2` | ^^^^^^^^^ help: try: `a == 2`
@ -7,64 +7,82 @@ LL | if let 2 = a {}
= note: `-D clippy::equatable-if-let` implied by `-D warnings` = note: `-D clippy::equatable-if-let` implied by `-D warnings`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:54:8 --> $DIR/equatable_if_let.rs:60:8
| |
LL | if let Ordering::Greater = a.cmp(&b) {} LL | if let Ordering::Greater = a.cmp(&b) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.cmp(&b) == Ordering::Greater` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.cmp(&b) == Ordering::Greater`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:55:8 --> $DIR/equatable_if_let.rs:61:8
| |
LL | if let Some(2) = c {} LL | if let Some(2) = c {}
| ^^^^^^^^^^^^^^^ help: try: `c == Some(2)` | ^^^^^^^^^^^^^^^ help: try: `c == Some(2)`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:56:8 --> $DIR/equatable_if_let.rs:62:8
| |
LL | if let Struct { a: 2, b: false } = d {} LL | if let Struct { a: 2, b: false } = d {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d == (Struct { a: 2, b: false })` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d == (Struct { a: 2, b: false })`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:57:8 --> $DIR/equatable_if_let.rs:63:8
| |
LL | if let Enum::TupleVariant(32, 64) = e {} LL | if let Enum::TupleVariant(32, 64) = e {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::TupleVariant(32, 64)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::TupleVariant(32, 64)`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:58:8 --> $DIR/equatable_if_let.rs:64:8
| |
LL | if let Enum::RecordVariant { a: 64, b: 32 } = e {} LL | if let Enum::RecordVariant { a: 64, b: 32 } = e {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == (Enum::RecordVariant { a: 64, b: 32 })` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == (Enum::RecordVariant { a: 64, b: 32 })`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:59:8 --> $DIR/equatable_if_let.rs:65:8
| |
LL | if let Enum::UnitVariant = e {} LL | if let Enum::UnitVariant = e {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::UnitVariant` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::UnitVariant`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:60:8 --> $DIR/equatable_if_let.rs:66:8
| |
LL | if let (Enum::UnitVariant, &Struct { a: 2, b: false }) = (e, &d) {} LL | if let (Enum::UnitVariant, &Struct { a: 2, b: false }) = (e, &d) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(e, &d) == (Enum::UnitVariant, &Struct { a: 2, b: false })` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(e, &d) == (Enum::UnitVariant, &Struct { a: 2, b: false })`
error: this pattern matching can be expressed using `matches!`
--> $DIR/equatable_if_let.rs:75:8
|
LL | if let NotPartialEq::A = f {}
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(f, NotPartialEq::A)`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:70:8 --> $DIR/equatable_if_let.rs:76:8
| |
LL | if let NotStructuralEq::A = g {} LL | if let NotStructuralEq::A = g {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `g == NotStructuralEq::A` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `g == NotStructuralEq::A`
error: this pattern matching can be expressed using `matches!`
--> $DIR/equatable_if_let.rs:77:8
|
LL | if let Some(NotPartialEq::A) = Some(f) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(Some(f), Some(NotPartialEq::A))`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:72:8 --> $DIR/equatable_if_let.rs:78:8
| |
LL | if let Some(NotStructuralEq::A) = Some(g) {} LL | if let Some(NotStructuralEq::A) = Some(g) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(g) == Some(NotStructuralEq::A)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(g) == Some(NotStructuralEq::A)`
error: this pattern matching can be expressed using equality error: this pattern matching can be expressed using `matches!`
--> $DIR/equatable_if_let.rs:79:8 --> $DIR/equatable_if_let.rs:79:8
| |
LL | if let NoPartialEqStruct { a: 2, b: false } = h {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(h, NoPartialEqStruct { a: 2, b: false })`
error: this pattern matching can be expressed using equality
--> $DIR/equatable_if_let.rs:86:8
|
LL | if let m1!(x) = "abc" { LL | if let m1!(x) = "abc" {
| ^^^^^^^^^^^^^^^^^^ help: try: `"abc" == m1!(x)` | ^^^^^^^^^^^^^^^^^^ help: try: `"abc" == m1!(x)`
error: aborting due to 11 previous errors error: aborting due to 14 previous errors