summaryrefslogtreecommitdiffstats
path: root/vendor/regex-automata/src/hybrid/error.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/regex-automata/src/hybrid/error.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/regex-automata/src/hybrid/error.rs')
-rw-r--r--vendor/regex-automata/src/hybrid/error.rs35
1 files changed, 22 insertions, 13 deletions
diff --git a/vendor/regex-automata/src/hybrid/error.rs b/vendor/regex-automata/src/hybrid/error.rs
index 715da39bd..604daf3c3 100644
--- a/vendor/regex-automata/src/hybrid/error.rs
+++ b/vendor/regex-automata/src/hybrid/error.rs
@@ -7,6 +7,16 @@ use crate::{hybrid::id::LazyStateIDError, nfa};
/// to build a lazy DFA without heuristic Unicode support but with an NFA that
/// contains a Unicode word boundary.)
///
+/// This error does not provide many introspection capabilities. There are
+/// generally only two things you can do with it:
+///
+/// * Obtain a human readable message via its `std::fmt::Display` impl.
+/// * Access an underlying
+/// [`nfa::thompson::BuildError`](crate::nfa::thompson::BuildError)
+/// type from its `source` method via the `std::error::Error` trait. This error
+/// only occurs when using convenience routines for building a lazy DFA
+/// directly from a pattern string.
+///
/// When the `std` feature is enabled, this implements the `std::error::Error`
/// trait.
#[derive(Clone, Debug)]
@@ -16,18 +26,14 @@ pub struct BuildError {
#[derive(Clone, Debug)]
enum BuildErrorKind {
- NFA(nfa::thompson::Error),
+ NFA(nfa::thompson::BuildError),
InsufficientCacheCapacity { minimum: usize, given: usize },
InsufficientStateIDCapacity { err: LazyStateIDError },
Unsupported(&'static str),
}
impl BuildError {
- fn kind(&self) -> &BuildErrorKind {
- &self.kind
- }
-
- pub(crate) fn nfa(err: nfa::thompson::Error) -> BuildError {
+ pub(crate) fn nfa(err: nfa::thompson::BuildError) -> BuildError {
BuildError { kind: BuildErrorKind::NFA(err) }
}
@@ -60,19 +66,16 @@ impl BuildError {
#[cfg(feature = "std")]
impl std::error::Error for BuildError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- match self.kind() {
+ match self.kind {
BuildErrorKind::NFA(ref err) => Some(err),
- BuildErrorKind::InsufficientCacheCapacity { .. } => None,
- // LazyStateIDError is an implementation detail, don't expose it.
- BuildErrorKind::InsufficientStateIDCapacity { .. } => None,
- BuildErrorKind::Unsupported(_) => None,
+ _ => None,
}
}
}
impl core::fmt::Display for BuildError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
- match self.kind() {
+ match self.kind {
BuildErrorKind::NFA(_) => write!(f, "error building NFA"),
BuildErrorKind::InsufficientCacheCapacity { minimum, given } => {
write!(
@@ -103,7 +106,9 @@ impl core::fmt::Display for BuildError {
/// The default configuration of a lazy DFA in this crate is
/// set such that a `CacheError` will never occur. Instead,
/// callers must opt into this behavior with settings like
-/// [`dfa::Config::minimum_cache_clear_count`](crate::hybrid::dfa::Config::minimum_cache_clear_count).
+/// [`dfa::Config::minimum_cache_clear_count`](crate::hybrid::dfa::Config::minimum_cache_clear_count)
+/// and
+/// [`dfa::Config::minimum_bytes_per_state`](crate::hybrid::dfa::Config::minimum_bytes_per_state).
///
/// When the `std` feature is enabled, this implements the `std::error::Error`
/// trait.
@@ -114,6 +119,10 @@ impl CacheError {
pub(crate) fn too_many_cache_clears() -> CacheError {
CacheError(())
}
+
+ pub(crate) fn bad_efficiency() -> CacheError {
+ CacheError(())
+ }
}
#[cfg(feature = "std")]