about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2018-10-15 14:07:19 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-10-15 14:07:19 +0200
commit481ad0ea35afb795b04e2aba99c194d50a0ebe3f (patch)
tree73cc2fce0e6489bf20b480abef9d13a3632bac38 /src
parent0e07c4281c343e9e15a0a8fca79538ad1a8eb513 (diff)
downloadrust-481ad0ea35afb795b04e2aba99c194d50a0ebe3f.tar.gz
rust-481ad0ea35afb795b04e2aba99c194d50a0ebe3f.zip
regression test for issue #54597
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs22
-rw-r--r--src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr12
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs b/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs
new file mode 100644
index 00000000000..0749900986d
--- /dev/null
+++ b/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs
@@ -0,0 +1,22 @@
+#![feature(nll)]
+
+#![allow(dead_code)]
+
+#[derive(Debug)]
+struct Value;
+impl Value {
+    fn as_array(&self) -> Option<&Vec<Value>> {
+        None
+    }
+}
+
+fn foo(val: Value) {
+    let _reviewers_original: Vec<Value> = match val.as_array() {
+        Some(array) => {
+            *array
+        }
+        None => vec![]
+    };
+}
+
+fn main() { }
diff --git a/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr b/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr
new file mode 100644
index 00000000000..6a12016b2a5
--- /dev/null
+++ b/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr
@@ -0,0 +1,12 @@
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:16:13
+   |
+LL |             *array
+   |             ^^^^^^
+   |             |
+   |             cannot move out of borrowed content
+   |             help: consider removing the `*`: `array`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.