From 37962288ec80cca6ce027650a3700526feb7ca54 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Wed, 22 Aug 2012 20:35:05 -0400 Subject: [PATCH] Compile moving out of enums (#2329) --- src/rustc/middle/trans/alt.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 13bbfabd0ca3..6e2fd40fecf5 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -794,20 +794,23 @@ fn make_pattern_bindings(bcx: block, phi_bindings: phi_bindings_list) bcx.fcx.lllocals.insert(binding.pat_id, local_imm(phi_val)); } - ast::bind_by_value => { + ast::bind_by_value | ast::bind_by_move => { // by value: make a new temporary and copy the value out let lltype = type_of::type_of(bcx.fcx.ccx, binding.ty); let allocation = alloca(bcx, lltype); let ty = binding.ty; - bcx = copy_val(bcx, INIT, allocation, - load_if_immediate(bcx, phi_val, ty), ty); + bcx = if binding.mode == ast::bind_by_value { + copy_val(bcx, INIT, allocation, + load_if_immediate(bcx, phi_val, ty), ty) + } else { + error!("moving out"); + move_val(bcx, INIT, allocation, + {bcx: bcx, val: phi_val, kind: lv_owned}, ty) + }; bcx.fcx.lllocals.insert(binding.pat_id, local_mem(allocation)); add_clean(bcx, allocation, ty); } - ast::bind_by_move => { - fail ~"unimplemented -- bblum"; - } } }