Skip to content

Commit 3796228

Browse files
committed
Compile moving out of enums (#2329)
1 parent e5fb58e commit 3796228

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/rustc/middle/trans/alt.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -794,20 +794,23 @@ fn make_pattern_bindings(bcx: block, phi_bindings: phi_bindings_list)
794794
bcx.fcx.lllocals.insert(binding.pat_id,
795795
local_imm(phi_val));
796796
}
797-
ast::bind_by_value => {
797+
ast::bind_by_value | ast::bind_by_move => {
798798
// by value: make a new temporary and copy the value out
799799
let lltype = type_of::type_of(bcx.fcx.ccx, binding.ty);
800800
let allocation = alloca(bcx, lltype);
801801
let ty = binding.ty;
802-
bcx = copy_val(bcx, INIT, allocation,
803-
load_if_immediate(bcx, phi_val, ty), ty);
802+
bcx = if binding.mode == ast::bind_by_value {
803+
copy_val(bcx, INIT, allocation,
804+
load_if_immediate(bcx, phi_val, ty), ty)
805+
} else {
806+
error!("moving out");
807+
move_val(bcx, INIT, allocation,
808+
{bcx: bcx, val: phi_val, kind: lv_owned}, ty)
809+
};
804810
bcx.fcx.lllocals.insert(binding.pat_id,
805811
local_mem(allocation));
806812
add_clean(bcx, allocation, ty);
807813
}
808-
ast::bind_by_move => {
809-
fail ~"unimplemented -- bblum";
810-
}
811814
}
812815
}
813816

0 commit comments

Comments
 (0)