Closed
Description
When the enum variants listed in a match
block omit the preceding EnumName::
the compiler may still accept the code, even if some cases were not handled or nonexistent variants are listed.
I tried this code:
enum Enum {
A,
B,
C,
}
fn main() {
let b = Enum::B;
match b {
A => println!("A"),
B => println!("B"),
Foo => {},
}
}
I expected to see this happen: Compiler errors regarding missing Enum::
, missing variant Enum::C
, and invalid variant.
Instead, this happened: the code compiled and printed "A"
Meta
rustc --version --verbose
:
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: aarch64-apple-darwin
release: 1.64.0
LLVM version: 14.0.6
Also tested with rustc 1.66.0-nightly (f83e0266c 2022-10-03)