rust-clippy/tests/ui/redundant_guards.stderr
bors ef736489e7 Auto merge of #11468 - mojave2:issue-11465, r=blyxyas
add extra `byref` checking for the guard's local

changelog: [`redundant_guards`]: Now checks if the variable is bound using `ref` before linting.

The lint should not be emitted, when the local variable is bind by-ref in the pattern.

fixes #11465
2023-09-16 22:02:10 +00:00

171 lines
3.9 KiB
Text

error: redundant guard
--> $DIR/redundant_guards.rs:33:20
|
LL | C(x, y) if let 1 = y => ..,
| ^^^^^^^^^
|
= note: `-D clippy::redundant-guards` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::redundant_guards)]`
help: try
|
LL - C(x, y) if let 1 = y => ..,
LL + C(x, 1) => ..,
|
error: redundant guard
--> $DIR/redundant_guards.rs:39:20
|
LL | Some(x) if matches!(x, Some(1) if true) => ..,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL | Some(Some(1)) if true => ..,
| ~~~~~~~ ~~~~~~~
error: redundant guard
--> $DIR/redundant_guards.rs:40:20
|
LL | Some(x) if matches!(x, Some(1)) => {
| ^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - Some(x) if matches!(x, Some(1)) => {
LL + Some(Some(1)) => {
|
error: redundant guard
--> $DIR/redundant_guards.rs:44:20
|
LL | Some(x) if let Some(1) = x => ..,
| ^^^^^^^^^^^^^^^
|
help: try
|
LL - Some(x) if let Some(1) = x => ..,
LL + Some(Some(1)) => ..,
|
error: redundant guard
--> $DIR/redundant_guards.rs:45:20
|
LL | Some(x) if x == Some(2) => ..,
| ^^^^^^^^^^^^
|
help: try
|
LL - Some(x) if x == Some(2) => ..,
LL + Some(Some(2)) => ..,
|
error: redundant guard
--> $DIR/redundant_guards.rs:68:20
|
LL | B { e } if matches!(e, Some(A(2))) => ..,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - B { e } if matches!(e, Some(A(2))) => ..,
LL + B { e: Some(A(2)) } => ..,
|
error: redundant guard
--> $DIR/redundant_guards.rs:105:20
|
LL | E::A(y) if y == "not from an or pattern" => {},
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - E::A(y) if y == "not from an or pattern" => {},
LL + E::A("not from an or pattern") => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:112:14
|
LL | x if matches!(x, Some(0)) => ..,
| ^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL - x if matches!(x, Some(0)) => ..,
LL + Some(0) => ..,
|
error: redundant guard
--> $DIR/redundant_guards.rs:160:28
|
LL | Some(ref x) if x == &1 => {},
| ^^^^^^^
|
help: try
|
LL - Some(ref x) if x == &1 => {},
LL + Some(1) => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:161:28
|
LL | Some(ref x) if let &2 = x => {},
| ^^^^^^^^^^
|
help: try
|
LL - Some(ref x) if let &2 = x => {},
LL + Some(2) => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:162:28
|
LL | Some(ref x) if matches!(x, &3) => {},
| ^^^^^^^^^^^^^^^
|
help: try
|
LL - Some(ref x) if matches!(x, &3) => {},
LL + Some(3) => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:180:32
|
LL | B { ref c, .. } if c == &1 => {},
| ^^^^^^^
|
help: try
|
LL - B { ref c, .. } if c == &1 => {},
LL + B { c: 1, .. } => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:181:32
|
LL | B { ref c, .. } if let &1 = c => {},
| ^^^^^^^^^^
|
help: try
|
LL - B { ref c, .. } if let &1 = c => {},
LL + B { c: 1, .. } => {},
|
error: redundant guard
--> $DIR/redundant_guards.rs:182:32
|
LL | B { ref c, .. } if matches!(c, &1) => {},
| ^^^^^^^^^^^^^^^
|
help: try
|
LL - B { ref c, .. } if matches!(c, &1) => {},
LL + B { c: 1, .. } => {},
|
error: aborting due to 14 previous errors