-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #67668 - matthewjasper:or-patterns, r=<try>
Implement MIR lowering for or-patterns This is the last thing needed to get meaningful run-pass tests for or-patterns. There probably need to be more tests before stabilizing this, but the most important cases should have been covered. Note: we can generate exponentially large MIR CFGs when using or-patterns containing bindings, type ascriptions, or that are for a match arm with a guard. `src/test/mir-opt/exponential-or.rs` shows the best case for what we currently do. cc #54883 closes #60350 closes #67514 cc @Centril r? @pnkfelix
- Loading branch information
Showing
61 changed files
with
1,535 additions
and
836 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Test that simple or-patterns don't get expanded to exponentially large CFGs | ||
|
||
// ignore-tidy-linelength | ||
|
||
#![feature(or_patterns)] | ||
|
||
fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 { | ||
match x { | ||
(y @ (1 | 4), true | false, Some(1 | 8) | None, z @ (6..=9 | 13..=16)) => y + 2 * z, | ||
_ => 0, | ||
} | ||
} | ||
|
||
fn main() {} | ||
|
||
// END RUST SOURCE | ||
|
||
// START rustc.match_tuple.SimplifyCfg-initial.after.mir | ||
// scope 1 { | ||
// debug y => _7; | ||
// debug z => _8; | ||
// } | ||
// bb0: { | ||
// FakeRead(ForMatchedPlace, _1); | ||
// switchInt((_1.0: u32)) -> [1u32: bb2, 4u32: bb2, otherwise: bb1]; | ||
// } | ||
// bb1: { | ||
// _0 = const 0u32; | ||
// goto -> bb10; | ||
// } | ||
// bb2: { | ||
// _2 = discriminant((_1.2: std::option::Option<i32>)); | ||
// switchInt(move _2) -> [0isize: bb4, 1isize: bb3, otherwise: bb1]; | ||
// } | ||
// bb3: { | ||
// switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1i32: bb4, 8i32: bb4, otherwise: bb1]; | ||
// } | ||
// bb4: { | ||
// _5 = Le(const 6u32, (_1.3: u32)); | ||
// switchInt(move _5) -> [false: bb6, otherwise: bb5]; | ||
// } | ||
// bb5: { | ||
// _6 = Le((_1.3: u32), const 9u32); | ||
// switchInt(move _6) -> [false: bb6, otherwise: bb8]; | ||
// } | ||
// bb6: { | ||
// _3 = Le(const 13u32, (_1.3: u32)); | ||
// switchInt(move _3) -> [false: bb1, otherwise: bb7]; | ||
// } | ||
// bb7: { | ||
// _4 = Le((_1.3: u32), const 16u32); | ||
// switchInt(move _4) -> [false: bb1, otherwise: bb8]; | ||
// } | ||
// bb8: { | ||
// falseEdges -> [real: bb9, imaginary: bb1]; | ||
// } | ||
// bb9: { | ||
// StorageLive(_7); | ||
// _7 = (_1.0: u32); | ||
// StorageLive(_8); | ||
// _8 = (_1.3: u32); | ||
// StorageLive(_9); | ||
// _9 = _7; | ||
// StorageLive(_10); | ||
// StorageLive(_11); | ||
// _11 = _8; | ||
// _10 = Mul(const 2u32, move _11); | ||
// StorageDead(_11); | ||
// _0 = Add(move _9, move _10); | ||
// StorageDead(_10); | ||
// StorageDead(_9); | ||
// StorageDead(_8); | ||
// StorageDead(_7); | ||
// goto -> bb10; | ||
// } | ||
// bb10: { | ||
// return; | ||
// } | ||
// END rustc.match_tuple.SimplifyCfg-initial.after.mir |
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
Oops, something went wrong.