about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-05-05 15:55:32 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-05-05 15:55:32 -0400
commite7f6c4c75406c3ecd117d7213e1be3438454b47e (patch)
tree0faa4609915c4ec0c764324d54ebc3035da7a558
parentbc52224d479c0af1e36d2b12e5cf00c0c0fb3810 (diff)
downloadrust-e7f6c4c75406c3ecd117d7213e1be3438454b47e.tar.gz
rust-e7f6c4c75406c3ecd117d7213e1be3438454b47e.zip
compile-fail tests for #[non_owned] and #[mutable]
-rw-r--r--src/test/compile-fail/mutable-enum.rs19
-rw-r--r--src/test/compile-fail/mutable-struct.rs19
-rw-r--r--src/test/compile-fail/non_owned-enum.rs19
-rw-r--r--src/test/compile-fail/non_owned-struct.rs19
4 files changed, 76 insertions, 0 deletions
diff --git a/src/test/compile-fail/mutable-enum.rs b/src/test/compile-fail/mutable-enum.rs
new file mode 100644
index 00000000000..2368e5eb5c5
--- /dev/null
+++ b/src/test/compile-fail/mutable-enum.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[mutable]
+enum Foo { A }
+
+fn bar<T: Const>(_: T) {}
+
+fn main() {
+    let x = A;
+    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const`
+}
diff --git a/src/test/compile-fail/mutable-struct.rs b/src/test/compile-fail/mutable-struct.rs
new file mode 100644
index 00000000000..ee040506c40
--- /dev/null
+++ b/src/test/compile-fail/mutable-struct.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[mutable]
+struct Foo { a: int }
+
+fn bar<T: Const>(_: T) {}
+
+fn main() {
+    let x = Foo { a: 5 };
+    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const`
+}
diff --git a/src/test/compile-fail/non_owned-enum.rs b/src/test/compile-fail/non_owned-enum.rs
new file mode 100644
index 00000000000..79c2be8183a
--- /dev/null
+++ b/src/test/compile-fail/non_owned-enum.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[non_owned]
+enum Foo { A }
+
+fn bar<T: Owned>(_: T) {}
+
+fn main() {
+    let x = A;
+    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned`
+}
diff --git a/src/test/compile-fail/non_owned-struct.rs b/src/test/compile-fail/non_owned-struct.rs
new file mode 100644
index 00000000000..2d0bc9a7e8e
--- /dev/null
+++ b/src/test/compile-fail/non_owned-struct.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[non_owned]
+struct Foo { a: int }
+
+fn bar<T: Owned>(_: T) {}
+
+fn main() {
+    let x = Foo { a: 5 };
+    bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned`
+}