diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/moves/move-1-unique.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/moves/move-1-unique.rs b/src/test/ui/moves/move-1-unique.rs new file mode 100644 index 000000000..f98d075d1 --- /dev/null +++ b/src/test/ui/moves/move-1-unique.rs @@ -0,0 +1,25 @@ +// run-pass +#![allow(unused_mut)] +#![allow(dead_code)] + +#[derive(Clone)] +struct Triple { + x: isize, + y: isize, + z: isize, +} + +fn test(x: bool, foo: Box<Triple>) -> isize { + let bar = foo; + let mut y: Box<Triple>; + if x { y = bar; } else { y = Box::new(Triple{x: 4, y: 5, z: 6}); } + return y.y; +} + +pub fn main() { + let x: Box<_> = Box::new(Triple{x: 1, y: 2, z: 3}); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(false, x), 5); +} |