Repository navigation
Tracking issue for eRFC 2497, "if- and while-let-chains, take 2" #53667
Copy link
Copy link
Labels
A-let-chainsArea: let chains (if-let, while-let, ...)Area: let chains (if-let, while-let, ...)B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-langRelevant to the language teamRelevant to the language team
Description
Note: This feature was stabilized in 1.88.0 but on edition 2024 only. If you are using 1.88.0+ and get an error that the feature is still unstable, please upgrade the edition.
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:
- Implement the RFC (cc @rust-lang/compiler -- can anyone write up mentoring instructions?)
- Adjust documentation (see instructions on forge)
- Formatting for new syntax has been added to the Style Guide (nightly-style-procedure)
- resolve expr fragment specifier issue (#86730)
- Initial stabilization PR: Stabilize
let_chainsin Rust 1.64 #94927, reverted in Revert let_chains stabilization #100538 - Second stabilization PR: Stabilize let chains in the 2024 edition #132833
- followups let_chains stabilization followups #140722
- Remove let_chains unstable feature #143214
Unresolved questions:
- The final syntax
- This would benefit from a design note summarizing previous discussions on
letas a boolean expression, and possibilities ofissyntax.
- This would benefit from a design note summarizing previous discussions on
- Should temporary and irrefutable lets without patterns be allowed in some form?
- Chained
if lets insidematcharms
Collected issues:
- unused_parens incorrectly lints on
if let true = (false && true) {}#60336 - Cleanup hack to expect
scrutinee: boolin if-to-match desugaring in match-expr typeck #60707 - Deduplicate diagnostics in
if-without-else-as-fn-expr.rs#60254 - MIR building for
match $c { true => $i, _ => $e }is slow #60571 - Suggest
if letwhen a failedifblock could be parsed as one #44990
Implementation history:
- Run branch cleanup after copy prop #59290
- Generalize diagnostic for
x = ywhereboolis the expected type #59439 - Introduce hir::ExprKind::Use and employ in for loop desugaring. #60225
- [let_chains, 1/6] Remove hir::ExprKind::If #59288
- [let_chains, 2/6] Introduce
Let(..)in AST, remove IfLet + WhileLet and parse let chains #60861 - [let_chains, 3/6] And then there was only Loop #61988
- Reintroduce hir::ExprKind::If #79328
- Introduce
hir::ExprKind::Let- Take 2 #80357 - Lower condition of
ifexpression before it's "then" block #82308 - Formally implement let chains #88642
- Add tests to ensure that
let_chainsworks withif_let_guard#93086 - Fix
let_chainsandif_let_guardfeature flags #93213 - [rustc_parse] Forbid
lets in certain places #97295 - Warn users about
||in let chain expressions #94754 - Ensure that
let_elsedoes not interact withlet_chains#94974 - [
let_chains] Forbidletinside parentheses #95008 - Tell users that
||operators are not currently supported in let chain expressions #95314
Unresolved problems
- Can we be confident that the implementation is correct and well tested?
Reacted by Joshua Barretto, Matus Talcik, Omer Ozarslan, Matt Russell, Ricky Han, g, Patrik Buhring, Lv9, ljedrz, phrohdoh and 423 more
Reacted by bb010g, Jonathan Moore, Anyere, Felipe S. S. Schneider, Squirrel, Kamil, halvors, astrale-sharp, Andrew, Andrew Ares and 36 more
Reacted by dzmitry-lahoda, Hocuri, Raphael C, Lucas Spits, hurlenko, Simon Wülker, Tanja, Virgiel, rethab, MB and 77 more
Reacted by dzmitry-lahoda, Ivan Temchenko, hurlenko, Henry Boisdequin, Tanja, Virgiel, Marcel Rød, Brooks Townsend, Jakub Beránek, sam0x17 and 62 more
Reacted by Felipe S. S. Schneider, Andrew, Prabhat Pandey, Charles Wang, dzmitry-lahoda, Lv Yitian, Alejandro Osornio, Gus, Shea Newton, henrispriet and 12 more
Metadata
Metadata
Assignees
Labels
A-let-chainsArea: let chains (if-let, while-let, ...)Area: let chains (if-let, while-let, ...)B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-ready-to-stabilizeStatus: This is ready to stabilize; it may need a stabilization report and a PRStatus: This is ready to stabilize; it may need a stabilization report and a PRT-langRelevant to the language teamRelevant to the language team
Activity
Centril commentedon Mar 11, 2019
I'm working on implementing this in a 3+ PR step fashion based on discussions with @oli-obk.
oli-obk commentedon Mar 11, 2019
for the record, the discussed step list is
iffromHIRand make lowering emit amatchif letfromASTand instead have aletexpressionalexreg commentedon Mar 11, 2019
I can't imagine 3 would be a particularly large step (enough to merit splitting), but 3 steps sounds fair enough.
Auto merge of #59288 - Centril:hir-if-to-match, r=<try>
Auto merge of #59288 - Centril:hir-if-to-match, r=oli-obk
Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
Auto merge of #60861 - Centril:let-chains-ast-intro, r=<try>
217 remaining items
🐛 fix: 修复 if-let 链式表达式兼容性问题
🐛 fix: 修复 if-let 链式表达式兼容性问题
Older rustc doesn't support `let_chain`
Migrate `pydantic-core` CI (#12752)
fix: replace let-chain with MSRV 1.87 compatible nested ifs
feat: implement Tier-2 (P1) NPU transpiler features (#124-#128) (#136)
feat: P2 compiler optimization infrastructure (#129-#133) (#137)
fix: bump MSRV to 1.88 (leptonica requires let-chains)
fix: replace unstable let_chains with nested if-let for CI compatibility
Revert let chains stabilization (feature(let_chains) again)
feat(serve): Docker quickstart + env-var config (STROMA_DB / STROMA_A…
Fix MSRV at 1.88.0
Fix MSRV at 1.88.0
upgrade min rust for rust-lang/rust#53667
Fix MSRV at 1.88.0