@@ -1944,8 +1944,16 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
1944
1944
}
1945
1945
hir:: PatBox ( ref inner) => {
1946
1946
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) {
1949
1957
Load ( bcx, val. val )
1950
1958
} else {
1951
1959
val. val
@@ -1955,8 +1963,16 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
1955
1963
}
1956
1964
hir:: PatRegion ( ref inner, _) => {
1957
1965
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) {
1960
1976
Load ( bcx, val. val )
1961
1977
} else {
1962
1978
val. val
0 commit comments