File tree 1 file changed +20
-1
lines changed 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,26 @@ let Irrefutable(x) = irr;
131
131
foo(x);
132
132
"## ,
133
133
134
+ E0165 : r##"
135
+ A while-let pattern attempts to match the pattern, and enters the body if the
136
+ match was succesful. If the match is irrefutable (when it cannot fail to match),
137
+ use a regular `let`-binding inside a `loop` instead. For instance:
138
+
139
+ struct Irrefutable(i32);
140
+ let irr = Irrefutable(0);
141
+
142
+ // This fails to compile because the match is irrefutable.
143
+ while let Irrefutable(x) = irr {
144
+ ...
145
+ }
146
+
147
+ // Try this instead:
148
+ loop {
149
+ let Irrefutable(x) = irr;
150
+ ...
151
+ }
152
+ "## ,
153
+
134
154
E0297 : r##"
135
155
Patterns used to bind names must be irrefutable. That is, they must guarantee
136
156
that a name will be extracted in all cases. Instead of pattern matching the
@@ -239,7 +259,6 @@ register_diagnostics! {
239
259
E0152 ,
240
260
E0158 ,
241
261
E0161 ,
242
- E0165 ,
243
262
E0170 ,
244
263
E0261 , // use of undeclared lifetime name
245
264
E0262 , // illegal lifetime parameter name
You can’t perform that action at this time.
0 commit comments