Skip to content

Commit 353d018

Browse files
authored
Rollup merge of rust-lang#94927 - c410-f3r:stabilize-let-chains, r=joshtriplett
Stabilize `let_chains` in Rust 1.64 # Stabilization proposal This PR proposes the stabilization of `#![feature(let_chains)]` in a future-compatibility way that will allow the **possible** addition of the `EXPR is PAT` syntax. Tracking issue: rust-lang#53667 Version: 1.64 (beta => 2022-08-11, stable => 2022-10-22). ## What is stabilized The ability to chain let expressions along side local variable declarations or ordinary conditional expressions. For example: ```rust pub enum Color { Blue, Red, Violet, } pub enum Flower { Rose, Tulip, Violet, } pub fn roses_are_red_violets_are_blue_printer( (first_flower, first_flower_color): (Flower, Color), (second_flower, second_flower_color): (Flower, Color), pick_up_lines: &[&str], ) { if let Flower::Rose = first_flower && let Color::Red = first_flower_color && let Flower::Violet = second_flower && let Color::Blue = second_flower_color && let &[first_pick_up_line, ..] = pick_up_lines { println!("Roses are red, violets are blue, {}", first_pick_up_line); } } fn main() { roses_are_red_violets_are_blue_printer( (Flower::Rose, Color::Red), (Flower::Violet, Color::Blue), &["sugar is sweet and so are you"], ); } ``` ## Motivation The main motivation for this feature is improving readability, ergonomics and reducing paper cuts. For more examples, see the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md). ## What isn't stabilized * Let chains in match guards (`if_let_guard`) * Resolution of divergent non-terminal matchers * The `EXPR is PAT` syntax ## History * On 2017-12-24, [RFC: if- and while-let-chains](rust-lang/rfcs#2260) * On 2018-07-12, [eRFC: if- and while-let-chains, take 2](rust-lang/rfcs#2497) * On 2018-08-24, [Tracking issue for eRFC 2497, "if- and while-let-chains, take 2](rust-lang#53667) * On 2019-03-19, [Run branch cleanup after copy prop](rust-lang#59290) * On 2019-03-26, [Generalize diagnostic for x = y where bool is the expected type](rust-lang#59439) * On 2019-04-24, [Introduce hir::ExprKind::Use and employ in for loop desugaring](rust-lang#60225) * On 2019-03-19, [[let_chains, 1/6] Remove hir::ExprKind::If](rust-lang#59288) * On 2019-05-15, [[let_chains, 2/6] Introduce Let(..) in AST, remove IfLet + WhileLet and parse let chains](rust-lang#60861) * On 2019-06-20, [[let_chains, 3/6] And then there was only Loop](rust-lang#61988) * On 2020-11-22, [Reintroduce hir::ExprKind::If](rust-lang#79328) * On 2020-12-24, [Introduce hir::ExprKind::Let - Take 2](rust-lang#80357) * On 2021-02-19, [Lower condition of if expression before it's "then" block](rust-lang#82308) * On 2021-09-01, [Fix drop handling for `if let` expressions](rust-lang#88572) * On 2021-09-04, [Formally implement let chains](rust-lang#88642) * On 2022-01-19, [Add tests to ensure that let_chains works with if_let_guard](rust-lang#93086) * On 2022-01-18, [Introduce `enhanced_binary_op` feature](rust-lang#93049) * On 2022-01-22, [Fix `let_chains` and `if_let_guard` feature flags](rust-lang#93213) * On 2022-02-25, [Initiate the inner usage of `let_chains`](rust-lang#94376) * On 2022-01-28, [[WIP] Introduce ast::StmtKind::LetElse to allow the usage of `let_else` with `let_chains`](rust-lang#93437) * On 2022-02-26, [1 - Make more use of `let_chains`](rust-lang#94396) * On 2022-02-26, [2 - Make more use of `let_chains`](rust-lang#94400) * On 2022-02-27, [3 - Make more use of `let_chains`](rust-lang#94420) * On 2022-02-28, [4 - Make more use of `let_chains`](rust-lang#94445) * On 2022-02-28, [5 - Make more use of `let_chains`](rust-lang#94448) * On 2022-02-28, [6 - Make more use of `let_chains`](rust-lang#94465) * On 2022-03-01, [7 - Make more use of `let_chains`](rust-lang#94476) * On 2022-03-01, [8 - Make more use of `let_chains`](rust-lang#94484) * On 2022-03-01, [9 - Make more use of `let_chains`](rust-lang#94498) * On 2022-03-08, [Warn users about `||` in let chain expressions](rust-lang#94754) From the first RFC (2017-12-24) to the theoretical future stabilization day (2022-10-22), it can be said that this feature took 4 years, 9 months and 28 days of research, development, discussions, agreements and headaches to be settled. ## Divergent non-terminal matchers More specifically, rust-lang#86730. ```rust macro_rules! mac { ($e:expr) => { if $e { true } else { false } }; } fn main() { // OK! assert_eq!(mac!(true && let 1 = 1), true); // ERROR! Anything starting with `let` is not considered an expression assert_eq!(mac!(let 1 = 1 && true), true); } ``` To the best of my knowledge, such error or divergence is orthogonal, does not prevent stabilization and can be tackled independently in the near future or effectively in the next Rust 2024 edition. If not, then https://github.com/c410-f3r/rust/tree/let-macro-blah contains a set of changes that will consider `let` an expression. It is possible that none of the solutions above satisfies all applicable constraints but I personally don't know of any other plausible answers. ## Alternative syntax Taking into account the usefulness of this feature and the overwhelming desire to use both now and in the past, `let PAT = EXPR` will be utilized for stabilization but it doesn't or shall create any obstacle for a **possible** future addition of `EXPR is PAT`. The introductory snippet would then be written as the following. ```rust if first_flower is Flower::Rose && first_flower_color is Color::Red && second_flower is Flower::Violet && second_flower_color is Color::Blue && pick_up_lines is &[first_pick_up_line, ..] { println!("Roses are red, violets are blue, {}", first_pick_up_line); } ``` Just to reinforce, this PR only unblocks a **possible** future road for `EXPR is PAT` and does emphasize what is better or what is worse. ## Tests * [Verifies the drop order of let chains and ensures it won't change in the future in an unpredictable way](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir/mir_let_chains_drop_order.rs) * [AST lowering does not wrap let chains in an `DropTemps` expression](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs) * [Checks pretty printing output](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.rs) * [Verifies uninitialized variables due to MIR modifications](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/chains-without-let.rs) * [A collection of statements where `let` expressions are forbidden](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs) * [All or at least most of the places where let chains are allowed](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/feature-gate.rs) * [Ensures that irrefutable lets are allowed in let chains](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/irrefutable-lets.rs) * [issue-88498.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/issue-88498.rs), [issue-90722.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/issue-90722.rs), [issue-92145.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/issue-92145.rs) and [issue-93150.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/issue-93150.rs) were bugs found by third parties and fixed overtime. * [Indexing was triggering a ICE due to a wrongly constructed MIR graph](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/no-double-assigments.rs) * [Protects the precedence of `&&` in relation to other things](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/protect-precedences.rs) * [`let_chains`, as well as `if_let_guard`, has a valid MIR graph that evaluates conditional expressions correctly](https://github.com/rust-lang/rust/blob/master/src/test/ui/rfc-2497-if-let-chains/then-else-blocks.rs) Most of the infra-structure used by let chains is also used by `if` expressions in stable compiler versions since rust-lang#80357 and rust-lang#88572. As a result, no bugs were found since the integration of rust-lang#88642. ## Possible future work * Let chains in match guards is implemented and working but stabilization is blocked by `if_let_guard`. * The usage of `let_chains` with `let_else` is possible but not implemented. Regardless, one attempt was introduced and closed in rust-lang#93437. Thanks `@Centril` for creating the RFC and huge thanks (again) to `@matthewjasper` for all the reviews, mentoring and MIR implementations. Fixes rust-lang#53667
2 parents db41351 + 3266460 commit 353d018

