forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#70413 - AminArria:match-pattern-incorrect-w…
…arning, r=Centril,Nadrieril,varkor Fix incorrect pattern warning "unreachable pattern" Fixes rust-lang#70372 Added `is_under_guard` parameter to `_match::is_useful` and only add it to the matrix if `false` Tested with: ```rust #![feature(or_patterns)] fn main() { match (3,42) { (a,_) | (_,a) if a > 10 => {println!("{}", a)} _ => () } match Some((3,42)) { Some((a, _)) | Some((_, a)) if a > 10 => {println!("{}", a)} _ => () } match Some((3,42)) { Some((a, _) | (_, a)) if a > 10 => {println!("{}", a)} _ => () } } ```
- Loading branch information
Showing
3 changed files
with
63 additions
and
8 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
22 changes: 22 additions & 0 deletions
22
src/test/ui/or-patterns/issue-70413-no-unreachable-pat-and-guard.rs
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,22 @@ | ||
// check-pass | ||
|
||
#![deny(unreachable_patterns)] | ||
|
||
#![feature(or_patterns)] | ||
fn main() { | ||
match (3,42) { | ||
(a,_) | (_,a) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
} | ||
|
||
match Some((3,42)) { | ||
Some((a, _)) | Some((_, a)) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
|
||
} | ||
|
||
match Some((3,42)) { | ||
Some((a, _) | (_, a)) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
} | ||
} |