summaryrefslogtreecommitdiffstats
path: root/src/test/ui/unique
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/unique')
-rw-r--r--src/test/ui/unique/unique-assign-copy.rs12
-rw-r--r--src/test/ui/unique/unique-assign-drop.rs10
-rw-r--r--src/test/ui/unique/unique-assign-generic.rs11
-rw-r--r--src/test/ui/unique/unique-assign.rs8
-rw-r--r--src/test/ui/unique/unique-autoderef-field.rs10
-rw-r--r--src/test/ui/unique/unique-autoderef-index.rs6
-rw-r--r--src/test/ui/unique/unique-cmp.rs11
-rw-r--r--src/test/ui/unique/unique-containing-tag.rs25
-rw-r--r--src/test/ui/unique/unique-create.rs11
-rw-r--r--src/test/ui/unique/unique-decl-init-copy.rs11
-rw-r--r--src/test/ui/unique/unique-decl-init.rs7
-rw-r--r--src/test/ui/unique/unique-decl-move.rs7
-rw-r--r--src/test/ui/unique/unique-decl.rs11
-rw-r--r--src/test/ui/unique/unique-deref.rs6
-rw-r--r--src/test/ui/unique/unique-destructure.rs9
-rw-r--r--src/test/ui/unique/unique-drop-complex.rs6
-rw-r--r--src/test/ui/unique/unique-ffi-symbols.rs16
-rw-r--r--src/test/ui/unique/unique-fn-arg-move.rs10
-rw-r--r--src/test/ui/unique/unique-fn-arg-mut.rs11
-rw-r--r--src/test/ui/unique/unique-fn-arg.rs11
-rw-r--r--src/test/ui/unique/unique-fn-ret.rs9
-rw-r--r--src/test/ui/unique/unique-generic-assign.rs11
-rw-r--r--src/test/ui/unique/unique-in-tag.rs20
-rw-r--r--src/test/ui/unique/unique-in-vec-copy.rs15
-rw-r--r--src/test/ui/unique/unique-in-vec.rs6
-rw-r--r--src/test/ui/unique/unique-init.rs6
-rw-r--r--src/test/ui/unique/unique-kinds.rs64
-rw-r--r--src/test/ui/unique/unique-log.rs6
-rw-r--r--src/test/ui/unique/unique-match-discrim.rs12
-rw-r--r--src/test/ui/unique/unique-move-drop.rs10
-rw-r--r--src/test/ui/unique/unique-move-temp.rs8
-rw-r--r--src/test/ui/unique/unique-move.rs9
-rw-r--r--src/test/ui/unique/unique-mutable.rs7
-rw-r--r--src/test/ui/unique/unique-object-move.rs18
-rw-r--r--src/test/ui/unique/unique-pat-2.rs18
-rw-r--r--src/test/ui/unique/unique-pat-3.rs16
-rw-r--r--src/test/ui/unique/unique-pat.rs14
-rw-r--r--src/test/ui/unique/unique-rec.rs9
-rw-r--r--src/test/ui/unique/unique-send-2.rs33
-rw-r--r--src/test/ui/unique/unique-send.rs10
-rw-r--r--src/test/ui/unique/unique-swap.rs11
41 files changed, 521 insertions, 0 deletions
diff --git a/src/test/ui/unique/unique-assign-copy.rs b/src/test/ui/unique/unique-assign-copy.rs
new file mode 100644
index 000000000..b742973ce
--- /dev/null
+++ b/src/test/ui/unique/unique-assign-copy.rs
@@ -0,0 +1,12 @@
+// run-pass
+
+pub fn main() {
+ let mut i: Box<_> = Box::new(1);
+ // Should be a copy
+ let mut j;
+ j = i.clone();
+ *i = 2;
+ *j = 3;
+ assert_eq!(*i, 2);
+ assert_eq!(*j, 3);
+}
diff --git a/src/test/ui/unique/unique-assign-drop.rs b/src/test/ui/unique/unique-assign-drop.rs
new file mode 100644
index 000000000..e7685b589
--- /dev/null
+++ b/src/test/ui/unique/unique-assign-drop.rs
@@ -0,0 +1,10 @@
+// run-pass
+#![allow(unused_assignments)]
+
+pub fn main() {
+ let i: Box<_> = Box::new(1);
+ let mut j: Box<_> = Box::new(2);
+ // Should drop the previous value of j
+ j = i;
+ assert_eq!(*j, 1);
+}
diff --git a/src/test/ui/unique/unique-assign-generic.rs b/src/test/ui/unique/unique-assign-generic.rs
new file mode 100644
index 000000000..d4932d833
--- /dev/null
+++ b/src/test/ui/unique/unique-assign-generic.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+fn f<T>(t: T) -> T {
+ let t1 = t;
+ t1
+}
+
+pub fn main() {
+ let t = f::<Box<_>>(Box::new(100));
+ assert_eq!(t, Box::new(100));
+}
diff --git a/src/test/ui/unique/unique-assign.rs b/src/test/ui/unique/unique-assign.rs
new file mode 100644
index 000000000..d598744f1
--- /dev/null
+++ b/src/test/ui/unique/unique-assign.rs
@@ -0,0 +1,8 @@
+// run-pass
+#![allow(unused_mut)]
+
+pub fn main() {
+ let mut i: Box<_>;
+ i = Box::new(1);
+ assert_eq!(*i, 1);
+}
diff --git a/src/test/ui/unique/unique-autoderef-field.rs b/src/test/ui/unique/unique-autoderef-field.rs
new file mode 100644
index 000000000..64147e11f
--- /dev/null
+++ b/src/test/ui/unique/unique-autoderef-field.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+struct J { j: isize }
+
+pub fn main() {
+ let i: Box<_> = Box::new(J {
+ j: 100
+ });
+ assert_eq!(i.j, 100);
+}
diff --git a/src/test/ui/unique/unique-autoderef-index.rs b/src/test/ui/unique/unique-autoderef-index.rs
new file mode 100644
index 000000000..ea6598a7f
--- /dev/null
+++ b/src/test/ui/unique/unique-autoderef-index.rs
@@ -0,0 +1,6 @@
+// run-pass
+
+pub fn main() {
+ let i: Box<_> = Box::new(vec![100]);
+ assert_eq!((*i)[0], 100);
+}
diff --git a/src/test/ui/unique/unique-cmp.rs b/src/test/ui/unique/unique-cmp.rs
new file mode 100644
index 000000000..ee05dd5a3
--- /dev/null
+++ b/src/test/ui/unique/unique-cmp.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(unused_allocation)]
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ assert_eq!(i, Box::new(100));
+ assert!(i < Box::new(101));
+ assert!(i <= Box::new(100));
+ assert!(i > Box::new(99));
+ assert!(i >= Box::new(99));
+}
diff --git a/src/test/ui/unique/unique-containing-tag.rs b/src/test/ui/unique/unique-containing-tag.rs
new file mode 100644
index 000000000..6c31ae99b
--- /dev/null
+++ b/src/test/ui/unique/unique-containing-tag.rs
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+
+// pretty-expanded FIXME #23616
+
+pub fn main() {
+ enum t { t1(isize), t2(isize), }
+
+ let _x: Box<_> = Box::new(t::t1(10));
+
+ /*alt *x {
+ t1(a) {
+ assert_eq!(a, 10);
+ }
+ _ { panic!(); }
+ }*/
+
+ /*alt x {
+ Box::new(t1(a) {
+ assert_eq!(a, 10);
+ })
+ _ { panic!(); }
+ }*/
+}
diff --git a/src/test/ui/unique/unique-create.rs b/src/test/ui/unique/unique-create.rs
new file mode 100644
index 000000000..c566e7962
--- /dev/null
+++ b/src/test/ui/unique/unique-create.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+pub fn main() {
+ let _: Box<_> = Box::new(100);
+}
+
+fn vec() {
+ vec![0];
+}
diff --git a/src/test/ui/unique/unique-decl-init-copy.rs b/src/test/ui/unique/unique-decl-init-copy.rs
new file mode 100644
index 000000000..5b9576fcc
--- /dev/null
+++ b/src/test/ui/unique/unique-decl-init-copy.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+pub fn main() {
+ let mut i: Box<_> = Box::new(1);
+ // Should be a copy
+ let mut j = i.clone();
+ *i = 2;
+ *j = 3;
+ assert_eq!(*i, 2);
+ assert_eq!(*j, 3);
+}
diff --git a/src/test/ui/unique/unique-decl-init.rs b/src/test/ui/unique/unique-decl-init.rs
new file mode 100644
index 000000000..1d70860c7
--- /dev/null
+++ b/src/test/ui/unique/unique-decl-init.rs
@@ -0,0 +1,7 @@
+// run-pass
+
+pub fn main() {
+ let i: Box<_> = Box::new(1);
+ let j = i;
+ assert_eq!(*j, 1);
+}
diff --git a/src/test/ui/unique/unique-decl-move.rs b/src/test/ui/unique/unique-decl-move.rs
new file mode 100644
index 000000000..21187510f
--- /dev/null
+++ b/src/test/ui/unique/unique-decl-move.rs
@@ -0,0 +1,7 @@
+// run-pass
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ let j = i;
+ assert_eq!(*j, 100);
+}
diff --git a/src/test/ui/unique/unique-decl.rs b/src/test/ui/unique/unique-decl.rs
new file mode 100644
index 000000000..84a1b2a5b
--- /dev/null
+++ b/src/test/ui/unique/unique-decl.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(dead_code)]
+
+
+pub fn main() {
+ let _: Box<isize>;
+}
+
+fn f(_i: Box<isize>) -> Box<isize> {
+ panic!();
+}
diff --git a/src/test/ui/unique/unique-deref.rs b/src/test/ui/unique/unique-deref.rs
new file mode 100644
index 000000000..33a1e9932
--- /dev/null
+++ b/src/test/ui/unique/unique-deref.rs
@@ -0,0 +1,6 @@
+// run-pass
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ assert_eq!(*i, 100);
+}
diff --git a/src/test/ui/unique/unique-destructure.rs b/src/test/ui/unique/unique-destructure.rs
new file mode 100644
index 000000000..7207ac962
--- /dev/null
+++ b/src/test/ui/unique/unique-destructure.rs
@@ -0,0 +1,9 @@
+// run-pass
+#![feature(box_patterns)]
+
+struct Foo { a: isize, b: isize }
+
+pub fn main() {
+ let box Foo{ a, b } = Box::new(Foo { a: 100, b: 200 });
+ assert_eq!(a + b, 300);
+}
diff --git a/src/test/ui/unique/unique-drop-complex.rs b/src/test/ui/unique/unique-drop-complex.rs
new file mode 100644
index 000000000..2324f1e1a
--- /dev/null
+++ b/src/test/ui/unique/unique-drop-complex.rs
@@ -0,0 +1,6 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+pub fn main() {
+ let _x: Box<_> = Box::new(vec![0,0,0,0,0]);
+}
diff --git a/src/test/ui/unique/unique-ffi-symbols.rs b/src/test/ui/unique/unique-ffi-symbols.rs
new file mode 100644
index 000000000..77b5ead26
--- /dev/null
+++ b/src/test/ui/unique/unique-ffi-symbols.rs
@@ -0,0 +1,16 @@
+// run-pass
+// We used to have a __rust_abi shim that resulted in duplicated symbols
+// whenever the item path wasn't enough to disambiguate between them.
+fn main() {
+ let a = {
+ extern "C" fn good() -> i32 { return 0; }
+ good as extern "C" fn() -> i32
+ };
+ let b = {
+ extern "C" fn good() -> i32 { return 5; }
+ good as extern "C" fn() -> i32
+ };
+
+ assert!(a != b);
+ assert_eq!((a(), b()), (0, 5));
+}
diff --git a/src/test/ui/unique/unique-fn-arg-move.rs b/src/test/ui/unique/unique-fn-arg-move.rs
new file mode 100644
index 000000000..6d42df218
--- /dev/null
+++ b/src/test/ui/unique/unique-fn-arg-move.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+fn f(i: Box<isize>) {
+ assert_eq!(*i, 100);
+}
+
+pub fn main() {
+ let i = Box::new(100);
+ f(i);
+}
diff --git a/src/test/ui/unique/unique-fn-arg-mut.rs b/src/test/ui/unique/unique-fn-arg-mut.rs
new file mode 100644
index 000000000..01510200b
--- /dev/null
+++ b/src/test/ui/unique/unique-fn-arg-mut.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+fn f(i: &mut Box<isize>) {
+ *i = Box::new(200);
+}
+
+pub fn main() {
+ let mut i = Box::new(100);
+ f(&mut i);
+ assert_eq!(*i, 200);
+}
diff --git a/src/test/ui/unique/unique-fn-arg.rs b/src/test/ui/unique/unique-fn-arg.rs
new file mode 100644
index 000000000..b4f3bc4b2
--- /dev/null
+++ b/src/test/ui/unique/unique-fn-arg.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+fn f(i: Box<isize>) {
+ assert_eq!(*i, 100);
+}
+
+pub fn main() {
+ f(Box::new(100));
+ let i = Box::new(100);
+ f(i);
+}
diff --git a/src/test/ui/unique/unique-fn-ret.rs b/src/test/ui/unique/unique-fn-ret.rs
new file mode 100644
index 000000000..773a9bce1
--- /dev/null
+++ b/src/test/ui/unique/unique-fn-ret.rs
@@ -0,0 +1,9 @@
+// run-pass
+
+fn f() -> Box<isize> {
+ Box::new(100)
+}
+
+pub fn main() {
+ assert_eq!(f(), Box::new(100));
+}
diff --git a/src/test/ui/unique/unique-generic-assign.rs b/src/test/ui/unique/unique-generic-assign.rs
new file mode 100644
index 000000000..9c4405aa8
--- /dev/null
+++ b/src/test/ui/unique/unique-generic-assign.rs
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(dead_code)]
+// Issue #976
+
+
+// pretty-expanded FIXME #23616
+
+fn f<T>(x: Box<T>) {
+ let _x2 = x;
+}
+pub fn main() { }
diff --git a/src/test/ui/unique/unique-in-tag.rs b/src/test/ui/unique/unique-in-tag.rs
new file mode 100644
index 000000000..6daa06fb1
--- /dev/null
+++ b/src/test/ui/unique/unique-in-tag.rs
@@ -0,0 +1,20 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+
+fn test1() {
+ enum bar { u(Box<isize>), w(isize), }
+
+ let x = bar::u(Box::new(10));
+ assert!(match x {
+ bar::u(a) => {
+ println!("{}", a);
+ *a
+ }
+ _ => { 66 }
+ } == 10);
+}
+
+pub fn main() {
+ test1();
+}
diff --git a/src/test/ui/unique/unique-in-vec-copy.rs b/src/test/ui/unique/unique-in-vec-copy.rs
new file mode 100644
index 000000000..ce52d15ef
--- /dev/null
+++ b/src/test/ui/unique/unique-in-vec-copy.rs
@@ -0,0 +1,15 @@
+// run-pass
+
+pub fn main() {
+ let mut a: Vec<Box<_>> = vec![Box::new(10)];
+ let b = a.clone();
+
+ assert_eq!(*a[0], 10);
+ assert_eq!(*b[0], 10);
+
+ // This should only modify the value in a, not b
+ *a[0] = 20;
+
+ assert_eq!(*a[0], 20);
+ assert_eq!(*b[0], 10);
+}
diff --git a/src/test/ui/unique/unique-in-vec.rs b/src/test/ui/unique/unique-in-vec.rs
new file mode 100644
index 000000000..1e8d05e3d
--- /dev/null
+++ b/src/test/ui/unique/unique-in-vec.rs
@@ -0,0 +1,6 @@
+// run-pass
+
+pub fn main() {
+ let vect : Vec<Box<_>> = vec![Box::new(100)];
+ assert_eq!(vect[0], Box::new(100));
+}
diff --git a/src/test/ui/unique/unique-init.rs b/src/test/ui/unique/unique-init.rs
new file mode 100644
index 000000000..d19605046
--- /dev/null
+++ b/src/test/ui/unique/unique-init.rs
@@ -0,0 +1,6 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+pub fn main() {
+ let _i: Box<_> = Box::new(100);
+}
diff --git a/src/test/ui/unique/unique-kinds.rs b/src/test/ui/unique/unique-kinds.rs
new file mode 100644
index 000000000..f02d0b507
--- /dev/null
+++ b/src/test/ui/unique/unique-kinds.rs
@@ -0,0 +1,64 @@
+// run-pass
+
+use std::cmp::PartialEq;
+use std::fmt::Debug;
+
+fn sendable() {
+
+ fn f<T:Send + PartialEq + Debug>(i: T, j: T) {
+ assert_eq!(i, j);
+ }
+
+ fn g<T:Send + PartialEq>(i: T, j: T) {
+ assert!(i != j);
+ }
+
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(100);
+ f(i, j);
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(101);
+ g(i, j);
+}
+
+fn copyable() {
+
+ fn f<T:PartialEq + Debug>(i: T, j: T) {
+ assert_eq!(i, j);
+ }
+
+ fn g<T:PartialEq>(i: T, j: T) {
+ assert!(i != j);
+ }
+
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(100);
+ f(i, j);
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(101);
+ g(i, j);
+}
+
+fn noncopyable() {
+
+ fn f<T:PartialEq + Debug>(i: T, j: T) {
+ assert_eq!(i, j);
+ }
+
+ fn g<T:PartialEq>(i: T, j: T) {
+ assert!(i != j);
+ }
+
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(100);
+ f(i, j);
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(101);
+ g(i, j);
+}
+
+pub fn main() {
+ sendable();
+ copyable();
+ noncopyable();
+}
diff --git a/src/test/ui/unique/unique-log.rs b/src/test/ui/unique/unique-log.rs
new file mode 100644
index 000000000..0715d1662
--- /dev/null
+++ b/src/test/ui/unique/unique-log.rs
@@ -0,0 +1,6 @@
+// run-pass
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ println!("{}", i);
+}
diff --git a/src/test/ui/unique/unique-match-discrim.rs b/src/test/ui/unique/unique-match-discrim.rs
new file mode 100644
index 000000000..6e6d74322
--- /dev/null
+++ b/src/test/ui/unique/unique-match-discrim.rs
@@ -0,0 +1,12 @@
+// run-pass
+#![allow(dead_code)]
+// Issue #961
+
+// pretty-expanded FIXME #23616
+
+fn altsimple() {
+ match Box::new(true) {
+ _ => { }
+ }
+}
+pub fn main() { }
diff --git a/src/test/ui/unique/unique-move-drop.rs b/src/test/ui/unique/unique-move-drop.rs
new file mode 100644
index 000000000..c0f5d8f90
--- /dev/null
+++ b/src/test/ui/unique/unique-move-drop.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+#![allow(unused_variables)]
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ let j: Box<_> = Box::new(200);
+ let j = i;
+ assert_eq!(*j, 100);
+}
diff --git a/src/test/ui/unique/unique-move-temp.rs b/src/test/ui/unique/unique-move-temp.rs
new file mode 100644
index 000000000..103af8e1f
--- /dev/null
+++ b/src/test/ui/unique/unique-move-temp.rs
@@ -0,0 +1,8 @@
+// run-pass
+#![allow(unused_mut)]
+
+pub fn main() {
+ let mut i: Box<_>;
+ i = Box::new(100);
+ assert_eq!(*i, 100);
+}
diff --git a/src/test/ui/unique/unique-move.rs b/src/test/ui/unique/unique-move.rs
new file mode 100644
index 000000000..40a2718e4
--- /dev/null
+++ b/src/test/ui/unique/unique-move.rs
@@ -0,0 +1,9 @@
+// run-pass
+#![allow(unused_mut)]
+
+pub fn main() {
+ let i: Box<_> = Box::new(100);
+ let mut j;
+ j = i;
+ assert_eq!(*j, 100);
+}
diff --git a/src/test/ui/unique/unique-mutable.rs b/src/test/ui/unique/unique-mutable.rs
new file mode 100644
index 000000000..0367c0809
--- /dev/null
+++ b/src/test/ui/unique/unique-mutable.rs
@@ -0,0 +1,7 @@
+// run-pass
+
+pub fn main() {
+ let mut i: Box<_> = Box::new(0);
+ *i = 1;
+ assert_eq!(*i, 1);
+}
diff --git a/src/test/ui/unique/unique-object-move.rs b/src/test/ui/unique/unique-object-move.rs
new file mode 100644
index 000000000..bb35a9b2d
--- /dev/null
+++ b/src/test/ui/unique/unique-object-move.rs
@@ -0,0 +1,18 @@
+// run-pass
+#![allow(dead_code)]
+// Issue #5192
+
+// pretty-expanded FIXME #23616
+
+pub trait EventLoop { fn foo(&self) {} }
+
+pub struct UvEventLoop {
+ uvio: isize
+}
+
+impl EventLoop for UvEventLoop { }
+
+pub fn main() {
+ let loop_: Box<dyn EventLoop> = Box::new(UvEventLoop { uvio: 0 }) as Box<dyn EventLoop>;
+ let _loop2_ = loop_;
+}
diff --git a/src/test/ui/unique/unique-pat-2.rs b/src/test/ui/unique/unique-pat-2.rs
new file mode 100644
index 000000000..9c73fd220
--- /dev/null
+++ b/src/test/ui/unique/unique-pat-2.rs
@@ -0,0 +1,18 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+#![allow(non_shorthand_field_patterns)]
+
+#![feature(box_patterns)]
+
+struct Foo {a: isize, b: usize}
+
+enum bar { u(Box<Foo>), w(isize), }
+
+pub fn main() {
+ let v = match bar::u(Box::new(Foo{ a: 10, b: 40 })) {
+ bar::u(box Foo{ a: a, b: b }) => { a + (b as isize) }
+ _ => { 66 }
+ };
+ assert_eq!(v, 50);
+}
diff --git a/src/test/ui/unique/unique-pat-3.rs b/src/test/ui/unique/unique-pat-3.rs
new file mode 100644
index 000000000..2e81f898d
--- /dev/null
+++ b/src/test/ui/unique/unique-pat-3.rs
@@ -0,0 +1,16 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+
+enum bar { u(Box<isize>), w(isize), }
+
+pub fn main() {
+ let v = match bar::u(10.into()) {
+ bar::u(a) => {
+ println!("{}", a);
+ *a
+ }
+ _ => { 66 }
+ };
+ assert_eq!(v, 10);
+}
diff --git a/src/test/ui/unique/unique-pat.rs b/src/test/ui/unique/unique-pat.rs
new file mode 100644
index 000000000..c2474d0e7
--- /dev/null
+++ b/src/test/ui/unique/unique-pat.rs
@@ -0,0 +1,14 @@
+// run-pass
+
+#![feature(box_patterns)]
+
+fn simple() {
+ match Box::new(true) {
+ box true => { }
+ _ => { panic!(); }
+ }
+}
+
+pub fn main() {
+ simple();
+}
diff --git a/src/test/ui/unique/unique-rec.rs b/src/test/ui/unique/unique-rec.rs
new file mode 100644
index 000000000..9f8ad9bb0
--- /dev/null
+++ b/src/test/ui/unique/unique-rec.rs
@@ -0,0 +1,9 @@
+// run-pass
+
+struct X { x: isize }
+
+pub fn main() {
+ let x: Box<_> = Box::new(X {x: 1});
+ let bar = x;
+ assert_eq!(bar.x, 1);
+}
diff --git a/src/test/ui/unique/unique-send-2.rs b/src/test/ui/unique/unique-send-2.rs
new file mode 100644
index 000000000..23ddd2cdc
--- /dev/null
+++ b/src/test/ui/unique/unique-send-2.rs
@@ -0,0 +1,33 @@
+// run-pass
+#![allow(unused_must_use)]
+// ignore-emscripten no threads support
+
+use std::sync::mpsc::{channel, Sender};
+use std::thread;
+
+fn child(tx: &Sender<Box<usize>>, i: usize) {
+ tx.send(Box::new(i)).unwrap();
+}
+
+pub fn main() {
+ let (tx, rx) = channel();
+ let n = 100;
+ let mut expected = 0;
+ let ts = (0..n).map(|i| {
+ expected += i;
+ let tx = tx.clone();
+ thread::spawn(move|| {
+ child(&tx, i)
+ })
+ }).collect::<Vec<_>>();
+
+ let mut actual = 0;
+ for _ in 0..n {
+ let j = rx.recv().unwrap();
+ actual += *j;
+ }
+
+ assert_eq!(expected, actual);
+
+ for t in ts { t.join(); }
+}
diff --git a/src/test/ui/unique/unique-send.rs b/src/test/ui/unique/unique-send.rs
new file mode 100644
index 000000000..431cc2be5
--- /dev/null
+++ b/src/test/ui/unique/unique-send.rs
@@ -0,0 +1,10 @@
+// run-pass
+
+use std::sync::mpsc::channel;
+
+pub fn main() {
+ let (tx, rx) = channel::<Box<_>>();
+ tx.send(Box::new(100)).unwrap();
+ let v = rx.recv().unwrap();
+ assert_eq!(v, Box::new(100));
+}
diff --git a/src/test/ui/unique/unique-swap.rs b/src/test/ui/unique/unique-swap.rs
new file mode 100644
index 000000000..4f33ff9a8
--- /dev/null
+++ b/src/test/ui/unique/unique-swap.rs
@@ -0,0 +1,11 @@
+// run-pass
+
+use std::mem::swap;
+
+pub fn main() {
+ let mut i: Box<_> = Box::new(100);
+ let mut j: Box<_> = Box::new(200);
+ swap(&mut i, &mut j);
+ assert_eq!(i, Box::new(200));
+ assert_eq!(j, Box::new(100));
+}