mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-14 00:58:43 +02:00
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.
This commit is contained in:
parent
e9ec52b7f9
commit
d22a3ca3e5
@ -62,7 +62,7 @@ impl fmt::Display for Error {
|
|||||||
match *self {
|
match *self {
|
||||||
Error::Regex(ref err) => err.fmt(f),
|
Error::Regex(ref err) => err.fmt(f),
|
||||||
Error::LiteralNotAllowed(chr) => {
|
Error::LiteralNotAllowed(chr) => {
|
||||||
write!(f, "Literal '{}' not allowed.", chr)
|
write!(f, "Literal {:?} not allowed.", chr)
|
||||||
}
|
}
|
||||||
Error::__Nonexhaustive => unreachable!(),
|
Error::__Nonexhaustive => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,10 @@ use {Error, Result};
|
|||||||
/// If `byte` is not an ASCII character (i.e., greater than `0x7F`), then this
|
/// If `byte` is not an ASCII character (i.e., greater than `0x7F`), then this
|
||||||
/// function panics.
|
/// function panics.
|
||||||
pub fn remove(expr: Expr, byte: u8) -> Result<Expr> {
|
pub fn remove(expr: Expr, byte: u8) -> Result<Expr> {
|
||||||
|
// 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::*;
|
use syntax::Expr::*;
|
||||||
assert!(byte <= 0x7F);
|
assert!(byte <= 0x7F);
|
||||||
let chr = byte as char;
|
let chr = byte as char;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user