Skip to content

Commit 998cfe5

Browse files
committed
Auto merge of #85305 - MarcusDunn:master, r=pnkfelix
Stabilize bindings_after_at attempting to stabilze bindings_after_at [#65490](#65490), im pretty new to the whole thing so any pointers are greatly appreciated.
2 parents 7d6bf86 + c2af4cb commit 998cfe5

File tree

56 files changed

+228
-335
lines changed

Some content is hidden

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

56 files changed

+228
-335
lines changed

compiler/rustc_ast_passes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//!
55
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
66
7-
#![feature(bindings_after_at)]
7+
#![cfg_attr(bootstrap, feature(bindings_after_at))]
88
#![feature(iter_is_partitioned)]
99
#![feature(box_patterns)]
1010
#![recursion_limit = "256"]

compiler/rustc_feature/src/accepted.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ declare_features! (
287287
(accepted, const_fn_unsize, "1.54.0", Some(64992), None),
288288
/// Allows `impl Trait` with multiple unrelated lifetimes.
289289
(accepted, member_constraints, "1.54.0", Some(61997), None),
290+
/// Allows bindings in the subpattern of a binding pattern.
291+
/// For example, you can write `x @ Some(y)`.
292+
(accepted, bindings_after_at, "1.54.0", Some(65490), None),
290293

291294
// -------------------------------------------------------------------------
292295
// feature-group-end: accepted features

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ declare_features! (
526526
/// Allows using `&mut` in constant functions.
527527
(active, const_mut_refs, "1.41.0", Some(57349), None),
528528

529-
/// Allows bindings in the subpattern of a binding pattern.
530-
/// For example, you can write `x @ Some(y)`.
531-
(active, bindings_after_at, "1.41.0", Some(65490), None),
532-
533529
/// Allows `impl const Trait for T` syntax.
534530
(active, const_trait_impl, "1.42.0", Some(67792), None),
535531

compiler/rustc_mir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Rust MIR: a lowered representation of Rust.
88
#![feature(in_band_lifetimes)]
99
#![feature(array_windows)]
1010
#![feature(assert_matches)]
11-
#![feature(bindings_after_at)]
11+
#![cfg_attr(bootstrap, feature(bindings_after_at))]
1212
#![feature(bool_to_option)]
1313
#![feature(box_patterns)]
1414
#![feature(box_syntax)]

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use rustc_middle::thir::PatKind;
1616
use rustc_middle::ty::{self, Ty, TyCtxt};
1717
use rustc_session::lint::builtin::BINDINGS_WITH_VARIANT_NAME;
1818
use rustc_session::lint::builtin::{IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS};
19-
use rustc_session::parse::feature_err;
2019
use rustc_session::Session;
21-
use rustc_span::{sym, Span};
20+
use rustc_span::Span;
2221
use std::slice;
2322

2423
crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
@@ -115,9 +114,6 @@ impl PatCtxt<'_, '_> {
115114
impl<'tcx> MatchVisitor<'_, 'tcx> {
116115
fn check_patterns(&mut self, pat: &Pat<'_>) {
117116
pat.walk_always(|pat| check_borrow_conflicts_in_at_patterns(self, pat));
118-
if !self.tcx.features().bindings_after_at {
119-
check_legality_of_bindings_in_at_patterns(self, pat);
120-
}
121117
check_for_bindings_named_same_as_variants(self, pat);
122118
}
123119

@@ -732,46 +728,3 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
732728
err.emit();
733729
}
734730
}
735-
736-
/// Forbids bindings in `@` patterns. This used to be is necessary for memory safety,
737-
/// because of the way rvalues were handled in the borrow check. (See issue #14587.)
738-
fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_>) {
739-
AtBindingPatternVisitor { cx, bindings_allowed: true }.visit_pat(pat);
740-
741-
struct AtBindingPatternVisitor<'a, 'b, 'tcx> {
742-
cx: &'a MatchVisitor<'b, 'tcx>,
743-
bindings_allowed: bool,
744-
}
745-
746-
impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> {
747-
type Map = intravisit::ErasedMap<'v>;
748-
749-
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
750-
NestedVisitorMap::None
751-
}
752-
753-
fn visit_pat(&mut self, pat: &Pat<'_>) {
754-
match pat.kind {
755-
hir::PatKind::Binding(.., ref subpat) => {
756-
if !self.bindings_allowed {
757-
feature_err(
758-
&self.cx.tcx.sess.parse_sess,
759-
sym::bindings_after_at,
760-
pat.span,
761-
"pattern bindings after an `@` are unstable",
762-
)
763-
.emit();
764-
}
765-
766-
if subpat.is_some() {
767-
let bindings_were_allowed = self.bindings_allowed;
768-
self.bindings_allowed = false;
769-
intravisit::walk_pat(self, pat);
770-
self.bindings_allowed = bindings_were_allowed;
771-
}
772-
}
773-
_ => intravisit::walk_pat(self, pat),
774-
}
775-
}
776-
}
777-
}

compiler/rustc_parse/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![feature(array_windows)]
44
#![feature(crate_visibility_modifier)]
5-
#![feature(bindings_after_at)]
5+
#![cfg_attr(bootstrap, feature(bindings_after_at))]
66
#![feature(box_syntax)]
77
#![feature(box_patterns)]
88
#![recursion_limit = "256"]

compiler/rustc_typeck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This API is completely unstable and subject to change.
5656
*/
5757

5858
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
59-
#![feature(bindings_after_at)]
59+
#![cfg_attr(bootstrap, feature(bindings_after_at))]
6060
#![feature(bool_to_option)]
6161
#![feature(box_syntax)]
6262
#![feature(crate_visibility_modifier)]

library/alloc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#![feature(allow_internal_unstable)]
8686
#![feature(arbitrary_self_types)]
8787
#![feature(async_stream)]
88+
#![cfg_attr(bootstrap, feature(bindings_after_at))]
8889
#![feature(box_patterns)]
8990
#![feature(box_syntax)]
9091
#![feature(cfg_sanitize)]
@@ -145,7 +146,6 @@
145146
#![feature(associated_type_bounds)]
146147
#![feature(slice_group_by)]
147148
#![feature(decl_macro)]
148-
#![feature(bindings_after_at)]
149149
// Allow testing this library
150150

151151
#[cfg(test)]

src/etc/pre-commit.sh

100755100644
File mode changed.

src/test/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Tests using a combination of pattern features has the expected borrow checking behavior
2-
#![feature(bindings_after_at)]
32
#![feature(box_patterns)]
43

54
enum Test {

0 commit comments

Comments
 (0)