]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0301.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0301.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 Mutable borrows are not allowed in pattern guards, because matching cannot have
4 side effects. Side effects could alter the matched object or the environment
5 on which the match depends in such a way, that the match would not be
6 exhaustive. For instance, the following would not match any arm if mutable
7 borrows were allowed:
8
9 ```compile_fail,E0596
10 match Some(()) {
11     None => { },
12     option if option.take().is_none() => {
13         /* impossible, option is `Some` */
14     },
15     Some(_) => { } // When the previous match failed, the option became `None`.
16 }
17 ```