New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI test cleanup: Extract ifs_same_cond tests #3612

Merged
merged 1 commit into from Jan 2, 2019
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+86 −82
Diff settings

Always

Just for now

Copy path View file
@@ -348,50 +348,6 @@ fn if_same_then_else() -> Result<&'static str, ()> {
}
}

#[warn(clippy::ifs_same_cond)]
#[allow(clippy::if_same_then_else)] // all empty blocks
fn ifs_same_cond() {
let a = 0;
let b = false;

if b {
} else if b {
//~ ERROR ifs same condition
}

if a == 1 {
} else if a == 1 {
//~ ERROR ifs same condition
}

if 2 * a == 1 {
} else if 2 * a == 2 {
} else if 2 * a == 1 {
//~ ERROR ifs same condition
} else if a == 1 {
}

// See #659
if cfg!(feature = "feature1-659") {
1
} else if cfg!(feature = "feature2-659") {
2
} else {
3
};

let mut v = vec![1];
if v.pop() == None {
// ok, functions
} else if v.pop() == None {
}

if v.len() == 42 {
// ok, functions
} else if v.len() == 42 {
}
}

fn main() {}

// Issue #2423. This was causing an ICE
Copy path View file
@@ -351,42 +351,5 @@ LL | | try!(Ok("foo"));
LL | | } else {
| |_____^

error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:358:15
|
LL | } else if b {
| ^
|
= note: `-D clippy::ifs-same-cond` implied by `-D warnings`
note: same as this
--> $DIR/copies.rs:357:8
|
LL | if b {
| ^

error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:363:15
|
LL | } else if a == 1 {
| ^^^^^^
|
note: same as this
--> $DIR/copies.rs:362:8
|
LL | if a == 1 {
| ^^^^^^

error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:369:15
|
LL | } else if 2 * a == 1 {
| ^^^^^^^^^^
|
note: same as this
--> $DIR/copies.rs:367:8
|
LL | if 2 * a == 1 {
| ^^^^^^^^^^

error: aborting due to 20 previous errors
error: aborting due to 17 previous errors

Copy path View file
@@ -0,0 +1,46 @@
#![warn(clippy::ifs_same_cond)]
#![allow(clippy::if_same_then_else)] // all empty blocks

fn ifs_same_cond() {
let a = 0;
let b = false;

if b {
} else if b {
//~ ERROR ifs same condition
}

if a == 1 {
} else if a == 1 {
//~ ERROR ifs same condition
}

if 2 * a == 1 {
} else if 2 * a == 2 {
} else if 2 * a == 1 {
//~ ERROR ifs same condition
} else if a == 1 {
}

// See #659
if cfg!(feature = "feature1-659") {
1
} else if cfg!(feature = "feature2-659") {
2
} else {
3
};

let mut v = vec![1];
if v.pop() == None {
// ok, functions
} else if v.pop() == None {
}

if v.len() == 42 {
// ok, functions
} else if v.len() == 42 {
}
}

fn main() {}
Copy path View file
@@ -0,0 +1,39 @@
error: this `if` has the same condition as a previous if
--> $DIR/ifs_same_cond.rs:9:15
|
LL | } else if b {
| ^
|
= note: `-D clippy::ifs-same-cond` implied by `-D warnings`
note: same as this
--> $DIR/ifs_same_cond.rs:8:8
|
LL | if b {
| ^

error: this `if` has the same condition as a previous if
--> $DIR/ifs_same_cond.rs:14:15
|
LL | } else if a == 1 {
| ^^^^^^
|
note: same as this
--> $DIR/ifs_same_cond.rs:13:8
|
LL | if a == 1 {
| ^^^^^^

error: this `if` has the same condition as a previous if
--> $DIR/ifs_same_cond.rs:20:15
|
LL | } else if 2 * a == 1 {
| ^^^^^^^^^^
|
note: same as this
--> $DIR/ifs_same_cond.rs:18:8
|
LL | if 2 * a == 1 {
| ^^^^^^^^^^

error: aborting due to 3 previous errors

ProTip! Use n and p to navigate between commits in a pull request.