Skip to content

Commit 82bf341

Browse files
committed
Auto merge of #100538 - Nilstrieb:revert-let-chains-beta, r=compiler-errors
Revert let_chains stabilization This reverts commit 3266460. It was discovered in #100513 that they are not implemented correctly, which does not make them ready for stabilization. The merge in the let parsing had a few conflicts, cc `@compiler-errors` and `@c410-f3r` to make sure I did it correctly (alternatively I could also revert `@compiler-errors'` let diagnostic improvement PR as well if a simpler revert is desired). r? `@Mark-Simulacrum`
2 parents fb2194a + 11a367a commit 82bf341

File tree

60 files changed

+789
-439
lines changed

Some content is hidden

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

60 files changed

+789
-439
lines changed

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#![feature(const_trait_impl)]
1515
#![feature(if_let_guard)]
1616
#![feature(label_break_value)]
17-
#![cfg_attr(bootstrap, feature(let_chains))]
17+
#![feature(let_chains)]
1818
#![feature(min_specialization)]
1919
#![feature(negative_impls)]
2020
#![feature(slice_internals)]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//! in the HIR, especially for multiple identifiers.
3232
3333
#![feature(box_patterns)]
34-
#![cfg_attr(bootstrap, feature(let_chains))]
34+
#![feature(let_chains)]
3535
#![feature(let_else)]
3636
#![feature(never_type)]
3737
#![recursion_limit = "256"]

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +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-
let err = "`let` expressions are not supported here";
123-
let mut diag = self.session.struct_span_err(expr.span, err);
124-
diag.note("only supported directly in conditions of `if` and `while` expressions");
125-
match forbidden_let_reason {
126-
ForbiddenLetReason::GenericForbidden => {}
127-
ForbiddenLetReason::NotSupportedOr(span) => {
128-
diag.span_note(span, "`||` operators are not supported in let chain expressions");
129-
}
130-
ForbiddenLetReason::NotSupportedParentheses(span) => {
131-
diag.span_note(
132-
span,
133-
"`let`s wrapped in parentheses are not supported in a context with let \
134-
chains",
135-
);
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+
}
136142
}
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();
137148
}
138-
diag.emit();
139149
}
140150

141151
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
@@ -766,6 +766,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
766766
"`if let` guards are experimental",
767767
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
768768
);
769+
gate_all!(let_chains, "`let` expressions in this position are unstable");
769770
gate_all!(
770771
async_closure,
771772
"async closures are unstable",

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![feature(box_patterns)]
99
#![feature(if_let_guard)]
1010
#![feature(iter_is_partitioned)]
11-
#![cfg_attr(bootstrap, feature(let_chains))]
11+
#![feature(let_chains)]
1212
#![feature(let_else)]
1313
#![recursion_limit = "256"]
1414

compiler/rustc_attr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +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-
#![cfg_attr(bootstrap, feature(let_chains))]
7+
#![feature(let_chains)]
88
#![feature(let_else)]
99

1010
#[macro_use]

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![allow(rustc::potential_query_instability)]
44
#![feature(box_patterns)]
5-
#![cfg_attr(bootstrap, feature(let_chains))]
5+
#![feature(let_chains)]
66
#![feature(let_else)]
77
#![feature(min_specialization)]
88
#![feature(never_type)]

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![feature(decl_macro)]
99
#![feature(if_let_guard)]
1010
#![feature(is_sorted)]
11-
#![cfg_attr(bootstrap, feature(let_chains))]
11+
#![feature(let_chains)]
1212
#![feature(let_else)]
1313
#![feature(proc_macro_internals)]
1414
#![feature(proc_macro_quote)]

compiler/rustc_codegen_llvm/src/lib.rs

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

compiler/rustc_const_eval/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +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-
#![cfg_attr(bootstrap, feature(let_chains))]
12+
#![feature(let_chains)]
1313
#![feature(let_else)]
1414
#![feature(map_try_insert)]
1515
#![feature(min_specialization)]

0 commit comments

Comments
 (0)