]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0162.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0162.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 An if-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 instead. For instance:
6
7 ```
8 struct Irrefutable(i32);
9 let irr = Irrefutable(0);
10
11 // This fails to compile because the match is irrefutable.
12 if let Irrefutable(x) = irr {
13     // This body will always be executed.
14     // ...
15 }
16 ```
17
18 Try this instead:
19
20 ```
21 struct Irrefutable(i32);
22 let irr = Irrefutable(0);
23
24 let Irrefutable(x) = irr;
25 println!("{}", x);
26 ```