diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs new file mode 100644 index 000000000..9b8ba2ea8 --- /dev/null +++ b/tests/ui/borrowck/borrowck-vec-pattern-move-tail.rs @@ -0,0 +1,11 @@ +fn main() { + let mut a = [1, 2, 3, 4]; + let t = match a { + [1, 2, ref tail @ ..] => tail, + _ => unreachable!() + }; + println!("t[0]: {}", t[0]); + a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed + println!("t[0]: {}", t[0]); + t[0]; +} |