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 match_overlapping_arm tests #3398

Merged
merged 1 commit into from Nov 2, 2018
Jump to file or symbol
Failed to load files and symbols.
+245 −227
Diff settings

Always

Just for now

@@ -0,0 +1,75 @@
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(exclusive_range_pattern)]
#![warn(clippy::match_overlapping_arm)]
#![allow(clippy::redundant_pattern_matching)]
/// Tests for match_overlapping_arm
fn overlapping() {
const FOO : u64 = 2;
match 42 {
0 ... 10 => println!("0 ... 10"),
0 ... 11 => println!("0 ... 11"),
_ => (),
}
match 42 {
0 ... 5 => println!("0 ... 5"),
6 ... 7 => println!("6 ... 7"),
FOO ... 11 => println!("0 ... 11"),
_ => (),
}
match 42 {
2 => println!("2"),
0 ... 5 => println!("0 ... 5"),
_ => (),
}
match 42 {
2 => println!("2"),
0 ... 2 => println!("0 ... 2"),
_ => (),
}
match 42 {
0 ... 10 => println!("0 ... 10"),
11 ... 50 => println!("11 ... 50"),
_ => (),
}
match 42 {
2 => println!("2"),
0 .. 2 => println!("0 .. 2"),
_ => (),
}
match 42 {
0 .. 10 => println!("0 .. 10"),
10 .. 50 => println!("10 .. 50"),
_ => (),
}
match 42 {
0 .. 11 => println!("0 .. 11"),
0 ... 11 => println!("0 ... 11"),
_ => (),
}
if let None = Some(42) {
// nothing
} else if let None = Some(42) {
// another nothing :-)
}
}
fn main() {}
@@ -0,0 +1,63 @@
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:20:9
|
20 | 0 ... 10 => println!("0 ... 10"),
| ^^^^^^^^
|
= note: `-D clippy::match-overlapping-arm` implied by `-D warnings`
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:21:9
|
21 | 0 ... 11 => println!("0 ... 11"),
| ^^^^^^^^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:26:9
|
26 | 0 ... 5 => println!("0 ... 5"),
| ^^^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:28:9
|
28 | FOO ... 11 => println!("0 ... 11"),
| ^^^^^^^^^^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:34:9
|
34 | 0 ... 5 => println!("0 ... 5"),
| ^^^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:33:9
|
33 | 2 => println!("2"),
| ^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:40:9
|
40 | 0 ... 2 => println!("0 ... 2"),
| ^^^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:39:9
|
39 | 2 => println!("2"),
| ^
error: some ranges overlap
--> $DIR/match_overlapping_arm.rs:63:9
|
63 | 0 .. 11 => println!("0 .. 11"),
| ^^^^^^^
|
note: overlaps with this
--> $DIR/match_overlapping_arm.rs:64:9
|
64 | 0 ... 11 => println!("0 ... 11"),
| ^^^^^^^^
error: aborting due to 5 previous errors
Copy path View file
@@ -74,65 +74,6 @@ fn ref_pats() {
}
}
fn overlapping() {
const FOO : u64 = 2;
match 42 {
0 ... 10 => println!("0 ... 10"),
0 ... 11 => println!("0 ... 11"),
_ => (),
}
match 42 {
0 ... 5 => println!("0 ... 5"),
6 ... 7 => println!("6 ... 7"),
FOO ... 11 => println!("0 ... 11"),
_ => (),
}
match 42 {
2 => println!("2"),
0 ... 5 => println!("0 ... 5"),
_ => (),
}
match 42 {
2 => println!("2"),
0 ... 2 => println!("0 ... 2"),
_ => (),
}
match 42 {
0 ... 10 => println!("0 ... 10"),
11 ... 50 => println!("11 ... 50"),
_ => (),
}
match 42 {
2 => println!("2"),
0 .. 2 => println!("0 .. 2"),
_ => (),
}
match 42 {
0 .. 10 => println!("0 .. 10"),
10 .. 50 => println!("10 .. 50"),
_ => (),
}
match 42 {
0 .. 11 => println!("0 .. 11"),
0 ... 11 => println!("0 ... 11"),
_ => (),
}
if let None = Some(42) {
// nothing
} else if let None = Some(42) {
// another nothing :-)
}
}
fn match_wild_err_arm() {
let x: Result<i32, &str> = Ok(3);
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.