From d22a3ca3e57dc5c28bfb161fc6a0d54856e0f486 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 16 Sep 2016 18:12:00 -0400 Subject: Improve the "bad literal" error message. Incidentally, this was done by using the Debug impl for `char` instead of the Display impl. Cute. Fixes #5. --- grep/src/lib.rs | 2 +- grep/src/nonl.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/grep/src/lib.rs b/grep/src/lib.rs index 68f95a4f..7526621d 100644 --- a/grep/src/lib.rs +++ b/grep/src/lib.rs @@ -62,7 +62,7 @@ impl fmt::Display for Error { match *self { Error::Regex(ref err) => err.fmt(f), Error::LiteralNotAllowed(chr) => { - write!(f, "Literal '{}' not allowed.", chr) + write!(f, "Literal {:?} not allowed.", chr) } Error::__Nonexhaustive => unreachable!(), } diff --git a/grep/src/nonl.rs b/grep/src/nonl.rs index e4dad13f..16fc103d 100644 --- a/grep/src/nonl.rs +++ b/grep/src/nonl.rs @@ -10,6 +10,10 @@ use {Error, Result}; /// If `byte` is not an ASCII character (i.e., greater than `0x7F`), then this /// function panics. pub fn remove(expr: Expr, byte: u8) -> Result { + // TODO(burntsushi): There is a bug in this routine where only `\n` is + // handled correctly. Namely, `AnyChar` and `AnyByte` need to be translated + // to proper character classes instead of the special `AnyCharNoNL` and + // `AnyByteNoNL` classes. use syntax::Expr::*; assert!(byte <= 0x7F); let chr = byte as char; -- cgit v1.2.3