mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-21 02:23:19 +00:00
363 lines
11 KiB
Text
363 lines
11 KiB
Text
error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
|
|
--> $DIR/matches.rs:31:5
|
|
|
|
|
31 | / match ExprNode::Butterflies {
|
|
32 | | ExprNode::ExprAddrOf => Some(&NODE),
|
|
33 | | _ => { let x = 5; None },
|
|
34 | | }
|
|
| |_____^ help: try this: `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }`
|
|
|
|
|
= note: `-D clippy::single-match-else` implied by `-D warnings`
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/matches.rs:40:9
|
|
|
|
|
40 | / match v {
|
|
41 | | &Some(v) => println!("{:?}", v),
|
|
42 | | &None => println!("none"),
|
|
43 | | }
|
|
| |_________^
|
|
|
|
|
= note: `-D clippy::match-ref-pats` implied by `-D warnings`
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
40 | match *v {
|
|
41 | Some(v) => println!("{:?}", v),
|
|
42 | None => println!("none"),
|
|
|
|
|
|
|
error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
|
|
--> $DIR/matches.rs:50:5
|
|
|
|
|
50 | / match tup {
|
|
51 | | &(v, 1) => println!("{}", v),
|
|
52 | | _ => println!("none"),
|
|
53 | | }
|
|
| |_____^ help: try this: `if let &(v, 1) = tup { $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ; } else { $ crate :: io :: _print ( format_args_nl ! ( $ ( $ arg ) * ) ) ; }`
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/matches.rs:50:5
|
|
|
|
|
50 | / match tup {
|
|
51 | | &(v, 1) => println!("{}", v),
|
|
52 | | _ => println!("none"),
|
|
53 | | }
|
|
| |_____^
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
50 | match *tup {
|
|
51 | (v, 1) => println!("{}", v),
|
|
|
|
|
|
|
error: you don't need to add `&` to both the expression and the patterns
|
|
--> $DIR/matches.rs:56:5
|
|
|
|
|
56 | / match &w {
|
|
57 | | &Some(v) => println!("{:?}", v),
|
|
58 | | &None => println!("none"),
|
|
59 | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
56 | match w {
|
|
57 | Some(v) => println!("{:?}", v),
|
|
58 | None => println!("none"),
|
|
|
|
|
|
|
error: you don't need to add `&` to all patterns
|
|
--> $DIR/matches.rs:67:5
|
|
|
|
|
67 | / if let &None = a {
|
|
68 | | println!("none");
|
|
69 | | }
|
|
| |_____^
|
|
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
|
|
|
|
67 | if let None = *a {
|
|
| ^^^^ ^^
|
|
|
|
error: you don't need to add `&` to both the expression and the patterns
|
|
--> $DIR/matches.rs:72:5
|
|
|
|
|
72 | / if let &None = &b {
|
|
73 | | println!("none");
|
|
74 | | }
|
|
| |_____^
|
|
help: try
|
|
|
|
|
72 | if let None = b {
|
|
| ^^^^ ^
|
|
|
|
error: some ranges overlap
|
|
--> $DIR/matches.rs:81:9
|
|
|
|
|
81 | 0 ... 10 => println!("0 ... 10"),
|
|
| ^^^^^^^^
|
|
|
|
|
= note: `-D clippy::match-overlapping-arm` implied by `-D warnings`
|
|
note: overlaps with this
|
|
--> $DIR/matches.rs:82:9
|
|
|
|
|
82 | 0 ... 11 => println!("0 ... 11"),
|
|
| ^^^^^^^^
|
|
|
|
error: some ranges overlap
|
|
--> $DIR/matches.rs:87:9
|
|
|
|
|
87 | 0 ... 5 => println!("0 ... 5"),
|
|
| ^^^^^^^
|
|
|
|
|
note: overlaps with this
|
|
--> $DIR/matches.rs:89:9
|
|
|
|
|
89 | FOO ... 11 => println!("0 ... 11"),
|
|
| ^^^^^^^^^^
|
|
|
|
error: some ranges overlap
|
|
--> $DIR/matches.rs:95:9
|
|
|
|
|
95 | 0 ... 5 => println!("0 ... 5"),
|
|
| ^^^^^^^
|
|
|
|
|
note: overlaps with this
|
|
--> $DIR/matches.rs:94:9
|
|
|
|
|
94 | 2 => println!("2"),
|
|
| ^
|
|
|
|
error: some ranges overlap
|
|
--> $DIR/matches.rs:101:9
|
|
|
|
|
101 | 0 ... 2 => println!("0 ... 2"),
|
|
| ^^^^^^^
|
|
|
|
|
note: overlaps with this
|
|
--> $DIR/matches.rs:100:9
|
|
|
|
|
100 | 2 => println!("2"),
|
|
| ^
|
|
|
|
error: some ranges overlap
|
|
--> $DIR/matches.rs:124:9
|
|
|
|
|
124 | 0 .. 11 => println!("0 .. 11"),
|
|
| ^^^^^^^
|
|
|
|
|
note: overlaps with this
|
|
--> $DIR/matches.rs:125:9
|
|
|
|
|
125 | 0 ... 11 => println!("0 ... 11"),
|
|
| ^^^^^^^^
|
|
|
|
error: Err(_) will match all errors, maybe not a good idea
|
|
--> $DIR/matches.rs:142:9
|
|
|
|
|
142 | Err(_) => panic!("err")
|
|
| ^^^^^^
|
|
|
|
|
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings`
|
|
= note: to remove this warning, match each error separately or use unreachable macro
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:141:18
|
|
|
|
|
141 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::match-same-arms` implied by `-D warnings`
|
|
note: same as this
|
|
--> $DIR/matches.rs:140:18
|
|
|
|
|
140 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:140:18
|
|
|
|
|
140 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: Err(_) will match all errors, maybe not a good idea
|
|
--> $DIR/matches.rs:148:9
|
|
|
|
|
148 | Err(_) => {panic!()}
|
|
| ^^^^^^
|
|
|
|
|
= note: to remove this warning, match each error separately or use unreachable macro
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:147:18
|
|
|
|
|
147 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:146:18
|
|
|
|
|
146 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:146:18
|
|
|
|
|
146 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: Err(_) will match all errors, maybe not a good idea
|
|
--> $DIR/matches.rs:154:9
|
|
|
|
|
154 | Err(_) => {panic!();}
|
|
| ^^^^^^
|
|
|
|
|
= note: to remove this warning, match each error separately or use unreachable macro
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:153:18
|
|
|
|
|
153 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:152:18
|
|
|
|
|
152 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:152:18
|
|
|
|
|
152 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:160:18
|
|
|
|
|
160 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:159:18
|
|
|
|
|
159 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:159:18
|
|
|
|
|
159 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:167:18
|
|
|
|
|
167 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:166:18
|
|
|
|
|
166 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:166:18
|
|
|
|
|
166 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:173:18
|
|
|
|
|
173 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:172:18
|
|
|
|
|
172 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:172:18
|
|
|
|
|
172 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:179:18
|
|
|
|
|
179 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:178:18
|
|
|
|
|
178 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:178:18
|
|
|
|
|
178 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:200:29
|
|
|
|
|
200 | (Ok(_), Some(x)) => println!("ok {}", x),
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:199:29
|
|
|
|
|
199 | (Ok(x), Some(_)) => println!("ok {}", x),
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
|
|
--> $DIR/matches.rs:199:29
|
|
|
|
|
199 | (Ok(x), Some(_)) => println!("ok {}", x),
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/matches.rs:215:18
|
|
|
|
|
215 | Ok(_) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/matches.rs:214:18
|
|
|
|
|
214 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
note: consider refactoring into `Ok(3) | Ok(_)`
|
|
--> $DIR/matches.rs:214:18
|
|
|
|
|
214 | Ok(3) => println!("ok"),
|
|
| ^^^^^^^^^^^^^^
|
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
|
|
|
error: use as_ref() instead
|
|
--> $DIR/matches.rs:222:33
|
|
|
|
|
222 | let borrowed: Option<&()> = match owned {
|
|
| _________________________________^
|
|
223 | | None => None,
|
|
224 | | Some(ref v) => Some(v),
|
|
225 | | };
|
|
| |_____^ help: try this: `owned.as_ref()`
|
|
|
|
|
= note: `-D clippy::match-as-ref` implied by `-D warnings`
|
|
|
|
error: use as_mut() instead
|
|
--> $DIR/matches.rs:228:39
|
|
|
|
|
228 | let borrow_mut: Option<&mut ()> = match mut_owned {
|
|
| _______________________________________^
|
|
229 | | None => None,
|
|
230 | | Some(ref mut v) => Some(v),
|
|
231 | | };
|
|
| |_____^ help: try this: `mut_owned.as_mut()`
|
|
|
|
error: aborting due to 26 previous errors
|
|
|