about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2016-06-05 19:03:30 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2016-06-09 00:38:38 +0300
commit1a614f856885eecff09f509268efa1e6ee7a6128 (patch)
tree6d102200694869eb5d12077819059281560966c1
parent5c717a6fc21594569d9e64968cdcf2e88e372a07 (diff)
wrap calls to `lvalue_ty`
-rw-r--r--src/librustc_trans/mir/block.rs4
-rw-r--r--src/librustc_trans/mir/lvalue.rs27
-rw-r--r--src/librustc_trans/mir/statement.rs3
3 files changed, 17 insertions, 17 deletions
diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs
index e19f20bba1d..8a33bbbeae5 100644
--- a/src/librustc_trans/mir/block.rs
+++ b/src/librustc_trans/mir/block.rs
@@ -777,9 +777,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
         }
         let dest = match *dest {
             mir::Lvalue::Temp(idx) => {
-                let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), dest);
-                let lvalue_ty = bcx.monomorphize(&lvalue_ty);
-                let ret_ty = lvalue_ty.to_ty(bcx.tcx());
+                let ret_ty = self.lvalue_ty(dest);
                 match self.temps[idx as usize] {
                     TempRef::Lvalue(dest) => dest,
                     TempRef::Operand(None) => {
diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs
index 841dcf0301c..0c7eeafe86e 100644
--- a/src/librustc_trans/mir/lvalue.rs
+++ b/src/librustc_trans/mir/lvalue.rs
@@ -99,8 +99,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
             },
             mir::Lvalue::Arg(index) => self.args[index as usize],
             mir::Lvalue::Static(def_id) => {
-                let const_ty = self.mir.lvalue_ty(tcx, lvalue);
-                LvalueRef::new_sized(consts::get_static(ccx, def_id).val, const_ty)
+                let const_ty = self.lvalue_ty(lvalue);
+                LvalueRef::new_sized(consts::get_static(ccx, def_id).val,
+                                     LvalueTy::from_ty(const_ty))
             },
             mir::Lvalue::ReturnPointer => {
                 let llval = if !fcx.fn_ty.ret.is_ignore() {
@@ -195,7 +196,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
                             ty::TyArray(..) => {
                                 // must cast the lvalue pointer type to the new
                                 // array type (*[%_; new_len]).
-                                let base_ty = self.mir.lvalue_ty(tcx, lvalue).to_ty(tcx);
+                                let base_ty = self.lvalue_ty(lvalue);
                                 let llbasety = type_of::type_of(bcx.ccx(), base_ty).ptr_to();
                                 let llbase = bcx.pointercast(llbase, llbasety);
                                 (bcx.pointercast(llbase, llbasety), ptr::null_mut())
@@ -236,27 +237,23 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
                 match self.temps[idx as usize] {
                     TempRef::Lvalue(lvalue) => f(self, lvalue),
                     TempRef::Operand(None) => {
-                        let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), lvalue);
-                        let lvalue_ty = bcx.monomorphize(&lvalue_ty);
+                        let lvalue_ty = self.lvalue_ty(lvalue);
                         let lvalue = LvalueRef::alloca(bcx,
-                                                       lvalue_ty.to_ty(bcx.tcx()),
+                                                       lvalue_ty,
                                                        "lvalue_temp");
                         let ret = f(self, lvalue);
-                        let op = self.trans_load(bcx, lvalue.llval, lvalue_ty.to_ty(bcx.tcx()));
+                        let op = self.trans_load(bcx, lvalue.llval, lvalue_ty);
                         self.temps[idx as usize] = TempRef::Operand(Some(op));
                         ret
                     }
                     TempRef::Operand(Some(_)) => {
-                        let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), lvalue);
-                        let lvalue_ty = bcx.monomorphize(&lvalue_ty);
-
                         // See comments in TempRef::new_operand as to why
                         // we always have Some in a ZST TempRef::Operand.
-                        let ty = lvalue_ty.to_ty(bcx.tcx());
+                        let ty = self.lvalue_ty(lvalue);
                         if common::type_is_zero_size(bcx.ccx(), ty) {
                             // Pass an undef pointer as no stores can actually occur.
                             let llptr = C_undef(type_of(bcx.ccx(), ty).ptr_to());
-                            f(self, LvalueRef::new_sized(llptr, lvalue_ty))
+                            f(self, LvalueRef::new_sized(llptr, LvalueTy::from_ty(ty)))
                         } else {
                             bug!("Lvalue temp already set");
                         }
@@ -290,4 +287,10 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
             llindex
         }
     }
+
+    pub fn lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> {
+        let tcx = self.fcx.ccx.tcx();
+        let lvalue_ty = self.mir.lvalue_ty(tcx, lvalue);
+        self.fcx.monomorphize(&lvalue_ty.to_ty(tcx))
+    }
 }
diff --git a/src/librustc_trans/mir/statement.rs b/src/librustc_trans/mir/statement.rs
index 544c47e471f..63472d58233 100644
--- a/src/librustc_trans/mir/statement.rs
+++ b/src/librustc_trans/mir/statement.rs
@@ -40,8 +40,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
                                 bcx
                             }
                             TempRef::Operand(Some(_)) => {
-                                let ty = self.mir.lvalue_ty(bcx.tcx(), lvalue);
-                                let ty = bcx.monomorphize(&ty.to_ty(bcx.tcx()));
+                                let ty = self.lvalue_ty(lvalue);
 
                                 if !common::type_is_zero_size(bcx.ccx(), ty) {
                                     span_bug!(statement.source_info.span,