From 481ad0ea35afb795b04e2aba99c194d50a0ebe3f Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 15 Oct 2018 14:07:19 +0200 Subject: [PATCH] regression test for issue #54597 --- ...54597-reject-move-out-of-borrow-via-pat.rs | 22 +++++++++++++++++++ ...7-reject-move-out-of-borrow-via-pat.stderr | 12 ++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs create mode 100644 src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr 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 0000000000000..0749900986d2e --- /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> { + None + } +} + +fn foo(val: Value) { + let _reviewers_original: Vec = 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 0000000000000..6a12016b2a5e3 --- /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`.