about summary refs log tree commit diff
path: root/tests/ui/borrowck/borrowck-move-subcomponent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/borrowck-move-subcomponent.rs')
-rw-r--r--tests/ui/borrowck/borrowck-move-subcomponent.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-move-subcomponent.rs b/tests/ui/borrowck/borrowck-move-subcomponent.rs
new file mode 100644
index 00000000000..38abd193222
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-move-subcomponent.rs
@@ -0,0 +1,17 @@
+// Tests that the borrow checker checks all components of a path when moving
+// out.
+
+
+
+struct S {
+  x : Box<isize>
+}
+
+fn f<T>(_: T) {}
+
+fn main() {
+  let a : S = S { x : Box::new(1) };
+  let pb = &a;
+  let S { x: ax } = a;  //~ ERROR cannot move out
+  f(pb);
+}