Closed
Description
The code presented next reports:
$rustc test.rs
test.rs:19:5: 19:15 error: unreachable pattern [E0001]
test.rs:19 LitBool(_) => PLitBool
^~~~~~~~~~
test.rs:19:5: 19:15 help: pass `--explain E0001` to see a detailed explanation
error: aborting due to previous error
But this is wrong, the error is because LitNil
doesn't exist anymore. I guess the compiler should check that enum variants used in patterns exist before checking if they can be reached. The test.rs file code is:
#![feature(globs)]
extern crate syntax;
use syntax::ast::Lit_;
use syntax::ast::Lit_::*;
use LitTypePrinter::*;
pub fn lit_to_lit_printer(lit: &Lit_) -> LitTypePrinter
{
match *lit {
LitStr(_, _) => PLitStr,
LitBinary(_) => PLitBinary,
LitByte(_) => PLitByte,
LitChar(_) => PLitChar,
LitInt(_, _) => PLitInt,
LitFloat(_, _) => PLitFloat,
LitFloatUnsuffixed(_) => PLitFloatUnsuffixed,
LitNil => PLitNil,
LitBool(_) => PLitBool
}
}
pub enum LitTypePrinter
{
PLitStr,
PLitBinary,
PLitByte,
PLitChar,
PLitInt,
PLitFloat,
PLitFloatUnsuffixed,
PLitNil,
PLitBool
}
fn main() {
lit_to_lit_printer(&LitChar('a'));
}
Metadata
Metadata
Assignees
Labels
No labels