]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/borrowck-univariant-enum.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.git] / src / test / run-pass / borrowck-univariant-enum.rs
index 3ec061c2dea6127aa162718cb741b923a43b8a5f..8192566da19656c5c22f59232fc1bf646efbcc1a 100644 (file)
@@ -8,8 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+
+use std::cell::Cell;
+use std::gc::GC;
+
 enum newtype {
-    newtype(int)
+    newvar(int)
 }
 
 pub fn main() {
@@ -17,13 +21,13 @@ 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 = box(GC) Cell::new(5);
+    let y = box(GC) Cell::new(newvar(3));
+    let z = match y.get() {
+      newvar(b) => {
+        x.set(x.get() + 1);
+        x.get() * b
       }
     };
-    assert!(z == 18);
+    assert_eq!(z, 18);
 }