Skip to content

Commit bca3cf7

Browse files
committed
Stabilize the let_else feature
1 parent 35a0407 commit bca3cf7

File tree

6 files changed

+10
-32
lines changed

6 files changed

+10
-32
lines changed

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext};
22
use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind};
33
use rustc_hir as hir;
4-
use rustc_session::parse::feature_err;
5-
use rustc_span::sym;
64

75
use smallvec::SmallVec;
86

@@ -91,15 +89,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
9189
let hir_id = self.lower_node_id(l.id);
9290
let pat = self.lower_pat(&l.pat);
9391
let els = if let LocalKind::InitElse(_, els) = &l.kind {
94-
if !self.tcx.features().let_else {
95-
feature_err(
96-
&self.tcx.sess.parse_sess,
97-
sym::let_else,
98-
l.span,
99-
"`let...else` statements are unstable",
100-
)
101-
.emit();
102-
}
10392
Some(self.lower_block(els, false))
10493
} else {
10594
None

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ declare_features! (
190190
(accepted, item_like_imports, "1.15.0", Some(35120), None),
191191
/// Allows `'a: { break 'a; }`.
192192
(accepted, label_break_value, "CURRENT_RUSTC_VERSION", Some(48594), None),
193+
/// Allows `let...else` statements.
194+
(accepted, let_else, "CURRENT_RUSTC_VERSION", Some(87335), None),
193195
/// Allows `break {expr}` with a value inside `loop`s.
194196
(accepted, loop_break_value, "1.19.0", Some(37339), None),
195197
/// Allows use of `?` as the Kleene "at most one" operator in macros.

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ declare_features! (
430430
(active, large_assignments, "1.52.0", Some(83518), None),
431431
/// Allows `if/while p && let q = r && ...` chains.
432432
(active, let_chains, "1.37.0", Some(53667), None),
433-
/// Allows `let...else` statements.
434-
(active, let_else, "1.56.0", Some(87335), None),
435433
/// Allows `#[link(..., cfg(..))]`.
436434
(active, link_cfg, "1.14.0", Some(37406), None),
437435
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.

src/test/ui/feature-gates/feature-gate-let_else.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/test/ui/feature-gates/feature-gate-let_else.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/test/ui/let-else/let-else.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// run-pass
2+
3+
fn main() {
4+
let Some(x) = Some(1) else {
5+
return;
6+
};
7+
assert_eq!(x, 1);
8+
}

0 commit comments

Comments
 (0)