summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-univariant-enum.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-univariant-enum.rs')
-rw-r--r--tests/ui/borrowck/borrowck-univariant-enum.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-univariant-enum.rs b/tests/ui/borrowck/borrowck-univariant-enum.rs
new file mode 100644
index 000000000..c78e94752
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-univariant-enum.rs
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+use std::cell::Cell;
+
+#[derive(Copy, Clone)]
+enum newtype {
+ newvar(isize)
+}
+
+pub fn main() {
+
+ // Test that borrowck treats enums with a single variant
+ // specially.
+
+ 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);
+}