Initial implementation of or-patterns by dlrobertson · Pull Request #61708 · rust-lang/rust (original) (raw)

dlrobertson

An incomplete implementation of or-patterns (e.g. Some(0 | 1) as a pattern). This patch set aims to implement initial parsing of or-patterns.

Related to: #54883

CC @alexreg @varkor
r? @Centril

alexreg, Centril, ljedrz, mark-i-m, jplatte, Aaron1011, taiki-e, ebkalderon, and dnrusakov reacted with thumbs up emoji phansch, Centril, and BatmanAoD reacted with hooray emoji

dlrobertson

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments and critiques on how or-patterns are parsed would be very much appreciated.

PatternKind::AscribeUserType { .. } |
PatternKind::Array { .. } |
PatternKind::Wild |
PatternKind::Binding { .. } |
PatternKind::Leaf { .. } |
PatternKind::Deref { .. } => {
self.error_simplifyable(match_pair)
None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current plan is to lower each "subpattern" here and create the TestKind::Or variant that will contain the TestKind's for the "subpatterns"

Centril

@Centril

@Centril

This comment has been minimized.

petrochenkov

@bors

This comment has been minimized.

Centril

@rust-highfive

This comment has been minimized.

dlrobertson

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some of my WIP work in MIR. I'd appreciate any feedback on the lowering there.

NB: or-patterns that include Wild or Switch currently fail. Range and SwitchInt seem to work though.

// can let the test create its blocks before the rest of the match.
// This currently improves the speed of llvm when optimizing long
// string literal matches
trait TargetBlockBuilder<'tcx> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What used to be the make_target_blocks closure is now implemented in the impl of the TargetBlockBuilder trait. This is needed so that we can build out the target blocks based on the or-pattern's subtests.

@matthewjasper does this seem like a reasonable approach?

@rust-highfive

This comment has been minimized.

matthewjasper

alexreg

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@varkor

This comment has been minimized.

@Centril

r=me with comments ^-- addressed for the parser changes and varkor on the rest since that didn't change.

@varkor @dlrobertson

@dlrobertson

Initial implementation of parsing or-patterns e.g., Some(Foo | Bar). This is a partial implementation of RFC 2535.

@dlrobertson

@bors

📌 Commit 1870537 has been approved by centril

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Aug 17, 2019

@bors

bors added a commit that referenced this pull request

Aug 18, 2019

@bors

Initial implementation of or-patterns

An incomplete implementation of or-patterns (e.g. Some(0 | 1) as a pattern). This patch set aims to implement initial parsing of or-patterns.

Related to: #54883

CC @alexreg @varkor r? @Centril

@bors

bors added a commit to rust-lang/rust-clippy that referenced this pull request

Aug 18, 2019

@bors

Centril added a commit to Centril/rust that referenced this pull request

Aug 26, 2019

@Centril

…ebank

Fully implement or-pattern parsing

Builds upon the initial parsing in rust-lang#61708 to fully implement or-pattern (p | q) parsing as specified in the grammar section of RFC 2535.

Noteworthy:

cc @dlrobertson cc the tracking issue rust-lang#54883.

r? @estebank

Centril added a commit to Centril/rust that referenced this pull request

Sep 5, 2019

@Centril

…ochenkov

or-patterns: Uniformly use PatKind::Or in AST & Fix/Cleanup resolve

Following up on work in rust-lang#63693 and rust-lang#61708, in this PR we:

cc rust-lang#54883 cc @dlrobertson @matthewjasper r? @petrochenkov

Centril added a commit to Centril/rust that referenced this pull request

Sep 5, 2019

@Centril

…ochenkov

or-patterns: Uniformly use PatKind::Or in AST & Fix/Cleanup resolve

Following up on work in rust-lang#63693 and rust-lang#61708, in this PR we:

cc rust-lang#54883 cc @dlrobertson @matthewjasper r? @petrochenkov

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request

Sep 6, 2019

@Mark-Simulacrum

…ochenkov

or-patterns: Uniformly use PatKind::Or in AST & Fix/Cleanup resolve

Following up on work in rust-lang#63693 and rust-lang#61708, in this PR we:

cc rust-lang#54883 cc @dlrobertson @matthewjasper r? @petrochenkov

Centril added a commit to Centril/rust that referenced this pull request

Sep 6, 2019

@Centril

…ochenkov

or-patterns: Uniformly use PatKind::Or in AST & Fix/Cleanup resolve

Following up on work in rust-lang#63693 and rust-lang#61708, in this PR we:

cc rust-lang#54883 cc @dlrobertson @matthewjasper r? @petrochenkov

Centril added a commit to Centril/rust that referenced this pull request

Sep 22, 2019

@Centril

or-patterns: Push PatKind/PatternKind::Or at top level to HIR & HAIR

Following up on work in rust-lang#64111, rust-lang#63693, and rust-lang#61708, in this PR:

r? @matthewjasper cc @dlrobertson @varkor @oli-obk

bors added a commit that referenced this pull request

Sep 23, 2019

@bors

or-patterns: Push PatKind/PatternKind::Or at top level to HIR & HAIR

Following up on work in #64111, #63693, and #61708, in this PR:

r? @matthewjasper cc @dlrobertson @varkor @oli-obk

Centril added a commit to Centril/rust that referenced this pull request

Sep 25, 2019

@Centril

or-patterns: Push PatKind/PatternKind::Or at top level to HIR & HAIR

Following up on work in rust-lang#64111, rust-lang#63693, and rust-lang#61708, in this PR:

r? @matthewjasper cc @dlrobertson @varkor @oli-obk