]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0005.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0005.md
CommitLineData
60c5eb7d
XL
1Patterns used to bind names must be irrefutable, that is, they must guarantee
2that a name will be extracted in all cases.
3
4Erroneous code example:
5
6```compile_fail,E0005
7let x = Some(1);
8let Some(y) = x;
9// error: refutable pattern in local binding: `None` not covered
10```
11
12If you encounter this error you probably need to use a `match` or `if let` to
13deal with the possibility of failure. Example:
14
15```
16let x = Some(1);
17
18match x {
19 Some(y) => {
20 // do something
21 },
22 None => {}
23}
24
25// or:
26
27if let Some(y) = x {
28 // do something
29}
30```