mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Fix breaking tests
Changes: - Fix stderr breaking the tests - Adding tests over the if arms
This commit is contained in:
parent
fa9f744c2c
commit
40f36658f5
5 changed files with 79 additions and 32 deletions
|
@ -232,6 +232,20 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
|||
return Ok(&foo[0..]);
|
||||
}
|
||||
|
||||
if true {
|
||||
let foo = "";
|
||||
return Ok(&foo[0..]);
|
||||
} else if false {
|
||||
let foo = "bar";
|
||||
return Ok(&foo[0..]);
|
||||
} else if true {
|
||||
let foo = "";
|
||||
return Ok(&foo[0..]);
|
||||
} else {
|
||||
let foo = "";
|
||||
return Ok(&foo[0..]);
|
||||
}
|
||||
|
||||
// False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559.
|
||||
if true {
|
||||
let foo = "";
|
||||
|
|
|
@ -210,5 +210,38 @@ LL | | try!(Ok("foo"));
|
|||
LL | | } else {
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/if_same_then_else.rs:244:12
|
||||
|
|
||||
LL | } else {
|
||||
| ____________^
|
||||
LL | | let foo = "";
|
||||
LL | | return Ok(&foo[0..]);
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
note: same as this
|
||||
--> $DIR/if_same_then_else.rs:241:20
|
||||
|
|
||||
LL | } else if true {
|
||||
| ____________________^
|
||||
LL | | let foo = "";
|
||||
LL | | return Ok(&foo[0..]);
|
||||
LL | | } else {
|
||||
| |_____^
|
||||
|
||||
error: this `if` has the same condition as a previous if
|
||||
--> $DIR/if_same_then_else.rs:241:15
|
||||
|
|
||||
LL | } else if true {
|
||||
| ^^^^
|
||||
|
|
||||
= note: #[deny(clippy::ifs_same_cond)] on by default
|
||||
note: same as this
|
||||
--> $DIR/if_same_then_else.rs:235:8
|
||||
|
|
||||
LL | if true {
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ fn match_same_arms() {
|
|||
|
||||
let _ = match 42 {
|
||||
1 => 2,
|
||||
2 => 2, //~ ERROR 2rd matched arms have same body
|
||||
2 => 2, //~ ERROR 2nd matched arms have same body
|
||||
3 => 2, //~ ERROR 3rd matched arms have same body
|
||||
4 => 3,
|
||||
_ => 0,
|
||||
|
|
|
@ -176,7 +176,7 @@ LL | 41 => 2,
|
|||
error: this `match` has identical arm bodies
|
||||
--> $DIR/match_same_arms.rs:122:14
|
||||
|
|
||||
LL | 2 => 2, //~ ERROR 2rd matched arms have same body
|
||||
LL | 2 => 2, //~ ERROR 2nd matched arms have same body
|
||||
| ^
|
||||
|
|
||||
note: same as this
|
||||
|
@ -216,12 +216,12 @@ LL | 3 => 2, //~ ERROR 3rd matched arms have same body
|
|||
note: same as this
|
||||
--> $DIR/match_same_arms.rs:122:14
|
||||
|
|
||||
LL | 2 => 2, //~ ERROR 2rd matched arms have same body
|
||||
LL | 2 => 2, //~ ERROR 2nd matched arms have same body
|
||||
| ^
|
||||
help: consider refactoring into `2 | 3`
|
||||
--> $DIR/match_same_arms.rs:122:9
|
||||
|
|
||||
LL | 2 => 2, //~ ERROR 2rd matched arms have same body
|
||||
LL | 2 => 2, //~ ERROR 2nd matched arms have same body
|
||||
| ^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
|
|
@ -89,11 +89,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:53:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:53:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -115,11 +115,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:59:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:59:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -141,11 +141,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:65:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:65:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -159,11 +159,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:74:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:74:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -177,11 +177,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:81:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:81:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -195,11 +195,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:87:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:87:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -213,11 +213,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:93:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:93:9
|
||||
|
|
||||
LL | 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
|
||||
|
@ -231,11 +231,11 @@ note: same as this
|
|||
|
|
||||
LL | (Ok(x), Some(_)) => println!("ok {}", x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
|
||||
--> $DIR/matches.rs:116:29
|
||||
help: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
|
||||
--> $DIR/matches.rs:116:9
|
||||
|
|
||||
LL | (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
|
||||
|
@ -249,11 +249,11 @@ note: same as this
|
|||
|
|
||||
LL | Ok(3) => println!("ok"),
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:131:18
|
||||
help: consider refactoring into `Ok(3) | Ok(_)`
|
||||
--> $DIR/matches.rs:131:9
|
||||
|
|
||||
LL | 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: you don't need to add `&` to all patterns
|
||||
|
|
Loading…
Reference in a new issue