Stabilize the let_else feature
This commit is contained in:
parent
35a0407814
commit
bca3cf7e86
6 changed files with 10 additions and 32 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
fn main() {
|
||||
let Some(x) = Some(1) else { //~ ERROR `let...else` statements are unstable
|
||||
return;
|
||||
};
|
||||
}
|
|
@ -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`.
|
8
src/test/ui/let-else/let-else.rs
Normal file
8
src/test/ui/let-else/let-else.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// run-pass
|
||||
|
||||
fn main() {
|
||||
let Some(x) = Some(1) else {
|
||||
return;
|
||||
};
|
||||
assert_eq!(x, 1);
|
||||
}
|
Loading…
Add table
Reference in a new issue