]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/build/mod.rs
[MIR] Reintroduce the unit temporary
[rust.git] / src / librustc_mir / build / mod.rs
index d217eb066479364de370bdc536bb7d96c3d091f0..a7459d62368e9cfa6e5f72b694f3deace3b93854 100644 (file)
@@ -26,6 +26,7 @@ pub struct Builder<'a, 'tcx: 'a> {
     var_decls: Vec<VarDecl<'tcx>>,
     var_indices: FnvHashMap<ast::NodeId, u32>,
     temp_decls: Vec<TempDecl<'tcx>>,
+    unit_temp: Option<Lvalue<'tcx>>,
 }
 
 struct CFG<'tcx> {
@@ -96,6 +97,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
         temp_decls: vec![],
         var_decls: vec![],
         var_indices: FnvHashMap(),
+        unit_temp: None
     };
 
     assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
@@ -156,6 +158,18 @@ fn args_and_body(&mut self,
             block.and(arg_decls)
         })
     }
+
+    fn get_unit_temp(&mut self) -> Lvalue<'tcx> {
+        match self.unit_temp {
+            Some(ref tmp) => tmp.clone(),
+            None => {
+                let ty = self.hir.unit_ty();
+                let tmp = self.temp(ty);
+                self.unit_temp = Some(tmp.clone());
+                tmp
+            }
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////