@@ -3,7 +3,7 @@ use crate::pointer_id::PointerTable;
33use crate :: type_desc:: { self , Ownership , Quantity } ;
44use crate :: util:: { self , Callee } ;
55use rustc_middle:: mir:: {
6- BasicBlock , Body , Location , Operand , Rvalue , Statement , StatementKind , Terminator ,
6+ BasicBlock , Body , Location , Operand , Place , Rvalue , Statement , StatementKind , Terminator ,
77 TerminatorKind ,
88} ;
99use rustc_span:: { Span , DUMMY_SP } ;
@@ -132,6 +132,7 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
132132 }
133133 StatementKind :: FakeRead ( ..) => { }
134134 StatementKind :: SetDiscriminant { .. } => todo ! ( "statement {:?}" , stmt) ,
135+ StatementKind :: Deinit ( ..) => { }
135136 StatementKind :: StorageLive ( ..) => { }
136137 StatementKind :: StorageDead ( ..) => { }
137138 StatementKind :: Retag ( ..) => { }
@@ -163,14 +164,16 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
163164 ref func,
164165 ref args,
165166 destination,
167+ target,
166168 ..
167169 } => {
168170 let func_ty = func. ty ( self . mir , tcx) ;
169- let pl_ty = destination . map ( | ( pl , _ ) | self . acx . type_of ( pl ) ) ;
171+ let pl_ty = self . acx . type_of ( destination ) ;
170172
171173 if let Some ( callee) = util:: ty_callee ( tcx, func_ty) {
172174 // Special cases for particular functions.
173- let pl_ty = pl_ty. unwrap ( ) ;
175+ // TODO(kkysen) I kept the `.unwrap()` so that the behavior is identical. Do we need this?
176+ target. unwrap ( ) ;
174177 match callee {
175178 Callee :: PtrOffset { .. } => {
176179 self . visit_ptr_offset ( & args[ 0 ] , pl_ty) ;
@@ -249,23 +252,29 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
249252 Rvalue :: ShallowInitBox ( ref _op, _ty) => {
250253 // TODO
251254 }
255+ Rvalue :: CopyForDeref ( pl) => {
256+ self . enter_rvalue_operand ( 0 , |v| v. visit_place ( pl, expect_ty) ) ;
257+ }
252258 }
253259 }
254260
255261 fn visit_operand ( & mut self , op : & Operand < ' tcx > , expect_ty : LTy < ' tcx > ) {
256262 match * op {
257263 Operand :: Copy ( pl) | Operand :: Move ( pl) => {
258- if let Some ( ptr) = self . acx . ptr_of ( pl) {
259- let expect_ptr = expect_ty. label ;
260- self . emit_ptr_cast ( ptr, expect_ptr) ;
261- }
262-
263- // TODO: walk over `pl` to handle all derefs (casts, `*x` -> `(*x).get()`)
264+ self . visit_place ( pl, expect_ty) ;
264265 }
265266 Operand :: Constant ( ..) => { }
266267 }
267268 }
268269
270+ fn visit_place ( & mut self , pl : Place < ' tcx > , expect_ty : LTy < ' tcx > ) {
271+ if let Some ( ptr) = self . acx . ptr_of ( pl) {
272+ let expect_ptr = expect_ty. label ;
273+ self . emit_ptr_cast ( ptr, expect_ptr) ;
274+ }
275+ // TODO: walk over `pl` to handle all derefs (casts, `*x` -> `(*x).get()`)
276+ }
277+
269278 fn visit_operand_desc (
270279 & mut self ,
271280 op : & Operand < ' tcx > ,
0 commit comments