File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,33 @@ reference when using guards or refactor the entire expression, perhaps by
112
112
putting the condition inside the body of the arm.
113
113
"## ,
114
114
115
+ E0297 : r##"
116
+ Patterns used to bind names must be irrefutable. That is, they must guarantee
117
+ that a name will be extracted in all cases. Instead of pattern matching the
118
+ loop variable, consider using a `match` or `if let` inside the loop body. For
119
+ instance:
120
+
121
+ // This fails because `None` is not covered.
122
+ for Some(x) in xs {
123
+ ...
124
+ }
125
+
126
+ // Match inside the loop instead:
127
+ for item in xs {
128
+ match item {
129
+ Some(x) => ...
130
+ None => ...
131
+ }
132
+ }
133
+
134
+ // Or use `if let`:
135
+ for item in xs {
136
+ if let Some(x) = item {
137
+ ...
138
+ }
139
+ }
140
+ "## ,
141
+
115
142
E0303 : r##"
116
143
In certain cases it is possible for sub-bindings to violate memory safety.
117
144
Updates to the borrow checker in a future version of Rust may remove this
@@ -194,7 +221,6 @@ register_diagnostics! {
194
221
E0284 , // cannot resolve type
195
222
E0285 , // overflow evaluation builtin bounds
196
223
E0296 , // malformed recursion limit attribute
197
- E0297 , // refutable pattern in for loop binding
198
224
E0298 , // mismatched types between arms
199
225
E0299 , // mismatched types between arms
200
226
E0300 , // unexpanded macro
You can’t perform that action at this time.
0 commit comments