diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-27 22:40:15 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-27 23:20:27 -0700 |
| commit | a96b16e8c334abb422d85cbd79a15afbe9efc4d1 (patch) | |
| tree | c384f746762a8a7f17cf38107f3f19d9a7d68d9d /src/comp/middle | |
| parent | 459353e1078ad50c9088980104b4e940840a26ae (diff) | |
| download | rust-a96b16e8c334abb422d85cbd79a15afbe9efc4d1.tar.gz rust-a96b16e8c334abb422d85cbd79a15afbe9efc4d1.zip | |
Make it again possible to initialize resource locals via assignment
Some special cases allow both 'let a <- my_resource(x)' and 'let a = my_resource(x)' to work as expected despite ostensibly being copies and moves.
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/kind.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index c5e8991f804..f4c23d3d4d7 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -183,6 +183,12 @@ fn need_shared_or_pinned_ctor(tcx: ty::ctxt, a: @ast::expr, descr: str) { ast::expr_rec(_, _) { true } + ast::expr_unary(ast::uniq(_), _) { + true + } + ast::expr_tup(_) { + true + } _ { false } } } @@ -266,14 +272,12 @@ fn check_stmt(tcx: ty::ctxt, stmt: @ast::stmt) { for (let_style, local) in locals { alt local.node.init { option::some({op: ast::init_assign., expr}) { - need_expr_kind(tcx, expr, - ast::kind_shared, - "local initializer"); + need_shared_or_pinned_ctor(tcx, expr, + "local initializer"); } option::some({op: ast::init_move., expr}) { - // FIXME: Should be as above but moving may be the - // only way available currently to assign a resource - // to a local. + need_shared_or_pinned_ctor(tcx, expr, + "local initializer"); } option::none. { /* fall through */ } } |