File tree

58 files changed

+426
-777
lines changed

Some content is hidden

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

58 files changed

+426
-777
lines changed

compiler/rustc_ast/src/lib.rs

+1-1
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-
#![feature(let_chains)]
17+
#![cfg_attr(bootstrap, feature(let_chains))]
1818
#![feature(min_specialization)]
1919
#![feature(negative_impls)]
2020
#![feature(slice_internals)]

compiler/rustc_ast_lowering/src/lib.rs

+1-1
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-
#![feature(let_chains)]
34+
#![cfg_attr(bootstrap, feature(let_chains))]
3535
#![feature(let_else)]
3636
#![feature(never_type)]
3737
#![recursion_limit = "256"]

compiler/rustc_ast_passes/src/ast_validation.rs

+15-25
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,23 @@ 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 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-
}
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+
);
142136
}
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();
148137
}
138+
diag.emit();
149139
}
150140

151141
fn check_gat_where(

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
738738
"`if let` guards are experimental",
739739
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
740740
);
741-
gate_all!(let_chains, "`let` expressions in this position are unstable");
742741
gate_all!(
743742
async_closure,
744743
"async closures are unstable",

compiler/rustc_ast_passes/src/lib.rs

+1-1
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-
#![feature(let_chains)]
11+
#![cfg_attr(bootstrap, feature(let_chains))]
1212
#![feature(let_else)]
1313
#![recursion_limit = "256"]
1414

compiler/rustc_attr/src/lib.rs

+1-1
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-
#![feature(let_chains)]
7+
#![cfg_attr(bootstrap, feature(let_chains))]
88
#![feature(let_else)]
99

1010
#[macro_use]

compiler/rustc_borrowck/src/lib.rs

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

compiler/rustc_builtin_macros/src/lib.rs

+1-1
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-
#![feature(let_chains)]
11+
#![cfg_attr(bootstrap, feature(let_chains))]
1212
#![feature(let_else)]
1313
#![feature(proc_macro_internals)]
1414
#![feature(proc_macro_quote)]

compiler/rustc_codegen_llvm/src/lib.rs

+1-1
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-
#![feature(let_chains)]
9+
#![cfg_attr(bootstrap, feature(let_chains))]
1010
#![feature(let_else)]
1111
#![feature(extern_types)]
1212
#![feature(once_cell)]

compiler/rustc_const_eval/src/lib.rs

+1-1
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-
#![feature(let_chains)]
12+
#![cfg_attr(bootstrap, feature(let_chains))]
1313
#![feature(let_else)]
1414
#![feature(map_try_insert)]
1515
#![feature(min_specialization)]

compiler/rustc_error_messages/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(let_chains)]
1+
#![cfg_attr(bootstrap, feature(let_chains))]
22
#![feature(once_cell)]
33
#![feature(rustc_attrs)]
44
#![feature(type_alias_impl_trait)]

