Skip to content

Split up match_bool UI tests #2643

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

Merged
merged 1 commit into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/ui/match_bool.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
fn match_bool() {
let test: bool = true;

match test {
true => 0,
false => 42,
};

let option = 1;
match option == 1 {
true => 1,
false => 0,
};

match test {
true => (),
false => { println!("Noooo!"); }
};

match test {
false => { println!("Noooo!"); }
_ => (),
};

match test && test {
false => { println!("Noooo!"); }
_ => (),
};

match test {
false => { println!("Noooo!"); }
true => { println!("Yes!"); }
};

// Not linted
match option {
1 ... 10 => 1,
11 ... 20 => 2,
_ => 3,
};
}

fn main() {
}
74 changes: 74 additions & 0 deletions tests/ui/match_bool.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
error: this boolean expression can be simplified
--> $DIR/match_bool.rs:25:11
|
25 | match test && test {
| ^^^^^^^^^^^^ help: try: `test`
|
= note: `-D nonminimal-bool` implied by `-D warnings`

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:4:5
|
4 | / match test {
5 | | true => 0,
6 | | false => 42,
7 | | };
| |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }`
|
= note: `-D match-bool` implied by `-D warnings`

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:10:5
|
10 | / match option == 1 {
11 | | true => 1,
12 | | false => 0,
13 | | };
| |_____^ help: consider using an if/else expression: `if option == 1 { 1 } else { 0 }`

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:15:5
|
15 | / match test {
16 | | true => (),
17 | | false => { println!("Noooo!"); }
18 | | };
| |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }`

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:20:5
|
20 | / match test {
21 | | false => { println!("Noooo!"); }
22 | | _ => (),
23 | | };
| |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }`

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:25:5
|
25 | / match test && test {
26 | | false => { println!("Noooo!"); }
27 | | _ => (),
28 | | };
| |_____^ help: consider using an if/else expression: `if !(test && test) { println!("Noooo!"); }`

error: equal expressions as operands to `&&`
--> $DIR/match_bool.rs:25:11
|
25 | match test && test {
| ^^^^^^^^^^^^
|
= note: #[deny(eq_op)] on by default

error: you seem to be trying to match on a boolean expression
--> $DIR/match_bool.rs:30:5
|
30 | / match test {
31 | | false => { println!("Noooo!"); }
32 | | true => { println!("Yes!"); }
33 | | };
| |_____^ help: consider using an if/else expression: `if test { println!("Yes!"); } else { println!("Noooo!"); }`

error: aborting due to 8 previous errors

42 changes: 0 additions & 42 deletions tests/ui/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,6 @@ fn unwrap_addr() -> Option<&'static ExprNode> {
}
}

fn match_bool() {
let test: bool = true;

match test {
true => 0,
false => 42,
};

let option = 1;
match option == 1 {
true => 1,
false => 0,
};

match test {
true => (),
false => { println!("Noooo!"); }
};

match test {
false => { println!("Noooo!"); }
_ => (),
};

match test && test {
false => { println!("Noooo!"); }
_ => (),
};

match test {
false => { println!("Noooo!"); }
true => { println!("Yes!"); }
};

// Not linted
match option {
1 ... 10 => 1,
11 ... 20 => 2,
_ => 3,
};
}

fn ref_pats() {
{
let v = &Some(0);
Expand Down
Loading