From bca3cf7e86b522f58d9a60b4d1c29a34f9483e7e Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 30 Aug 2022 14:46:35 +0200 Subject: [PATCH] Stabilize the let_else feature --- compiler/rustc_ast_lowering/src/block.rs | 11 ----------- compiler/rustc_feature/src/accepted.rs | 2 ++ compiler/rustc_feature/src/active.rs | 2 -- src/test/ui/feature-gates/feature-gate-let_else.rs | 5 ----- .../ui/feature-gates/feature-gate-let_else.stderr | 14 -------------- src/test/ui/let-else/let-else.rs | 8 ++++++++ 6 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 src/test/ui/feature-gates/feature-gate-let_else.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-let_else.stderr create mode 100644 src/test/ui/let-else/let-else.rs diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs index 7465706d1a9..8c4878f129c 100644 --- a/compiler/rustc_ast_lowering/src/block.rs +++ b/compiler/rustc_ast_lowering/src/block.rs @@ -1,8 +1,6 @@ use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext}; use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind}; use rustc_hir as hir; -use rustc_session::parse::feature_err; -use rustc_span::sym; use smallvec::SmallVec; @@ -91,15 +89,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let hir_id = self.lower_node_id(l.id); let pat = self.lower_pat(&l.pat); let els = if let LocalKind::InitElse(_, els) = &l.kind { - if !self.tcx.features().let_else { - feature_err( - &self.tcx.sess.parse_sess, - sym::let_else, - l.span, - "`let...else` statements are unstable", - ) - .emit(); - } Some(self.lower_block(els, false)) } else { None diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 100000f4cd6..5f7de94e726 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -190,6 +190,8 @@ declare_features! ( (accepted, item_like_imports, "1.15.0", Some(35120), None), /// Allows `'a: { break 'a; }`. (accepted, label_break_value, "CURRENT_RUSTC_VERSION", Some(48594), None), + /// Allows `let...else` statements. + (accepted, let_else, "CURRENT_RUSTC_VERSION", Some(87335), None), /// Allows `break {expr}` with a value inside `loop`s. (accepted, loop_break_value, "1.19.0", Some(37339), None), /// Allows use of `?` as the Kleene "at most one" operator in macros. diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index c28fa654a6c..ad28595ca82 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -430,8 +430,6 @@ declare_features! ( (active, large_assignments, "1.52.0", Some(83518), None), /// Allows `if/while p && let q = r && ...` chains. (active, let_chains, "1.37.0", Some(53667), None), - /// Allows `let...else` statements. - (active, let_else, "1.56.0", Some(87335), None), /// Allows `#[link(..., cfg(..))]`. (active, link_cfg, "1.14.0", Some(37406), None), /// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check. diff --git a/src/test/ui/feature-gates/feature-gate-let_else.rs b/src/test/ui/feature-gates/feature-gate-let_else.rs deleted file mode 100644 index 3f04a9dabfd..00000000000 --- a/src/test/ui/feature-gates/feature-gate-let_else.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let Some(x) = Some(1) else { //~ ERROR `let...else` statements are unstable - return; - }; -} diff --git a/src/test/ui/feature-gates/feature-gate-let_else.stderr b/src/test/ui/feature-gates/feature-gate-let_else.stderr deleted file mode 100644 index 86252604154..00000000000 --- a/src/test/ui/feature-gates/feature-gate-let_else.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: `let...else` statements are unstable - --> $DIR/feature-gate-let_else.rs:2:5 - | -LL | / let Some(x) = Some(1) else { -LL | | return; -LL | | }; - | |______^ - | - = note: see issue #87335 for more information - = help: add `#![feature(let_else)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/let-else/let-else.rs b/src/test/ui/let-else/let-else.rs new file mode 100644 index 00000000000..3505533e63f --- /dev/null +++ b/src/test/ui/let-else/let-else.rs @@ -0,0 +1,8 @@ +// run-pass + +fn main() { + let Some(x) = Some(1) else { + return; + }; + assert_eq!(x, 1); +}