diff options
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0165.md')
-rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0165.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0165.md b/compiler/rustc_error_codes/src/error_codes/E0165.md new file mode 100644 index 000000000..7bcd6c0cb --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0165.md @@ -0,0 +1,27 @@ +#### Note: this error code is no longer emitted by the compiler. + +A `while let` pattern attempts to match the pattern, and enters the body if the +match was successful. If the match is irrefutable (when it cannot fail to +match), use a regular `let`-binding inside a `loop` instead. For instance: + +```no_run +struct Irrefutable(i32); +let irr = Irrefutable(0); + +// This fails to compile because the match is irrefutable. +while let Irrefutable(x) = irr { + // ... +} +``` + +Try this instead: + +```no_run +struct Irrefutable(i32); +let irr = Irrefutable(0); + +loop { + let Irrefutable(x) = irr; + // ... +} +``` |