about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-05-11 06:41:58 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-05-11 06:41:58 -0700
commit5dbf881e87baad3ab7ff33b56777e8411541e036 (patch)
treeea1238a5bb64f4a52dae10af22fce0f2071760c8
parentb4d1f1b2c11db370a2ef82646a4fdc091699e7b6 (diff)
downloadrust-5dbf881e87baad3ab7ff33b56777e8411541e036.tar.gz
rust-5dbf881e87baad3ab7ff33b56777e8411541e036.zip
three new tests for assigning to various unassignable things
-rw-r--r--src/test/compile-fail/borrowck-assign-to-constants.rs7
-rw-r--r--src/test/compile-fail/borrowck-assign-to-enum.rs6
-rw-r--r--src/test/compile-fail/borrowck-assign-to-resource.rs6
3 files changed, 19 insertions, 0 deletions
diff --git a/src/test/compile-fail/borrowck-assign-to-constants.rs b/src/test/compile-fail/borrowck-assign-to-constants.rs
new file mode 100644
index 00000000000..59ced0275c0
--- /dev/null
+++ b/src/test/compile-fail/borrowck-assign-to-constants.rs
@@ -0,0 +1,7 @@
+const foo: int = 5;
+
+fn main() {
+    // assigning to various global constants
+    none = some(3); //! ERROR assigning to static item
+    foo = 6; //! ERROR assigning to static item
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/borrowck-assign-to-enum.rs b/src/test/compile-fail/borrowck-assign-to-enum.rs
new file mode 100644
index 00000000000..927bcfdc85e
--- /dev/null
+++ b/src/test/compile-fail/borrowck-assign-to-enum.rs
@@ -0,0 +1,6 @@
+enum foo = int;
+
+fn main() {
+    let x = foo(3);
+    *x = 4; //! ERROR assigning to enum content
+}
\ No newline at end of file
diff --git a/src/test/compile-fail/borrowck-assign-to-resource.rs b/src/test/compile-fail/borrowck-assign-to-resource.rs
new file mode 100644
index 00000000000..b04ac704df7
--- /dev/null
+++ b/src/test/compile-fail/borrowck-assign-to-resource.rs
@@ -0,0 +1,6 @@
+resource r(_r: int) {}
+
+fn main() {
+    let x = r(3);
+    *x = 4; //! ERROR assigning to resource content
+}
\ No newline at end of file