]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-lend-flow-match.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / borrowck / borrowck-lend-flow-match.rs
1 fn separate_arms() {
2     // Here both arms perform assignments, but only one is illegal.
3
4     let mut x = None;
5     match x {
6         None => {
7             // It is ok to reassign x here, because there is in
8             // fact no outstanding loan of x!
9             x = Some(0);
10         }
11         Some(ref r) => {
12             x = Some(1); //~ ERROR cannot assign to `x` because it is borrowed
13             drop(r);
14         }
15     }
16 }
17
18 fn main() {}