@@ -27,6 +27,7 @@ use Disr;
27
27
use std:: ptr;
28
28
29
29
use super :: { MirContext , TempRef } ;
30
+ use super :: operand:: OperandValue ;
30
31
31
32
#[ derive( Copy , Clone , Debug ) ]
32
33
pub struct LvalueRef < ' tcx > {
@@ -121,6 +122,26 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
121
122
let return_ty = fn_return_ty. unwrap ( ) ;
122
123
LvalueRef :: new_sized ( llval, LvalueTy :: from_ty ( return_ty) )
123
124
} ,
125
+ mir:: Lvalue :: Projection ( box mir:: Projection {
126
+ ref base,
127
+ elem : mir:: ProjectionElem :: Deref
128
+ } ) => {
129
+ // Load the pointer from its location.
130
+ let ptr = self . trans_consume ( bcx, base) ;
131
+ let projected_ty = LvalueTy :: from_ty ( ptr. ty )
132
+ . projection_ty ( tcx, & mir:: ProjectionElem :: Deref ) ;
133
+ let projected_ty = bcx. monomorphize ( & projected_ty) ;
134
+ let ( llptr, llextra) = match ptr. val {
135
+ OperandValue :: Immediate ( llptr) => ( llptr, ptr:: null_mut ( ) ) ,
136
+ OperandValue :: Pair ( llptr, llextra) => ( llptr, llextra) ,
137
+ OperandValue :: Ref ( _) => bug ! ( "Deref of by-Ref type {:?}" , ptr. ty)
138
+ } ;
139
+ LvalueRef {
140
+ llval : llptr,
141
+ llextra : llextra,
142
+ ty : projected_ty,
143
+ }
144
+ }
124
145
mir:: Lvalue :: Projection ( ref projection) => {
125
146
let tr_base = self . trans_lvalue ( bcx, & projection. base ) ;
126
147
let projected_ty = tr_base. ty . projection_ty ( tcx, & projection. elem ) ;
@@ -138,15 +159,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
138
159
} ;
139
160
140
161
let ( llprojected, llextra) = match projection. elem {
141
- mir:: ProjectionElem :: Deref => {
142
- let base_ty = tr_base. ty . to_ty ( tcx) ;
143
- if common:: type_is_sized ( tcx, projected_ty. to_ty ( tcx) ) {
144
- ( base:: load_ty_builder ( bcx, tr_base. llval , base_ty) ,
145
- ptr:: null_mut ( ) )
146
- } else {
147
- load_fat_ptr ( bcx, tr_base. llval )
148
- }
149
- }
162
+ mir:: ProjectionElem :: Deref => bug ! ( ) ,
150
163
mir:: ProjectionElem :: Field ( ref field, _) => {
151
164
let base_ty = tr_base. ty . to_ty ( tcx) ;
152
165
let base_repr = adt:: represent_type ( ccx, base_ty) ;
0 commit comments