compiler/rustc_expand/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(associated_type_bounds)]
44
#![feature(associated_type_defaults)]
55
#![feature(if_let_guard)]
6-
#![feature(let_chains)]
6+
#![cfg_attr(bootstrap, feature(let_chains))]
77
#![feature(let_else)]
88
#![feature(macro_metavar_expr)]
99
#![feature(proc_macro_diagnostic)]

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ declare_features! (
186186
/// Allows some increased flexibility in the name resolution rules,
187187
/// especially around globs and shadowing (RFC 1560).
188188
(accepted, item_like_imports, "1.15.0", Some(35120), None),
189+
/// Allows `if/while p && let q = r && ...` chains.
190+
(accepted, let_chains, "1.64.0", Some(53667), None),
189191
/// Allows `break {expr}` with a value inside `loop`s.
190192
(accepted, loop_break_value, "1.19.0", Some(37339), None),
191193
/// Allows use of `?` as the Kleene "at most one" operator in macros.

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,6 @@ declare_features! (
424424
(active, label_break_value, "1.28.0", Some(48594), None),
425425
// Allows setting the threshold for the `large_assignments` lint.
426426
(active, large_assignments, "1.52.0", Some(83518), None),
427-
/// Allows `if/while p && let q = r && ...` chains.
428-
(active, let_chains, "1.37.0", Some(53667), None),
429427
/// Allows `let...else` statements.
430428
(active, let_else, "1.56.0", Some(87335), None),
431429
/// Allows `#[link(..., cfg(..))]`.

compiler/rustc_infer/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![feature(control_flow_enum)]
1919
#![feature(extend_one)]
2020
#![feature(label_break_value)]
21-
#![feature(let_chains)]
21+
#![cfg_attr(bootstrap, feature(let_chains))]
2222
#![feature(let_else)]
2323
#![feature(min_specialization)]
2424
#![feature(never_type)]

compiler/rustc_lint/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#![feature(if_let_guard)]
3434
#![feature(iter_intersperse)]
3535
#![feature(iter_order_by)]
36-
#![feature(let_chains)]
36+
#![cfg_attr(bootstrap, feature(let_chains))]
3737
#![feature(let_else)]
3838
#![feature(never_type)]
3939
#![recursion_limit = "256"]

compiler/rustc_metadata/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(generators)]
55
#![feature(generic_associated_types)]
66
#![feature(iter_from_generator)]
7-
#![feature(let_chains)]
7+
#![cfg_attr(bootstrap, feature(let_chains))]
88
#![feature(let_else)]
99
#![feature(once_cell)]
1010
#![feature(proc_macro_internals)]

compiler/rustc_middle/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#![feature(extern_types)]
4141
#![feature(new_uninit)]
4242
#![feature(once_cell)]
43-
#![feature(let_chains)]
43+
#![cfg_attr(bootstrap, feature(let_chains))]
4444
#![feature(let_else)]
4545
#![feature(min_specialization)]
4646
#![feature(trusted_len)]

compiler/rustc_mir_build/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![feature(box_patterns)]
66
#![feature(control_flow_enum)]
77
#![feature(if_let_guard)]
8-
#![feature(let_chains)]
8+
#![cfg_attr(bootstrap, feature(let_chains))]
99
#![feature(let_else)]
1010
#![feature(min_specialization)]
1111
#![feature(once_cell)]

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(rustc::potential_query_instability)]
22
#![feature(box_patterns)]
3-
#![feature(let_chains)]
3+
#![cfg_attr(bootstrap, feature(let_chains))]
44
#![feature(let_else)]
55
#![feature(map_try_insert)]
66
#![feature(min_specialization)]

