forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#5108 - JohnTitor:split-up-0130, r=flip1995
Split up `match` ui test Part of rust-lang#2038 Also, this decreases the line length limit to 220. changelog: none
- Loading branch information
Showing
7 changed files
with
178 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#![feature(exclusive_range_pattern)] | ||
#![allow(clippy::match_same_arms)] | ||
#![warn(clippy::match_wild_err_arm)] | ||
|
||
fn match_wild_err_arm() { | ||
let x: Result<i32, &str> = Ok(3); | ||
|
||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => panic!("err"), | ||
} | ||
|
||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => panic!(), | ||
} | ||
|
||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => { | ||
panic!(); | ||
}, | ||
} | ||
|
||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_e) => panic!(), | ||
} | ||
|
||
// Allowed when used in `panic!`. | ||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_e) => panic!("{}", _e), | ||
} | ||
|
||
// Allowed when not with `panic!` block. | ||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => println!("err"), | ||
} | ||
|
||
// Allowed when used with `unreachable!`. | ||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => unreachable!(), | ||
} | ||
|
||
// Allowed when used with `unreachable!`. | ||
match x { | ||
Ok(3) => println!("ok"), | ||
Ok(_) => println!("ok"), | ||
Err(_) => { | ||
unreachable!(); | ||
}, | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error: `Err(_)` matches all errors | ||
--> $DIR/match_wild_err_arm.rs:11:9 | ||
| | ||
LL | Err(_) => panic!("err"), | ||
| ^^^^^^ | ||
| | ||
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings` | ||
= note: match each error separately or use the error output | ||
|
||
error: `Err(_)` matches all errors | ||
--> $DIR/match_wild_err_arm.rs:17:9 | ||
| | ||
LL | Err(_) => panic!(), | ||
| ^^^^^^ | ||
| | ||
= note: match each error separately or use the error output | ||
|
||
error: `Err(_)` matches all errors | ||
--> $DIR/match_wild_err_arm.rs:23:9 | ||
| | ||
LL | Err(_) => { | ||
| ^^^^^^ | ||
| | ||
= note: match each error separately or use the error output | ||
|
||
error: `Err(_e)` matches all errors | ||
--> $DIR/match_wild_err_arm.rs:31:9 | ||
| | ||
LL | Err(_e) => panic!(), | ||
| ^^^^^^^ | ||
| | ||
= note: match each error separately or use the error output | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.