]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / borrowck / borrowck-vec-pattern-move-tail.rs
1 // http://rust-lang.org/COPYRIGHT.
2 //
3
4 // revisions: ast cmp
5 //[cmp]compile-flags: -Z borrowck=compare
6
7 #![feature(slice_patterns)]
8
9 fn main() {
10     let mut a = [1, 2, 3, 4];
11     let t = match a {
12         [1, 2, ref tail..] => tail,
13         _ => unreachable!()
14     };
15     println!("t[0]: {}", t[0]);
16     a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
17               //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast)
18               //[cmp]~| ERROR cannot assign to `a[_]` because it is borrowed (Mir)
19     println!("t[0]: {}", t[0]);
20     t[0];
21 }