Closed
Description
I had code like
match e.kind {
EndOfFile => return Ok(()),
_ => return Err(()),
}
and got error: unreachable pattern
on the second pattern. I hadn't imported std::rt::io::EndOfFile
so rustc
interpreted EndOfFile
as a variable rather than an enum constructor.
Most Rust code follows the stylistic rule of capitalizing enum constructors and not capitalizing variables. So I think rustc
should warn when binding a capitalized variable in a match
— at least when it makes another pattern unreachable, but probably always.