@@ -413,7 +413,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
413
413
}
414
414
}
415
415
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
+ }
417
420
}
418
421
PatKind :: Range ( _, Some ( _) , Spanned { node : RangeEnd :: Excluded , .. } ) => {
419
422
gate ! (
@@ -607,13 +610,16 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
607
610
} ;
608
611
}
609
612
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
+ }
610
617
gate_all_legacy_dont_use ! ( trait_alias, "trait aliases are experimental" ) ;
611
618
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
612
619
// used to be gated under associated_type_bounds, which are right above, so RTN needs to
613
620
// be too.
614
621
gate_all_legacy_dont_use ! ( return_type_notation, "return type notation is experimental" ) ;
615
622
gate_all_legacy_dont_use ! ( decl_macro, "`macro` is experimental" ) ;
616
- gate_all_legacy_dont_use ! ( box_patterns, "box pattern syntax is experimental" ) ;
617
623
gate_all_legacy_dont_use ! (
618
624
exclusive_range_pattern,
619
625
"exclusive range pattern syntax is experimental"
0 commit comments