Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ criterion.workspace = true
indoc.workspace = true

[features]
regex = ["dep:regex-automata"]
default = [ "regex" ]
regex = ["dep:regex-automata"]
6 changes: 3 additions & 3 deletions engine/src/rhs_types/regex/imp_real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ pub struct Regex {
impl Regex {
/// Retrieves the syntax configuration that will be used to build the regex.
#[inline]
pub fn syntax_config() -> regex_automata::util::syntax::Config {
fn syntax_config() -> regex_automata::util::syntax::Config {
regex_automata::util::syntax::Config::new()
.unicode(false)
.utf8(false)
}

/// Retrieves the meta configuration that will be used to build the regex.
#[inline]
pub fn meta_config(settings: &ParserSettings) -> regex_automata::meta::Config {
fn meta_config(settings: &ParserSettings) -> regex_automata::meta::Config {
regex_automata::meta::Config::new()
.match_kind(MatchKind::LeftmostFirst)
.utf8_empty(false)
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Regex {
} else if let Some(syntax) = err.syntax_error() {
Error::Syntax(syntax.to_string())
} else {
unreachable!()
Error::Other(err.to_string())
}
})
}
Expand Down
16 changes: 5 additions & 11 deletions engine/src/rhs_types/regex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,15 @@ impl Serialize for Regex {
#[derive(Clone, Debug, Error, PartialEq)]
pub enum Error {
/// A syntax error.
#[error("{0}")]
Syntax(String),
/// The compiled regex exceeded the configured
/// regex compiled size limit.
#[error("Compiled regex exceeds size limit of {0} bytes.")]
CompiledTooBig(usize),
}

impl Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match *self {
Error::Syntax(ref err) => Display::fmt(err, f),
Error::CompiledTooBig(limit) => {
write!(f, "Compiled regex exceeds size limit of {} bytes.", limit)
}
}
}
/// An uncategorized error.
#[error("{0}")]
Other(String),
}

#[cfg(test)]
Expand Down
Loading