about summary refs log tree commit diff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-27 22:40:15 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-27 23:20:27 -0700
commita96b16e8c334abb422d85cbd79a15afbe9efc4d1 (patch)
treec384f746762a8a7f17cf38107f3f19d9a7d68d9d /src/comp/middle
parent459353e1078ad50c9088980104b4e940840a26ae (diff)
downloadrust-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.rs16
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 */ }
             }