@@ -833,6 +833,11 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
833
833
let kind = match pat. ctor ( ) {
834
834
Bool ( b) => PatKind :: Constant { value : mir:: Const :: from_bool ( cx. tcx , * b) } ,
835
835
IntRange ( range) => return self . hoist_pat_range ( range, * pat. ty ( ) ) ,
836
+ Struct if pat. ty ( ) . is_box ( ) => {
837
+ // Outside of the `alloc` crate, the only way to create a struct pattern
838
+ // of type `Box` is to use a `box` pattern via #[feature(box_patterns)].
839
+ PatKind :: Box { subpattern : hoist ( & pat. fields [ 0 ] ) }
840
+ }
836
841
Struct | Variant ( _) | UnionField => match pat. ty ( ) . kind ( ) {
837
842
ty:: Tuple ( ..) => PatKind :: StructLike {
838
843
enum_info : EnumInfo :: NotEnum ,
@@ -841,12 +846,6 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
841
846
. map ( |( i, pattern) | FieldPat { field : FieldIdx :: new ( i) , pattern } )
842
847
. collect ( ) ,
843
848
} ,
844
- ty:: Adt ( adt_def, _) if adt_def. is_box ( ) => {
845
- // Without `box_patterns`, the only legal pattern of type `Box` is `_` (outside
846
- // of `std`). So this branch is only reachable when the feature is enabled and
847
- // the pattern is a box pattern.
848
- PatKind :: Deref { subpattern : subpatterns. next ( ) . unwrap ( ) }
849
- }
850
849
& ty:: Adt ( adt_def, _) => {
851
850
let variant_index = RustcPatCtxt :: variant_index_for_adt ( & pat. ctor ( ) , adt_def) ;
852
851
let subpatterns = subpatterns
0 commit comments