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.)
This commit is contained in:
kennytm 2018-10-18 10:47:27 +08:00
commit bea91dcb69
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
2 changed files with 34 additions and 0 deletions

View file

@ -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() { }

View file

@ -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`.