Description
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_chains
in Rust 1.64 #94927, reverted in Revert let_chains stabilization #100538 - Second stabilization PR: Stabilize let chains in the 2024 edition #132833
Unresolved questions:
- The final syntax
- This would benefit from a design note summarizing previous discussions on
let
as a boolean expression, and possibilities ofis
syntax.
- 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 let
s insidematch
arms
Collected issues:
- unused_parens incorrectly lints on
if let true = (false && true) {}
#60336 - Cleanup hack to expect
scrutinee: bool
in 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 let
when a failedif
block could be parsed as one #44990
Implementation history:
- Run branch cleanup after copy prop #59290
- Generalize diagnostic for
x = y
wherebool
is 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
if
expression before it's "then" block #82308 - Formally implement let chains #88642
- Add tests to ensure that
let_chains
works withif_let_guard
#93086 - Fix
let_chains
andif_let_guard
feature flags #93213 - [rustc_parse] Forbid
let
s in certain places #97295 - Warn users about
||
in let chain expressions #94754 - Ensure that
let_else
does not interact withlet_chains
#94974 - [
let_chains
] Forbidlet
inside 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?
Metadata
Metadata
Assignees
Labels
Blocker: Approved by a merged RFC but not yet implemented.Category: An issue tracking the progress of sth. like the implementation of an RFC`#![feature(let_chains)]`Status: This is ready to stabilize; it may need a stabilization report and a PRRelevant to the language team, which will review and decide on the PR/issue.