compiler/rustc_parse/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(array_windows)]
44
#![feature(box_patterns)]
55
#![feature(if_let_guard)]
6-
#![feature(let_chains)]
6+
#![cfg_attr(bootstrap, feature(let_chains))]
77
#![feature(let_else)]
88
#![feature(never_type)]
99
#![feature(rustc_attrs)]

compiler/rustc_parse/src/parser/expr.rs

+7-23
Original file line numberDiff line numberDiff line change
@@ -2341,16 +2341,9 @@ impl<'a> Parser<'a> {
23412341

23422342
/// Parses the condition of a `if` or `while` expression.
23432343
fn parse_cond_expr(&mut self) -> PResult<'a, P<Expr>> {
2344-
let cond = self.with_let_management(true, |local_self| {
2344+
self.with_let_management(true, |local_self| {
23452345
local_self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)
2346-
})?;
2347-
2348-
if let ExprKind::Let(..) = cond.kind {
2349-
// Remove the last feature gating of a `let` expression since it's stable.
2350-
self.sess.gated_spans.ungate_last(sym::let_chains, cond.span);
2351-
}
2352-
2353-
Ok(cond)
2346+
})
23542347
}
23552348

23562349
// Checks if `let` is in an invalid position like `let x = let y = 1;` or
@@ -2389,7 +2382,6 @@ impl<'a> Parser<'a> {
23892382
this.parse_assoc_expr_with(1 + prec_let_scrutinee_needs_par(), None.into())
23902383
})?;
23912384
let span = lo.to(expr.span);
2392-
self.sess.gated_spans.gate(sym::let_chains, span);
23932385
Ok(self.mk_expr(span, ExprKind::Let(pat, expr, span), attrs))
23942386
}
23952387

