@@ -1944,8 +1944,16 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
19441944 }
19451945 hir:: PatBox ( ref inner) => {
19461946 let pat_ty = node_id_type ( bcx, inner. id ) ;
1947- // Don't load DSTs, instead pass along a fat ptr
1948- let val = if type_is_sized ( tcx, pat_ty) {
1947+ // Pass along DSTs as fat pointers.
1948+ let val = if type_is_fat_ptr ( tcx, pat_ty) {
1949+ // We need to check for this, as the pattern could be binding
1950+ // a fat pointer by-value.
1951+ if let hir:: PatIdent ( hir:: BindByRef ( _) , _, _) = inner. node {
1952+ val. val
1953+ } else {
1954+ Load ( bcx, val. val )
1955+ }
1956+ } else if type_is_sized ( tcx, pat_ty) {
19491957 Load ( bcx, val. val )
19501958 } else {
19511959 val. val
@@ -1955,8 +1963,16 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
19551963 }
19561964 hir:: PatRegion ( ref inner, _) => {
19571965 let pat_ty = node_id_type ( bcx, inner. id ) ;
1958- // Don't load DSTs, instead pass along a fat ptr
1959- let val = if type_is_sized ( tcx, pat_ty) {
1966+ // Pass along DSTs as fat pointers.
1967+ let val = if type_is_fat_ptr ( tcx, pat_ty) {
1968+ // We need to check for this, as the pattern could be binding
1969+ // a fat pointer by-value.
1970+ if let hir:: PatIdent ( hir:: BindByRef ( _) , _, _) = inner. node {
1971+ val. val
1972+ } else {
1973+ Load ( bcx, val. val )
1974+ }
1975+ } else if type_is_sized ( tcx, pat_ty) {
19601976 Load ( bcx, val. val )
19611977 } else {
19621978 val. val
0 commit comments