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#80100 - mark-i-m:pattORns-2, r=petrochenkov
or_patterns: implement :pat edition-specific behavior cc rust-lang#54883 `@joshtriplett` This PR implements the edition-specific behavior of `:pat` wrt or-patterns, as determined by the crater runs and T-lang consensus in rust-lang#54883 (comment). I believe this can unblock stabilization of or_patterns. r? `@petrochenkov`
- Loading branch information
Showing
14 changed files
with
193 additions
and
75 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
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,15 @@ | ||
// run-pass | ||
// edition:2018 | ||
|
||
macro_rules! pat_bar { | ||
($p:pat | $p2:pat) => {{ | ||
match Some(1u8) { | ||
$p | $p2 => {} | ||
_ => {} | ||
} | ||
}}; | ||
} | ||
|
||
fn main() { | ||
pat_bar!(Some(1u8) | None); | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.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,15 @@ | ||
// Test that :pat doesn't accept top-level or-patterns in edition 2018. | ||
|
||
// edition:2018 | ||
|
||
#![feature(or_patterns)] | ||
|
||
fn main() {} | ||
|
||
// Test the `pat` macro fragment parser: | ||
macro_rules! accept_pat { | ||
($p:pat) => {}; | ||
} | ||
|
||
accept_pat!(p | q); //~ ERROR no rules expected the token `|` | ||
accept_pat!(|p| q); //~ ERROR no rules expected the token `|` |
20 changes: 20 additions & 0 deletions
20
src/test/ui/or-patterns/or-patterns-syntactic-fail-2018.stderr
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,20 @@ | ||
error: no rules expected the token `|` | ||
--> $DIR/or-patterns-syntactic-fail-2018.rs:14:15 | ||
| | ||
LL | macro_rules! accept_pat { | ||
| ----------------------- when calling this macro | ||
... | ||
LL | accept_pat!(p | q); | ||
| ^ no rules expected this token in macro call | ||
|
||
error: no rules expected the token `|` | ||
--> $DIR/or-patterns-syntactic-fail-2018.rs:15:13 | ||
| | ||
LL | macro_rules! accept_pat { | ||
| ----------------------- when calling this macro | ||
... | ||
LL | accept_pat!(|p| q); | ||
| ^ no rules expected this token in macro call | ||
|
||
error: aborting due to 2 previous errors | ||
|
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.