]> git.proxmox.com Git - rustc.git/blobdiff - src/test/run-pass/borrowck-univariant-enum.rs
Imported Upstream version 1.0.0~beta.3
[rustc.git] / src / test / run-pass / borrowck-univariant-enum.rs
index bb8710aad489bf67e6f0d4a61218e908d9c8619d..2e8ddb08064726af9a7f3f3afe7ce0269d75a261 100644 (file)
@@ -8,8 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+
+
+use std::cell::Cell;
+
+#[derive(Copy, Clone)]
 enum newtype {
-    newtype(int)
+    newvar(isize)
 }
 
 pub fn main() {
@@ -17,12 +22,12 @@ pub fn main() {
     // Test that borrowck treats enums with a single variant
     // specially.
 
-    let x = @mut 5;
-    let y = @mut newtype(3);
-    let z = match *y {
-      newtype(b) => {
-        *x += 1;
-        *x * b
+    let x = &Cell::new(5);
+    let y = &Cell::new(newtype::newvar(3));
+    let z = match y.get() {
+      newtype::newvar(b) => {
+        x.set(x.get() + 1);
+        x.get() * b
       }
     };
     assert_eq!(z, 18);