Skip to content

Commit d8f6e9f

Browse files
committed
Add let destructuring for unique boxes
Issue #409
1 parent 122f714 commit d8f6e9f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/comp/middle/check_alt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
120120
pat_wild. | pat_bind(_) { ret false; }
121121
pat_lit(_) { ret true; }
122122
pat_box(sub) { ret is_refutable(tcx, sub); }
123+
pat_uniq(sub) { ret is_refutable(tcx, sub); }
123124
pat_rec(fields, _) {
124125
for field: field_pat in fields {
125126
if is_refutable(tcx, field.pat) { ret true; }

src/comp/middle/trans_alt.rs

+4
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ fn bind_irrefutable_pat(bcx: @block_ctxt, pat: @ast::pat, val: ValueRef,
656656
[C_int(0), C_int(back::abi::box_rc_field_body)]);
657657
bcx = bind_irrefutable_pat(bcx, inner, unboxed, table, true);
658658
}
659+
ast::pat_uniq(inner) {
660+
let val = Load(bcx, val);
661+
bcx = bind_irrefutable_pat(bcx, inner, val, table, true);
662+
}
659663
ast::pat_wild. | ast::pat_lit(_) { }
660664
}
661665
ret bcx;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let ~{a, b} = ~{a: 100, b: 200};
3+
assert a + b == 300;
4+
}

0 commit comments

Comments
 (0)