]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-pat-reassign-binding.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.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 }