mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-19 09:02:15 +02:00
globset: make ErrorKind enum extensible
This commit makes the ErrorKind enum extensible by adding a __Nonexhaustive variant. Callers should use this as a hint that exhaustive case analysis isn't possible in a stable way since new variants may be added in the future without a semver bump.
This commit is contained in:
parent
e2516ed095
commit
54256515b4
@ -163,6 +163,13 @@ pub enum ErrorKind {
|
|||||||
DanglingEscape,
|
DanglingEscape,
|
||||||
/// An error associated with parsing or compiling a regex.
|
/// An error associated with parsing or compiling a regex.
|
||||||
Regex(String),
|
Regex(String),
|
||||||
|
/// Hints that destructuring should not be exhaustive.
|
||||||
|
///
|
||||||
|
/// This enum may grow additional variants, so this makes sure clients
|
||||||
|
/// don't count on exhaustive matching. (Otherwise, adding a new variant
|
||||||
|
/// could break existing code.)
|
||||||
|
#[doc(hidden)]
|
||||||
|
__Nonexhaustive,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StdError for Error {
|
impl StdError for Error {
|
||||||
@ -210,6 +217,7 @@ impl ErrorKind {
|
|||||||
"dangling '\\'"
|
"dangling '\\'"
|
||||||
}
|
}
|
||||||
ErrorKind::Regex(ref err) => err,
|
ErrorKind::Regex(ref err) => err,
|
||||||
|
ErrorKind::__Nonexhaustive => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,6 +248,7 @@ impl fmt::Display for ErrorKind {
|
|||||||
ErrorKind::InvalidRange(s, e) => {
|
ErrorKind::InvalidRange(s, e) => {
|
||||||
write!(f, "invalid range; '{}' > '{}'", s, e)
|
write!(f, "invalid range; '{}' > '{}'", s, e)
|
||||||
}
|
}
|
||||||
|
ErrorKind::__Nonexhaustive => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user