Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for eRFC 2497, "if- and while-let-chains, take 2" #53667

Open
Centril opened this issue Aug 24, 2018 · 8 comments

Comments

Projects
None yet
7 participants
@Centril
Copy link
Member

commented Aug 24, 2018

This is a tracking issue for the eRFC "if- and while-let-chains, take 2" (rust-lang/rfcs#2497).
For the tracking issue for the immediate edition changes, see #53668.

Steps:

Unresolved questions:

Collected issues:

Implementation history:

@Centril

This comment has been minimized.

Copy link
Member Author

commented Mar 11, 2019

I'm working on implementing this in a 3+ PR step fashion based on discussions with @oli-obk.

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

for the record, the discussed step list is

  1. remove if from HIR and make lowering emit a match
  2. remove if let from AST and instead have a let expression
  3. "do the rest of the work" (might get split up further).
@alexreg

This comment has been minimized.

Copy link
Contributor

commented Mar 11, 2019

I can't imagine 3 would be a particularly large step (enough to merit splitting), but 3 steps sounds fair enough.

bors added a commit that referenced this issue Mar 19, 2019

Auto merge of #59288 - Centril:hir-if-to-match, r=<try>
[WIP] [let_chains, 1/6] Remove hir::ExprKind::If

Per #53667 (comment).

r? @oli-obk

bors added a commit that referenced this issue Apr 5, 2019

Auto merge of #59288 - Centril:hir-if-to-match, r=<try>
[WIP] [let_chains, 1/6] Remove hir::ExprKind::If

Per #53667 (comment).

r? @oli-obk

bors added a commit that referenced this issue Apr 17, 2019

Auto merge of #59288 - Centril:hir-if-to-match, r=<try>
[WIP] [let_chains, 1/6] Remove hir::ExprKind::If

Per #53667 (comment).

r? @oli-obk

bors added a commit that referenced this issue Apr 22, 2019

Auto merge of #59288 - Centril:hir-if-to-match, r=<try>
[WIP] [let_chains, 1/6] Remove hir::ExprKind::If

Per #53667 (comment).

r? @oli-obk

bors added a commit that referenced this issue May 10, 2019

Auto merge of #59288 - Centril:hir-if-to-match, r=oli-obk
[let_chains, 1/6] Remove hir::ExprKind::If

Per #53667 (comment).

r? @oli-obk

bors added a commit that referenced this issue May 15, 2019

Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ do some AST validation
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per #53667 (comment).
Next step after #59288.

cc @Manishearth re. Clippy.

r? @oli-obk

bors added a commit that referenced this issue May 16, 2019

Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ do some AST validation
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per #53667 (comment).
Next step after #59288.

cc @Manishearth re. Clippy.

r? @oli-obk

bors added a commit that referenced this issue May 16, 2019

Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ do some AST validation
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per #53667 (comment).
Next step after #59288.

cc @Manishearth re. Clippy.

r? @oli-obk

bors added a commit that referenced this issue May 19, 2019

Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ do some AST validation
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per #53667 (comment).
Next step after #59288.

cc @Manishearth re. Clippy.

r? @oli-obk
@estk

This comment has been minimized.

Copy link
Contributor

commented May 20, 2019

@Centril I'm really jazzed about this feature, lmk if there is any work I can help with.

@Centril

This comment has been minimized.

Copy link
Member Author

commented May 20, 2019

@estk :) The work is pretty non-parallelizable at the moment; However, once #60861 lands you may want to take a look at #60336.

@Manishearth

This comment has been minimized.

Copy link
Member

commented May 26, 2019

Question worth discussing: This introduces let as something like an expression in the AST.

Do we plan to make it a true expression? As in, will $e:expr match let Pat(..) = foo in macros? This does not mean that it will work everywhere (as @Centril correctly points out, $t:ty matches impl Trait, but it's only allowed in certain positions in the AST), it just means that macros will be able to match on it. They may error further down the pipeline if it gets used outside of an if.

This is technically a breaking behavior change; a macro with a fallthrough to let $p:pat = $e:expr will suddenly start behaving differently.

@eddyb

This comment has been minimized.

Copy link
Member

commented May 28, 2019

@Manishearth I thought that you can't probe whether something parses as an AST fragment in macro_rules macros, only tokens (this includes $i:ident, $l:lit, etc.).
That is, I expected the first expr/pat/stmt/block/item/etc. that is reached to be final.
But I'm wrong, and this is either behavior introduced in the past couple years, or I was just confused.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

this is either behavior introduced in the past couple years

This is #42913 if I'm not mistaken, almost 2 years ago.
One token lookahead is used to reject alternatives that "obviously don't fit".

bors added a commit that referenced this issue Jun 23, 2019

Auto merge of #60861 - Centril:let-chains-ast-intro, r=petrochenkov
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains

Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`.
Moreover, we also:
+ connect the parsing logic for let chains
+ introduce the feature gate
+ rewire HIR lowering a bit.

However, this does not connect the new syntax to semantics in HIR.
That will be the subject of a subsequent PR.

Per #53667 (comment).
Next step after #59288.

cc @Manishearth re. Clippy.

r? @oli-obk

bors added a commit that referenced this issue Jul 5, 2019

Auto merge of #61988 - Centril:there-is-only-loop, r=matthewjasper
[let_chains, 3/6] And then there was only Loop

Here we remove `hir::ExprKind::While`.
Instead, we desugar: `'label: while $cond $body` into:

```rust
'label: loop {
    match DropTemps($cond) {
        true => $body,
        _ => break,
    }
}
```

Per #53667 (comment).
This is a follow up to #59288 which did the same for `if` expressions.

r? @matthewjasper

bors added a commit that referenced this issue Jul 6, 2019

Auto merge of #61988 - Centril:there-is-only-loop, r=matthewjasper
[let_chains, 3/6] And then there was only Loop

Here we remove `hir::ExprKind::While`.
Instead, we desugar: `'label: while $cond $body` into:

```rust
'label: loop {
    match DropTemps($cond) {
        true => $body,
        _ => break,
    }
}
```

Per #53667 (comment).
This is a follow up to #59288 which did the same for `if` expressions.

r? @matthewjasper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.