Skip to content

Commit d258e92

Browse files
authored
Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, r=jackh726,pnkfelix
Stabilize `destructuring_assignment` Closes #71126 - [Stabilization report](#71126 (comment)) - [Completed FCP](#71126 (comment)) `@rustbot` label +F-destructuring-assignment +T-lang Also needs +relnotes but I don't have permission to add that tag.
2 parents 195e931 + d95f749 commit d258e92

Some content is hidden

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

49 files changed

+64
-383
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_errors::struct_span_err;
99
use rustc_hir as hir;
1010
use rustc_hir::def::Res;
1111
use rustc_hir::definitions::DefPathData;
12-
use rustc_session::parse::feature_err;
1312
use rustc_span::hygiene::ExpnId;
1413
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
1514
use rustc_span::symbol::{sym, Ident, Symbol};
@@ -962,24 +961,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
962961
self.lower_span(eq_sign_span),
963962
);
964963
}
965-
if !self.sess.features_untracked().destructuring_assignment {
966-
let mut err = feature_err(
967-
&self.sess.parse_sess,
968-
sym::destructuring_assignment,
969-
eq_sign_span,
970-
"destructuring assignments are unstable",
971-
);
972-
err.span_label(lhs.span, "cannot assign to this expression");
973-
if self.is_in_loop_condition {
974-
err.span_suggestion_verbose(
975-
lhs.span.shrink_to_lo(),
976-
"you might have meant to use pattern destructuring",
977-
"let ".to_string(),
978-
rustc_errors::Applicability::MachineApplicable,
979-
);
980-
}
981-
err.emit();
982-
}
983964

984965
let mut assignments = vec![];
985966

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
724724
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
725725
gate_all!(inline_const, "inline-const is experimental");
726726
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
727-
if sess.parse_sess.span_diagnostic.err_count() == 0 {
728-
// Errors for `destructuring_assignment` can get quite noisy, especially where `_` is
729-
// involved, so we only emit errors where there are no other parsing errors.
730-
gate_all!(destructuring_assignment, "destructuring assignments are unstable");
731-
}
732727

733728
// All uses of `gate_all!` below this point were added in #65742,
734729
// and subsequently disabled (with the non-early gating readded).

compiler/rustc_expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(crate_visibility_modifier)]
22
#![feature(decl_macro)]
3-
#![feature(destructuring_assignment)]
3+
#![cfg_attr(bootstrap, feature(destructuring_assignment))]
44
#![feature(if_let_guard)]
55
#![feature(let_else)]
66
#![feature(proc_macro_diagnostic)]

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ declare_features! (
114114
(accepted, default_type_params, "1.0.0", None, None),
115115
/// Allows `#[deprecated]` attribute.
116116
(accepted, deprecated, "1.9.0", Some(29935), None),
117+
/// Allows the use of destructuring assignments.
118+
(accepted, destructuring_assignment, "1.59.0", Some(71126), None),
117119
/// Allows `#[doc(alias = "...")]`.
118120
(accepted, doc_alias, "1.48.0", Some(50146), None),
119121
/// Allows `..` in tuple (struct) patterns.

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ declare_features! (
356356
(active, default_type_parameter_fallback, "1.3.0", Some(27336), None),
357357
/// Allows `#[derive(Default)]` and `#[default]` on enums.
358358
(active, derive_default_enum, "1.56.0", Some(86985), None),
359-
/// Allows the use of destructuring assignments.
360-
(active, destructuring_assignment, "1.49.0", Some(71126), None),
361359
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
362360
(active, doc_auto_cfg, "1.58.0", Some(43781), None),
363361
/// Allows `#[doc(cfg(...))]`.

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,6 @@ impl<'a> Parser<'a> {
12971297
} else if self.eat_keyword(kw::Let) {
12981298
self.parse_let_expr(attrs)
12991299
} else if self.eat_keyword(kw::Underscore) {
1300-
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
13011300
Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore, attrs))
13021301
} else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
13031302
// Don't complain about bare semicolons after unclosed braces
@@ -2620,7 +2619,6 @@ impl<'a> Parser<'a> {
26202619
let exp_span = self.prev_token.span;
26212620
// We permit `.. }` on the left-hand side of a destructuring assignment.
26222621
if self.check(&token::CloseDelim(close_delim)) {
2623-
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
26242622
base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi());
26252623
break;
26262624
}

compiler/rustc_typeck/src/check/expr.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
878878
"let ".to_string(),
879879
Applicability::MachineApplicable,
880880
);
881-
if !self.sess().features_untracked().destructuring_assignment {
882-
// We already emit an E0658 with a suggestion for `while let`, this is
883-
// redundant output.
884-
err.delay_as_bug();
885-
}
886881
break;
887882
}
888883
hir::Node::Item(_)

library/alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
#![feature(cfg_target_has_atomic)]
137137
#![feature(const_fn_trait_bound)]
138138
#![feature(const_trait_impl)]
139-
#![feature(destructuring_assignment)]
139+
#![cfg_attr(bootstrap, feature(destructuring_assignment))]
140140
#![feature(dropck_eyepatch)]
141141
#![feature(exclusive_range_pattern)]
142142
#![feature(fundamental)]

src/test/ui/associated-types/associated-type-destructuring-assignment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// check-pass
22

3-
#![feature(destructuring_assignment)]
43
#![feature(more_qualified_paths)]
54

65
enum E { V() }

src/test/ui/cross/cross-file-errors/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ mod underscore;
44
fn main() {
55
underscore!();
66
//~^ ERROR `_` can only be used on the left-hand side of an assignment
7-
//~| ERROR destructuring assignments are unstable
87
}

0 commit comments

Comments
 (0)