@@ -2695,15 +2687,11 @@ impl<'a> Parser<'a> {
26952687
pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {
26962688
// Used to check the `let_chains` and `if_let_guard` features mostly by scaning
26972689
// `&&` tokens.
2698-
fn check_let_expr(expr: &Expr) -> (bool, bool) {
2690+
fn check_let_expr(expr: &Expr) -> bool {
26992691
match expr.kind {
2700-
ExprKind::Binary(_, ref lhs, ref rhs) => {
2701-
let lhs_rslt = check_let_expr(lhs);
2702-
let rhs_rslt = check_let_expr(rhs);
2703-
(lhs_rslt.0 || rhs_rslt.0, false)
2704-
}
2705-
ExprKind::Let(..) => (true, true),
2706-
_ => (false, true),
2692+
ExprKind::Binary(_, ref lhs, ref rhs) => check_let_expr(lhs) || check_let_expr(rhs),
2693+
ExprKind::Let(..) => true,
2694+
_ => false,
27072695
}
27082696
}
27092697
let attrs = self.parse_outer_attributes()?;
@@ -2718,12 +2706,8 @@ impl<'a> Parser<'a> {
27182706
let guard = if this.eat_keyword(kw::If) {
27192707
let if_span = this.prev_token.span;
27202708
let cond = this.with_let_management(true, |local_this| local_this.parse_expr())?;
2721-
let (has_let_expr, does_not_have_bin_op) = check_let_expr(&cond);
2709+
let has_let_expr = check_let_expr(&cond);
27222710
if has_let_expr {
2723-
if does_not_have_bin_op {
2724-
// Remove the last feature gating of a `let` expression since it's stable.
2725-
this.sess.gated_spans.ungate_last(sym::let_chains, cond.span);
2726-
}
27272711
let span = if_span.to(cond.span);
27282712
this.sess.gated_spans.gate(sym::if_let_guard, span);
27292713
}

compiler/rustc_passes/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#![allow(rustc::potential_query_instability)]
88
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
99
#![feature(iter_intersperse)]
10-
#![feature(let_chains)]
10+
#![cfg_attr(bootstrap, feature(let_chains))]
1111
#![feature(let_else)]
1212
#![feature(map_try_insert)]
1313
#![feature(min_specialization)]

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![feature(box_patterns)]
1111
#![feature(drain_filter)]
1212
#![feature(if_let_guard)]
13-
#![feature(let_chains)]
13+
#![cfg_attr(bootstrap, feature(let_chains))]
1414
#![feature(let_else)]
1515
#![feature(never_type)]
1616
#![recursion_limit = "256"]

compiler/rustc_session/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(if_let_guard)]
2-
#![feature(let_chains)]
2+
#![cfg_attr(bootstrap, feature(let_chains))]
33
#![feature(let_else)]
44
#![feature(min_specialization)]
55
#![feature(never_type)]

compiler/rustc_trait_selection/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![feature(drain_filter)]
1818
#![feature(hash_drain_filter)]
1919
#![feature(label_break_value)]
20-
#![feature(let_chains)]
20+
#![cfg_attr(bootstrap, feature(let_chains))]
2121
#![feature(let_else)]
2222
#![feature(if_let_guard)]
2323
#![feature(never_type)]

compiler/rustc_typeck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This API is completely unstable and subject to change.
6565
#![feature(is_sorted)]
6666
#![feature(iter_intersperse)]
6767
#![feature(label_break_value)]
68-
#![feature(let_chains)]
68+
#![cfg_attr(bootstrap, feature(let_chains))]
6969
#![feature(let_else)]
7070
#![feature(min_specialization)]
7171
#![feature(never_type)]

library/std/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
#![feature(intra_doc_pointers)]
244244
#![feature(label_break_value)]
245245
#![feature(lang_items)]
246-
#![feature(let_chains)]
246+
#![cfg_attr(bootstrap, feature(let_chains))]
247247
#![feature(let_else)]
248248
#![feature(linkage)]
249249
#![feature(min_specialization)]

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#![feature(control_flow_enum)]
1010
#![feature(box_syntax)]
1111
#![feature(drain_filter)]
12-
#![feature(let_chains)]
12+
#![cfg_attr(bootstrap, feature(let_chains))]
1313
#![feature(let_else)]
1414
#![feature(test)]
1515
#![feature(never_type)]

src/test/ui/expr/if/attrs/let-chains-attr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// check-pass
22

3-
#![feature(let_chains)]
4-
53
#[cfg(FALSE)]
64
fn foo() {
75
#[attr]

src/test/ui/expr/if/bad-if-let-suggestion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
fn a() {
55
if let x = 1 && i = 2 {}
66
//~^ ERROR cannot find value `i` in this scope
7-
//~| ERROR `let` expressions in this position are unstable
87
//~| ERROR mismatched types
98
//~| ERROR `let` expressions are not supported here
109
}

0 commit comments

Comments
 (0)