Open Jeremiah-Griffin opened 2 years ago
The errors emitted look correct, but your second example's diagnostic output is incomplete.
(previous_chr.unwrap(), current_chr)
evaluates to a (char, char)
, which is then matched against. So, exhaustiveness checks are done on the range of characters, rather than Option<char>
's possible Some(_)
and None
.(previous_chr, current_chr)
is a (Option<char>, char)
, so both Some(_)
and None
must be accounted for. Though, the recommendation to fix it is incomplete because following the instructions will result in another exhaustiveness error, since not all characters are covered by the current Some
option.I could see addressing all possibilities for every combination of types and nested types becoming very unwieldy and difficult to read, though.
@rustbot label A-diagnostics
When matching against a tuple, if one of the values is an
Option<char>
, unwrapping it in the match statement itself provides a garbled error message from the compiler.previous_chr is of type
Option<char>
current_chr if of typechar
I would expect a typical error message stating that the None case for the optional value is not covered. Instead, this message is returned by the compiler:
Changing the code to the following...
...produces the expected message:
rust version:
rustc 1.64.0-nightly (4493a0f47 2022-08-02) binary: rustc commit-hash: 4493a0f4724c0bae1436242d76cccc9c0a287b80 commit-date: 2022-08-02 host: x86_64-pc-windows-msvc release: 1.64.0-nightly LLVM version: 14.0.6
There is no panic and no backtrace is emitted.