Skip to content

Commit d1ef818

Browse files
committed
Revert let_chains stabilization
This reverts commit 3266460. This is the revert against master, the beta revert was already done in #100538.
1 parent 76eb4f3 commit d1ef818

File tree

59 files changed

+791
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+791
-396
lines changed

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(const_trait_impl)]
1515
#![feature(if_let_guard)]
1616
#![cfg_attr(bootstrap, feature(label_break_value))]
17+
#![feature(let_chains)]
1718
#![feature(min_specialization)]
1819
#![feature(negative_impls)]
1920
#![feature(slice_internals)]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
//! in the HIR, especially for multiple identifiers.
3232
3333
#![feature(box_patterns)]
34+
#![feature(let_chains)]
3435
#![feature(let_else)]
3536
#![feature(never_type)]
3637
#![recursion_limit = "256"]

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,33 @@ impl<'a> AstValidator<'a> {
119119

120120
/// Emits an error banning the `let` expression provided in the given location.
121121
fn ban_let_expr(&self, expr: &'a Expr, forbidden_let_reason: ForbiddenLetReason) {
122-
self.session.emit_err(ForbiddenLet { span: expr.span, reason: forbidden_let_reason });
122+
let sess = &self.session;
123+
if sess.opts.unstable_features.is_nightly_build() {
124+
let err = "`let` expressions are not supported here";
125+
let mut diag = sess.struct_span_err(expr.span, err);
126+
diag.note("only supported directly in conditions of `if` and `while` expressions");
127+
match forbidden_let_reason {
128+
ForbiddenLetReason::GenericForbidden => {}
129+
ForbiddenLetReason::NotSupportedOr(span) => {
130+
diag.span_note(
131+
span,
132+
"`||` operators are not supported in let chain expressions",
133+
);
134+
}
135+
ForbiddenLetReason::NotSupportedParentheses(span) => {
136+
diag.span_note(
137+
span,
138+
"`let`s wrapped in parentheses are not supported in a context with let \
139+
chains",
140+
);
141+
}
142+
}
143+
diag.emit();
144+
} else {
145+
sess.struct_span_err(expr.span, "expected expression, found statement (`let`)")
146+
.note("variable declaration using `let` is a statement")
147+
.emit();
148+
}
123149
}
124150

125151
fn check_gat_where(

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
777777
"`if let` guards are experimental",
778778
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
779779
);
780+
gate_all!(let_chains, "`let` expressions in this position are unstable");
780781
gate_all!(
781782
async_closure,
782783
"async closures are unstable",

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(box_patterns)]
99
#![feature(if_let_guard)]
1010
#![feature(iter_is_partitioned)]
11+
#![feature(let_chains)]
1112
#![feature(let_else)]
1213
#![recursion_limit = "256"]
1314

compiler/rustc_attr/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax`
55
//! to this crate.
66
7+
#![feature(let_chains)]
78
#![feature(let_else)]
89
#![deny(rustc::untranslatable_diagnostic)]
910
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![allow(rustc::potential_query_instability)]
44
#![feature(box_patterns)]
5+
#![feature(let_chains)]
56
#![feature(let_else)]
67
#![feature(min_specialization)]
78
#![feature(never_type)]

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(decl_macro)]
99
#![feature(if_let_guard)]
1010
#![feature(is_sorted)]
11+
#![feature(let_chains)]
1112
#![feature(let_else)]
1213
#![feature(proc_macro_internals)]
1314
#![feature(proc_macro_quote)]

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
88
#![feature(hash_raw_entry)]
9+
#![feature(let_chains)]
910
#![feature(let_else)]
1011
#![feature(extern_types)]
1112
#![feature(once_cell)]

compiler/rustc_const_eval/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Rust MIR: a lowered representation of Rust.
99
#![feature(control_flow_enum)]
1010
#![feature(decl_macro)]
1111
#![feature(exact_size_is_empty)]
12+
#![feature(let_chains)]
1213
#![feature(let_else)]
1314
#![feature(map_try_insert)]
1415
#![feature(min_specialization)]

0 commit comments

Comments
 (0)