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#119031 - Nadrieril:two-phase-match-lowering, …
…r=<try> [Experiment] Play with match lowering Match lowering to MIR has the reputation of being the most intricate piece of the compiler, and after banging my head on it for a bit I sure hope there isn't anything more intricate somewhere else. It's good quality code but I hope to unentangle it. This PR is me wrestling with it and asking `rustc-timer` for its opinion. r? `@ghost`
- Loading branch information
Showing
16 changed files
with
373 additions
and
389 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
21 changes: 10 additions & 11 deletions
21
tests/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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
//@ check-pass | ||
//@ run-pass | ||
|
||
#![deny(unreachable_patterns)] | ||
|
||
fn main() { | ||
match (3,42) { | ||
(a,_) | (_,a) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
match (3, 42) { | ||
(a, _) | (_, a) if a > 10 => {} | ||
_ => unreachable!(), | ||
} | ||
|
||
match Some((3,42)) { | ||
Some((a, _)) | Some((_, a)) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
|
||
match Some((3, 42)) { | ||
Some((a, _)) | Some((_, a)) if a > 10 => {} | ||
_ => unreachable!(), | ||
} | ||
|
||
match Some((3,42)) { | ||
Some((a, _) | (_, a)) if a > 10 => {println!("{}", a)} | ||
_ => () | ||
match Some((3, 42)) { | ||
Some((a, _) | (_, a)) if a > 10 => {} | ||
_ => unreachable!(), | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
tests/ui/pattern/usefulness/integer-ranges/regression-switchint-sorting-with-ranges.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,14 @@ | ||
//@ run-pass | ||
// | ||
// Regression test for match lowering to MIR: when gathering candidates, by the time we get to the | ||
// range we know the range will only match on the failure case of the switchint. Hence we mustn't | ||
// add the `1` to the switchint or the range would be incorrectly sorted. | ||
#![allow(unreachable_patterns)] | ||
fn main() { | ||
match 1 { | ||
10 => unreachable!(), | ||
0..=5 => {} | ||
1 => unreachable!(), | ||
_ => unreachable!(), | ||
} | ||
} |