File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,20 @@ for item in xs {
139
139
}
140
140
"## ,
141
141
142
+ E0301 : r##"
143
+ Mutable borrows are not allowed in pattern guards, because matching cannot have
144
+ side effects. Side effects could alter the matched object or the environment
145
+ on which the match depends in such a way, that the match would not be
146
+ exhaustive. For instance, the following would not match any arm if mutable
147
+ borrows were allowed:
148
+
149
+ match Some(()) {
150
+ None => { },
151
+ option if option.take().is_none() => { /* impossible, option is `Some` */ },
152
+ Some(_) => { } // When the previous match failed, the option became `None`.
153
+ }
154
+ "## ,
155
+
142
156
E0303 : r##"
143
157
In certain cases it is possible for sub-bindings to violate memory safety.
144
158
Updates to the borrow checker in a future version of Rust may remove this
@@ -224,7 +238,6 @@ register_diagnostics! {
224
238
E0298 , // mismatched types between arms
225
239
E0299 , // mismatched types between arms
226
240
E0300 , // unexpanded macro
227
- E0301 , // cannot mutable borrow in a pattern guard
228
241
E0302 , // cannot assign in a pattern guard
229
242
E0304 , // expected signed integer constant
230
243
E0305 , // expected constant
You can’t perform that action at this time.
0 commit comments