Skip to content

Commit a3d1edb

Browse files
committed
Stabilize destructuring_assignment
1 parent 1796de7 commit a3d1edb

Some content is hidden

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

48 files changed

+62
-370
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};
@@ -930,24 +929,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
930929
self.lower_span(eq_sign_span),
931930
);
932931
}
933-
if !self.sess.features_untracked().destructuring_assignment {
934-
let mut err = feature_err(
935-
&self.sess.parse_sess,
936-
sym::destructuring_assignment,
937-
eq_sign_span,
938-
"destructuring assignments are unstable",
939-
);
940-
err.span_label(lhs.span, "cannot assign to this expression");
941-
if self.is_in_loop_condition {
942-
err.span_suggestion_verbose(
943-
lhs.span.shrink_to_lo(),
944-
"you might have meant to use pattern destructuring",
945-
"let ".to_string(),
946-
rustc_errors::Applicability::MachineApplicable,
947-
);
948-
}
949-
err.emit();
950-
}
951932

952933
let mut assignments = vec![];
953934

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(iter_zip)]
66
#![feature(let_else)]

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
@@ -1265,7 +1265,6 @@ impl<'a> Parser<'a> {
12651265
} else if self.eat_keyword(kw::Let) {
12661266
self.parse_let_expr(attrs)
12671267
} else if self.eat_keyword(kw::Underscore) {
1268-
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
12691268
Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore, attrs))
12701269
} else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
12711270
// Don't complain about bare semicolons after unclosed braces
@@ -2588,7 +2587,6 @@ impl<'a> Parser<'a> {
25882587
let exp_span = self.prev_token.span;
25892588
// We permit `.. }` on the left-hand side of a destructuring assignment.
25902589
if self.check(&token::CloseDelim(close_delim)) {
2591-
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
25922590
base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi());
25932591
break;
25942592
}

compiler/rustc_typeck/src/check/expr.rs

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

library/alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
#![feature(cfg_target_has_atomic)]
138138
#![feature(const_fn_trait_bound)]
139139
#![feature(const_trait_impl)]
140-
#![feature(destructuring_assignment)]
140+
#![cfg_attr(bootstrap, feature(destructuring_assignment))]
141141
#![feature(dropck_eyepatch)]
142142
#![feature(exclusive_range_pattern)]
143143
#![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)