diff options
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0005.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0005.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0005.md b/compiler/rustc_error_codes/src/error_codes/E0005.md new file mode 100644 index 000000000..e2e7db508 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0005.md @@ -0,0 +1,30 @@ +Patterns used to bind names must be irrefutable, that is, they must guarantee +that a name will be extracted in all cases. + +Erroneous code example: + +```compile_fail,E0005 +let x = Some(1); +let Some(y) = x; +// error: refutable pattern in local binding: `None` not covered +``` + +If you encounter this error you probably need to use a `match` or `if let` to +deal with the possibility of failure. Example: + +``` +let x = Some(1); + +match x { + Some(y) => { + // do something + }, + None => {} +} + +// or: + +if let Some(y) = x { + // do something +} +``` |