Skip to content

Tracking issue for RFC #2175: or-patterns in if / while let expressions  #48215

Closed
@aturon

Description

@aturon
Member

This is a tracking issue for the RFC "or-patterns in if / while let expressions" (rust-lang/rfcs#2175).

Steps:

Activity

added
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
T-langRelevant to the language team
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Feb 14, 2018
zackmdavis

zackmdavis commented on Feb 15, 2018

@zackmdavis
Member

This seems likely to be a rather straightforward change: currently parse_arm calls parse_pats to parse the |-separated patterns of a match arm, whereas parse_if_let_expr just calls parse_pat.

I'd like to take this.

zackmdavis

zackmdavis commented on Feb 15, 2018

@zackmdavis
Member

Arguably we should retitle the issue and RFC to make it clear that the ultimately approved proposal actually includes let itself (in addition to if let and while let).

zackmdavis

zackmdavis commented on Feb 15, 2018

@zackmdavis
Member

This seems likely to be a rather straightforward change: currently [...]

Er, this remark was terribly naïve: the change to the parser might be that simple, but then the IfLet (&c.) AST nodes have to hold a vector rather than a single pattern, and much of the code that handles them (e.g., HIR lowering) needs to change correspondingly.

nikomatsakis

nikomatsakis commented on Feb 15, 2018

@nikomatsakis
Contributor

@zackmdavis

Er, this remark was terribly naïve: the change to the parser might be that simple, but then the IfLet (&c.) AST nodes have to hold a vector rather than a single pattern, and much of the code that handles them (e.g., HIR lowering) needs to change correspondingly.

Sounds about right. but it should still be something that can be done purely in HIR lowering, right? I would think so.

zackmdavis

zackmdavis commented on Feb 15, 2018

@zackmdavis
Member

something that can be done purely in HIR lowering, right?

Visitors, pretty-printing, and resolution are also affected.

nikomatsakis

nikomatsakis commented on Feb 15, 2018

@nikomatsakis
Contributor

Sounds about right. I guess what I meant is "after HIR lowering, I wouldn't expect much other code to care"

zackmdavis

zackmdavis commented on Feb 24, 2018

@zackmdavis
Member

(I was actively working on this today, but would seem to have been pre-empted by #48490.)

added a commit that references this issue on Feb 24, 2018

Rollup merge of rust-lang#48490 - petrochenkov:orpat, r=eddyb

9523c82
dtolnay

dtolnay commented on Mar 31, 2018

@dtolnay
Member

Does optional leading vert need to be supported here for consistency with #44101?

if let
    | A(x)
    | B(x) = expr
{
    /* ... */
}

@mdinger

32 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @alexreg@nikomatsakis@aturon@Centril@zackmdavis

      Issue actions

        Tracking issue for RFC #2175: or-patterns in if / while let expressions · Issue #48215 · rust-lang/rust