mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-22 11:03:16 +00:00
e006c77d61
look inside refs and detect if let &None = ... Fixes https://github.com/rust-lang/rust-clippy/issues/5396 changelog: redundant_pattern_matching: look inside Refs to fix FNs with "if let &None = .. "
105 lines
2.8 KiB
Text
105 lines
2.8 KiB
Text
error: you don't need to add `&` to all patterns
|
|
--> $DIR/match_ref_pats.rs:6:9
|
|
|
|
|
LL | / match v {
|
|
LL | | &Some(v) => println!("{:?}", v),
|
|
LL | | &None => println!("none"),
|
|
LL | | }
|
|
| |_________^
|
|
|
|
|
= note: `-D clippy::match-ref-pats` implied by `-D warnings`
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
LL | match *v {
|
|
LL | Some(v) => println!("{:?}", v),
|
|
LL | None => println!("none"),
|
|
|
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/match_ref_pats.rs:17:5
|
|
|
|
|
LL | / match tup {
|
|
LL | | &(v, 1) => println!("{}", v),
|
|
LL | | _ => println!("none"),
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
LL | match *tup {
|
|
LL | (v, 1) => println!("{}", v),
|
|
|
|
|
|
|
error: you don't need to add `&` to both the expression and the patterns
|
|
--> $DIR/match_ref_pats.rs:23:5
|
|
|
|
|
LL | / match &w {
|
|
LL | | &Some(v) => println!("{:?}", v),
|
|
LL | | &None => println!("none"),
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
|
|
|
LL | match w {
|
|
LL | Some(v) => println!("{:?}", v),
|
|
LL | None => println!("none"),
|
|
|
|
|
|
|
error: redundant pattern matching, consider using `is_none()`
|
|
--> $DIR/match_ref_pats.rs:35:12
|
|
|
|
|
LL | if let &None = a {
|
|
| -------^^^^^---- help: try this: `if a.is_none()`
|
|
|
|
|
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/match_ref_pats.rs:35:5
|
|
|
|
|
LL | / if let &None = a {
|
|
LL | | println!("none");
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
LL | if let None = *a {
|
|
| ^^^^ ^^
|
|
|
|
error: redundant pattern matching, consider using `is_none()`
|
|
--> $DIR/match_ref_pats.rs:40:12
|
|
|
|
|
LL | if let &None = &b {
|
|
| -------^^^^^----- help: try this: `if b.is_none()`
|
|
|
|
error: you don't need to add `&` to both the expression and the patterns
|
|
--> $DIR/match_ref_pats.rs:40:5
|
|
|
|
|
LL | / if let &None = &b {
|
|
LL | | println!("none");
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try
|
|
|
|
|
LL | if let None = b {
|
|
| ^^^^ ^
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/match_ref_pats.rs:67:9
|
|
|
|
|
LL | / match foo_variant!(0) {
|
|
LL | | &Foo::A => println!("A"),
|
|
LL | | _ => println!("Wild"),
|
|
LL | | }
|
|
| |_________^
|
|
|
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
LL | match *foo_variant!(0) {
|
|
LL | Foo::A => println!("A"),
|
|
|
|
|
|
|
error: aborting due to 8 previous errors
|
|
|