-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #98200 - ouz-a:issue-98177, r=oli-obk
Expand potential inner `Or` pattern for THIR Code assumed there wouldn't be a deeper `Or` pattern inside expanded `PatStack` this fixes it by looking for the `Or` pattern inside expanded `PatStack`. A more ideal solution would be recursively doing this but I haven't found a good way to do that. _fixes #97898_
- Loading branch information
Showing
4 changed files
with
114 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/inner-or-pat.rs:38:54 | ||
| | ||
LL | match x { | ||
| - this expression has type `&str` | ||
LL | x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) | | ||
| ^^ expected `str`, found `()` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,11 @@ | ||
error[E0408]: variable `x` is not bound in all patterns | ||
--> $DIR/inner-or-pat.rs:53:37 | ||
| | ||
LL | (x @ "red" | (x @ "blue" | "red")) => { | ||
| - ^^^^^ pattern doesn't bind `x` | ||
| | | ||
| variable not in all patterns | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0408`. |
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,73 @@ | ||
// revisions: or1 or2 or3 or4 or5 | ||
// [or1] run-pass | ||
// [or2] run-pass | ||
// [or5] run-pass | ||
|
||
#![allow(unreachable_patterns)] | ||
#![allow(unused_variables)] | ||
#![allow(unused_parens)] | ||
#![allow(dead_code)] | ||
|
||
|
||
|
||
fn foo() { | ||
let x = "foo"; | ||
match x { | ||
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | "no" | "nop") | ("hey" | "gg")) | | ||
x @ ("black" | "pink") | | ||
x @ ("red" | "blue") => { | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
fn bar() { | ||
let x = "foo"; | ||
match x { | ||
x @ ("foo" | "bar") | | ||
(x @ "red" | (x @ "blue" | x @ "red")) => { | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
#[cfg(or3)] | ||
fn zot() { | ||
let x = "foo"; | ||
match x { | ||
x @ ((("h" | "ho" | "yo" | ("dude" | "w")) | () | "nop") | ("hey" | "gg")) | | ||
//[or3]~^ ERROR mismatched types | ||
x @ ("black" | "pink") | | ||
x @ ("red" | "blue") => { | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
|
||
#[cfg(or4)] | ||
fn hey() { | ||
let x = "foo"; | ||
match x { | ||
x @ ("foo" | "bar") | | ||
(x @ "red" | (x @ "blue" | "red")) => { | ||
//[or4]~^ variable `x` is not bound in all patterns | ||
} | ||
_ => (), | ||
} | ||
} | ||
|
||
fn don() { | ||
enum Foo { | ||
A, | ||
B, | ||
C, | ||
} | ||
|
||
match Foo::A { | ||
| _foo @ (Foo::A | Foo::B) => {} | ||
Foo::C => {} | ||
}; | ||
} | ||
|
||
fn main(){} |