@@ -16,9 +16,8 @@ use rustc_middle::thir::PatKind;
1616use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
1717use rustc_session:: lint:: builtin:: BINDINGS_WITH_VARIANT_NAME ;
1818use rustc_session:: lint:: builtin:: { IRREFUTABLE_LET_PATTERNS , UNREACHABLE_PATTERNS } ;
19- use rustc_session:: parse:: feature_err;
2019use rustc_session:: Session ;
21- use rustc_span:: { sym , Span } ;
20+ use rustc_span:: { Span } ;
2221use std:: slice;
2322
2423crate fn check_match ( tcx : TyCtxt < ' _ > , def_id : DefId ) {
@@ -123,9 +122,6 @@ impl PatCtxt<'_, '_> {
123122impl < ' tcx > MatchVisitor < ' _ , ' tcx > {
124123 fn check_patterns ( & mut self , pat : & Pat < ' _ > ) {
125124 pat. walk_always ( |pat| check_borrow_conflicts_in_at_patterns ( self , pat) ) ;
126- if !self . tcx . features ( ) . bindings_after_at {
127- check_legality_of_bindings_in_at_patterns ( self , pat) ;
128- }
129125 check_for_bindings_named_same_as_variants ( self , pat) ;
130126 }
131127
@@ -740,46 +736,3 @@ fn check_borrow_conflicts_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat<'_
740736 err. emit ( ) ;
741737 }
742738}
743-
744- /// Forbids bindings in `@` patterns. This used to be is necessary for memory safety,
745- /// because of the way rvalues were handled in the borrow check. (See issue #14587.)
746- fn check_legality_of_bindings_in_at_patterns ( cx : & MatchVisitor < ' _ , ' _ > , pat : & Pat < ' _ > ) {
747- AtBindingPatternVisitor { cx, bindings_allowed : true } . visit_pat ( pat) ;
748-
749- struct AtBindingPatternVisitor < ' a , ' b , ' tcx > {
750- cx : & ' a MatchVisitor < ' b , ' tcx > ,
751- bindings_allowed : bool ,
752- }
753-
754- impl < ' v > Visitor < ' v > for AtBindingPatternVisitor < ' _ , ' _ , ' _ > {
755- type Map = intravisit:: ErasedMap < ' v > ;
756-
757- fn nested_visit_map ( & mut self ) -> NestedVisitorMap < Self :: Map > {
758- NestedVisitorMap :: None
759- }
760-
761- fn visit_pat ( & mut self , pat : & Pat < ' _ > ) {
762- match pat. kind {
763- hir:: PatKind :: Binding ( .., ref subpat) => {
764- if !self . bindings_allowed {
765- feature_err (
766- & self . cx . tcx . sess . parse_sess ,
767- sym:: bindings_after_at,
768- pat. span ,
769- "pattern bindings after an `@` are unstable" ,
770- )
771- . emit ( ) ;
772- }
773-
774- if subpat. is_some ( ) {
775- let bindings_were_allowed = self . bindings_allowed ;
776- self . bindings_allowed = false ;
777- intravisit:: walk_pat ( self , pat) ;
778- self . bindings_allowed = bindings_were_allowed;
779- }
780- }
781- _ => intravisit:: walk_pat ( self , pat) ,
782- }
783- }
784- }
785- }
0 commit comments