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
9 of 15 tasks
Tracked by #1568
Centril opened this issue Aug 24, 2018 · 70 comments · Fixed by #94927
Open
9 of 15 tasks
Tracked by #1568

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

Centril opened this issue Aug 24, 2018 · 70 comments · Fixed by #94927
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-let_chains `#![feature(let_chains)]` S-tracking-ready-to-stabilize Status: This is ready to stabilize; it may need a stabilization report and a PR T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril 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:

Unresolved problems

  • Can we be confident that the implementation is correct and well tested?
@Centril Centril added B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. T-lang Relevant to the language team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Aug 24, 2018
@Centril Centril self-assigned this Mar 11, 2019
@Centril
Copy link
Contributor Author

Centril commented Mar 11, 2019

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

@oli-obk
Copy link
Contributor

oli-obk 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
Copy link
Contributor

alexreg 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 Apr 17, 2019
[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
[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
[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
[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
[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
Copy link
Contributor

estk commented May 20, 2019

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

@sammysheep
Copy link

Nightly user here. My experience with this feature has been very good. I'm surprised with how concisely I can convey my intent.

I find I tend to use chains with 3 clauses for some reason, and the succinct transitive nature of it feels elegant.

10/10. Would recommend!

@Noratrieb
Copy link
Member

Noratrieb commented Mar 9, 2024

@joshtriplett has opened rust-lang/rfcs#3573 and it is not clear whether it makes sense to have both features (I personally don't think so).
If it was decided that this should be stabilized (either because the RFC is rejected or because the lang team would like to have both), then it would need someone familiar with the let chains implementation to confirm that they are confident the implementation is correct now.

@est31
Copy link
Member

est31 commented Mar 10, 2024

Yeah before we stabilize this we should in any case wait for the decision on that RFC, which in this instance can turn in any direction.

@roylaurie
Copy link

Yeah before we stabilize this we should in any case wait for the decision on that RFC, which in this instance can turn in any direction.

I think this should keep moving forward. Why trash all of this work unless the other RFC actually gets accepted?

The other idea has already been shot down before. The recent sentiment I've seen on Reddit and in the comments on Github don't paint a picture of anything changing in that regard.

@jpmckinney
Copy link

I also say keep moving forward. In terms of governance, I don’t think it makes sense to pause work on one RFC anytime another RFC suggests an alternative. That’ll just stall everything. (Also, that other RFC will not pause for this one.)

jmqd added a commit to jmqd/simul that referenced this issue Mar 22, 2024
I expect more arms to be added here later, but for the time being, let's
address the clippy complaint and swap this to an if let. It would be
nice if we could chain these ifs, it's not stabilized yet:
rust-lang/rust#53667
@TennyZhuang
Copy link
Contributor

TennyZhuang commented Apr 1, 2024

I do not think rust-lang/rfcs#3573 should block this RFC. is operator is an alternative to the existing feature if let, but not let-chains. The motivation of the new is operator is better readability from a left-to-right style, which means that it should also replace existing if let Some(x) = y to if y is Some(x). Regardless of whether the is operator is a more reasonable expression, we cannot remove the existing if let style, so extending it is still meaningful.

@CEbbinghaus
Copy link

After reading rust-lang/rfcs#3573 I actually disagree with @TennyZhuang. The two features stand in opposition to one another as they both offer the same functionality. However the is operator is significantly more flexible and consistent due to it returning a boolean which lets it fit anywhere a boolean can. Currently the only thing that cannot be achieved any other way is chaining pattern matching which this RFC addresses. As such if this RFC makes it to stable then there is 0 functional reason to add is, only ergonomic reasons (which already has a vocal opposition).

@Noratrieb
Copy link
Member

Noratrieb commented Apr 30, 2024

Please remember that tracking issues are not for discussion, but for updates, especially large ones like this one. Please open a new issue/Zulip/internals.rust-lang.org thread (that can be linked from here) to discuss the feature, so that people subscribed to the issue don't get spammed and the issue history remains readable.
I want to avoid locking the issue so that people can post links to discussion.

@traviscross
Copy link
Contributor

We talked about this in the lang planning meeting today. As far as we know, the blockers and semi-blockers to this have been resolved. E.g.:

At this point, we would encourage someone to write up a comprehensive stabilization report and include that in a PR proposing let-chains for stabilization. We're looking forward to considering that proposal.

@est31
Copy link
Member

est31 commented Nov 7, 2024

This is really wonderful news, @traviscross! I've went over the original stabilization PR (now reverted) and related issues to refresh my memory. I've found two possible stabilization blockers that I have opened zulip threads about.

As there is many people subscribed, please try to keep replies in the linked zulip threads.

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 10, 2024
…compiler-errors

Additional tests to ensure let is rejected during parsing

In the original stabilization PR, @ `compiler-errors` has [pointed out](rust-lang#94927 (comment)) that rust-lang#97295 wasn't enough to address the concerns about having `let` in expressions being rejected at parsing time, instead of later.

Thankfully, since then the situation has been greatly improved by rust-lang#115677. This PR adds some additional tests to `disallowed-positions.rs`, and adds two additional revisions to the "normal" case which is now given the `feature` name:

* `no_feature`: Added to incorporate `disallowed-positions-without-feature-gate.rs` into the file, reducing duplication.
* `nothing`: like feature, but all functions are cfg'd out. Ensures that the errors are really emitted during parsing.

cc tracking issue rust-lang#53667
@est31
Copy link
Member

est31 commented Nov 10, 2024

Stabilization report/PR: #132833

rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 10, 2024
Rollup merge of rust-lang#132828 - est31:let_chains_parsing_tests, r=compiler-errors

Additional tests to ensure let is rejected during parsing

In the original stabilization PR, @ `compiler-errors` has [pointed out](rust-lang#94927 (comment)) that rust-lang#97295 wasn't enough to address the concerns about having `let` in expressions being rejected at parsing time, instead of later.

Thankfully, since then the situation has been greatly improved by rust-lang#115677. This PR adds some additional tests to `disallowed-positions.rs`, and adds two additional revisions to the "normal" case which is now given the `feature` name:

* `no_feature`: Added to incorporate `disallowed-positions-without-feature-gate.rs` into the file, reducing duplication.
* `nothing`: like feature, but all functions are cfg'd out. Ensures that the errors are really emitted during parsing.

cc tracking issue rust-lang#53667
mati865 pushed a commit to mati865/rust that referenced this issue Nov 12, 2024
…compiler-errors

Additional tests to ensure let is rejected during parsing

In the original stabilization PR, @ `compiler-errors` has [pointed out](rust-lang#94927 (comment)) that rust-lang#97295 wasn't enough to address the concerns about having `let` in expressions being rejected at parsing time, instead of later.

Thankfully, since then the situation has been greatly improved by rust-lang#115677. This PR adds some additional tests to `disallowed-positions.rs`, and adds two additional revisions to the "normal" case which is now given the `feature` name:

* `no_feature`: Added to incorporate `disallowed-positions-without-feature-gate.rs` into the file, reducing duplication.
* `nothing`: like feature, but all functions are cfg'd out. Ensures that the errors are really emitted during parsing.

cc tracking issue rust-lang#53667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-let_chains `#![feature(let_chains)]` S-tracking-ready-to-stabilize Status: This is ready to stabilize; it may need a stabilization report and a PR T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.