]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_error_codes/src/error_codes/E0165.md
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_error_codes / src / error_codes / E0165.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 A while-let pattern attempts to match the pattern, and enters the body if the
4 match was successful. If the match is irrefutable (when it cannot fail to
5 match), use a regular `let`-binding inside a `loop` instead. For instance:
6
7 ```no_run
8 struct Irrefutable(i32);
9 let irr = Irrefutable(0);
10
11 // This fails to compile because the match is irrefutable.
12 while let Irrefutable(x) = irr {
13 // ...
14 }
15 ```
16
17 Try this instead:
18
19 ```no_run
20 struct Irrefutable(i32);
21 let irr = Irrefutable(0);
22
23 loop {
24 let Irrefutable(x) = irr;
25 // ...
26 }
27 ```