diff options
Diffstat (limited to 'tests/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs')
-rw-r--r-- | tests/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs b/tests/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs new file mode 100644 index 000000000..3e46ee6f0 --- /dev/null +++ b/tests/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs @@ -0,0 +1,20 @@ +#![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 //~ ERROR cannot move out of `*array` + } + None => vec![] + }; +} + +fn main() { } |