@@ -413,7 +413,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
413413 }
414414 }
415415 PatKind :: Box ( ..) => {
416- gate ! ( & self , box_patterns, pattern. span, "box pattern syntax is experimental" ) ;
416+ if !self . features . deref_patterns {
417+ // Allow box patterns under `deref_patterns`.
418+ gate ! ( & self , box_patterns, pattern. span, "box pattern syntax is experimental" ) ;
419+ }
417420 }
418421 PatKind :: Range ( _, Some ( _) , Spanned { node : RangeEnd :: Excluded , .. } ) => {
419422 gate ! (
@@ -607,13 +610,16 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
607610 } ;
608611 }
609612
613+ if !visitor. features . deref_patterns {
614+ // Allow box patterns under `deref_patterns`.
615+ gate_all_legacy_dont_use ! ( box_patterns, "box pattern syntax is experimental" ) ;
616+ }
610617 gate_all_legacy_dont_use ! ( trait_alias, "trait aliases are experimental" ) ;
611618 // Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
612619 // used to be gated under associated_type_bounds, which are right above, so RTN needs to
613620 // be too.
614621 gate_all_legacy_dont_use ! ( return_type_notation, "return type notation is experimental" ) ;
615622 gate_all_legacy_dont_use ! ( decl_macro, "`macro` is experimental" ) ;
616- gate_all_legacy_dont_use ! ( box_patterns, "box pattern syntax is experimental" ) ;
617623 gate_all_legacy_dont_use ! (
618624 exclusive_range_pattern,
619625 "exclusive range pattern syntax is experimental"
0 commit comments