diff options
| author | kennytm <kennytm@gmail.com> | 2018-10-18 10:47:27 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-10-18 12:54:59 +0800 |
| commit | bea91dcb697c989ee20a4713d3f2df2cbfc9c1a4 (patch) | |
| tree | 34118af43eeaa9acdae33db25194a78c7ba7b3b8 /src/test | |
| parent | 955016c79cce334e38305add31703bcf4baeb9d8 (diff) | |
| parent | 481ad0ea35afb795b04e2aba99c194d50a0ebe3f (diff) | |
| download | rust-bea91dcb697c989ee20a4713d3f2df2cbfc9c1a4.tar.gz rust-bea91dcb697c989ee20a4713d3f2df2cbfc9c1a4.zip | |
Rollup merge of #55090 - pnkfelix:issue-54597-regression-test, r=estebank
regression test for move out of borrow via pattern regression test for issue #54597. (We may have other tests that cover this, but I couldn't immediately find them associated with the PR that originally fixed the ICE here.)
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr | 12 |
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`. |
