提交 d8f6e9f2 编写于 作者: B Brian Anderson

Add let destructuring for unique boxes

Issue #409
上级 122f714f
...@@ -120,6 +120,7 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool { ...@@ -120,6 +120,7 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
pat_wild. | pat_bind(_) { ret false; } pat_wild. | pat_bind(_) { ret false; }
pat_lit(_) { ret true; } pat_lit(_) { ret true; }
pat_box(sub) { ret is_refutable(tcx, sub); } pat_box(sub) { ret is_refutable(tcx, sub); }
pat_uniq(sub) { ret is_refutable(tcx, sub); }
pat_rec(fields, _) { pat_rec(fields, _) {
for field: field_pat in fields { for field: field_pat in fields {
if is_refutable(tcx, field.pat) { ret true; } if is_refutable(tcx, field.pat) { ret true; }
......
...@@ -656,6 +656,10 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef, ...@@ -656,6 +656,10 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
[C_int(0), C_int(back::abi::box_rc_field_body)]); [C_int(0), C_int(back::abi::box_rc_field_body)]);
bcx = bind_irrefutable_pat(bcx, inner, unboxed, table, true); bcx = bind_irrefutable_pat(bcx, inner, unboxed, table, true);
} }
ast::pat_uniq(inner) {
let val = Load(bcx, val);
bcx = bind_irrefutable_pat(bcx, inner, val, table, true);
}
ast::pat_wild. | ast::pat_lit(_) { } ast::pat_wild. | ast::pat_lit(_) { }
} }
ret bcx; ret bcx;
......
fn main() {
let ~{a, b} = ~{a: 100, b: 200};
assert a + b == 300;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册