From 5dbf881e87baad3ab7ff33b56777e8411541e036 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 May 2012 06:41:58 -0700 Subject: [PATCH] three new tests for assigning to various unassignable things --- src/test/compile-fail/borrowck-assign-to-constants.rs | 7 +++++++ src/test/compile-fail/borrowck-assign-to-enum.rs | 6 ++++++ src/test/compile-fail/borrowck-assign-to-resource.rs | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 src/test/compile-fail/borrowck-assign-to-constants.rs create mode 100644 src/test/compile-fail/borrowck-assign-to-enum.rs create mode 100644 src/test/compile-fail/borrowck-assign-to-resource.rs 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