Compile moving out of enums (#2329)

This commit is contained in:
Ben Blum 2012-08-22 20:35:05 -04:00
parent e5fb58e6c0
commit 37962288ec

View file

@ -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";
}
}
}