]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0510.md
Auto merge of #68154 - ssomers:btreemap_navigation_benches, r=Mark-Simulacrum
[rust.git] / src / librustc_error_codes / error_codes / E0510.md
1 Cannot mutate place in this match guard.
2
3 When matching on a variable it cannot be mutated in the match guards, as this
4 could cause the match to be non-exhaustive:
5
6 ```compile_fail,E0510
7 let mut x = Some(0);
8 match x {
9     None => (),
10     Some(_) if { x = None; false } => (),
11     Some(v) => (), // No longer matches
12 }
13 ```
14
15 Here executing `x = None` would modify the value being matched and require us
16 to go "back in time" to the `None` arm.