about summary refs log tree commit diff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2022-08-30 14:46:35 +0200
committerest31 <MTest31@outlook.com>2022-09-15 21:06:45 +0200
commitbca3cf7e86b522f58d9a60b4d1c29a34f9483e7e (patch)
treea7c1ad5585f5311b225e2f5d943d243c0a942c56
parent35a0407814a6b5a04f0929105631e9c69e293e9d (diff)
downloadrust-bca3cf7e86b522f58d9a60b4d1c29a34f9483e7e.tar.gz
rust-bca3cf7e86b522f58d9a60b4d1c29a34f9483e7e.zip
Stabilize the let_else feature
-rw-r--r--compiler/rustc_ast_lowering/src/block.rs11
-rw-r--r--compiler/rustc_feature/src/accepted.rs2
-rw-r--r--compiler/rustc_feature/src/active.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-let_else.rs5
-rw-r--r--src/test/ui/feature-gates/feature-gate-let_else.stderr14
-rw-r--r--src/test/ui/let-else/let-else.rs8
6 files changed, 10 insertions, 32 deletions
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 <https://github.com/rust-lang/rust/issues/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);
+}