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 @@ -153,6 +153,20 @@ match Some(()) {
153
153
}
154
154
"## ,
155
155
156
+ E0302 : r##"
157
+ Assignments are not allowed in pattern guards, because matching cannot have
158
+ side effects. Side effects could alter the matched object or the environment
159
+ on which the match depends in such a way, that the match would not be
160
+ exhaustive. For instance, the following would not match any arm if assignments
161
+ were allowed:
162
+
163
+ match Some(()) {
164
+ None => { },
165
+ option if { option = None; false } { },
166
+ Some(_) => { } // When the previous match failed, the option became `None`.
167
+ }
168
+ "## ,
169
+
156
170
E0303 : r##"
157
171
In certain cases it is possible for sub-bindings to violate memory safety.
158
172
Updates to the borrow checker in a future version of Rust may remove this
@@ -238,7 +252,6 @@ register_diagnostics! {
238
252
E0298 , // mismatched types between arms
239
253
E0299 , // mismatched types between arms
240
254
E0300 , // unexpanded macro
241
- E0302 , // cannot assign in a pattern guard
242
255
E0304 , // expected signed integer constant
243
256
E0305 , // expected constant
244
257
E0306 , // expected positive integer for repeat count
You can’t perform that action at this time.
0 commit comments