]> git.proxmox.com Git - rustc.git/blob - tests/ui/borrowck/borrowck-pat-reassign-binding.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / borrowck / borrowck-pat-reassign-binding.rs
1 fn main() {
2 let mut x: Option<isize> = None;
3 match x {
4 None => {
5 // Note: on this branch, no borrow has occurred.
6 x = Some(0);
7 }
8 Some(ref i) => {
9 // But on this branch, `i` is an outstanding borrow
10 x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed
11 drop(i);
12 }
13 }
14 x.clone(); // just to prevent liveness warnings
15 }