Skip to content

Commit 16ca628

Browse files
committed
Migrate to edition 2024
1 parent 461ee4e commit 16ca628

File tree

17 files changed

+102
-96
lines changed

17 files changed

+102
-96
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/src/ast/field_expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'s> Expr<'s> for ComparisonExpr<'s> {
425425
let lhs = self.lhs;
426426

427427
macro_rules! cast_value {
428-
($value:expr, $ty:ident) => {
428+
($value:expr_2021, $ty:ident) => {
429429
match $value {
430430
LhsValue::$ty(value) => value,
431431
_ => unreachable!(),
@@ -482,7 +482,7 @@ impl<'s> Expr<'s> for ComparisonExpr<'s> {
482482
}),
483483
ComparisonOpExpr::Contains(bytes) => {
484484
macro_rules! search {
485-
($searcher:expr) => {{
485+
($searcher:expr_2021) => {{
486486
let searcher = $searcher;
487487
lhs.compile_with(compiler, false, move |x, _ctx| {
488488
searcher.search_in(cast_value!(x, Bytes).as_ref())

engine/src/ast/function_expr.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ impl<'i, 's> LexWith<'i, &FilterParser<'s>> for FunctionCallArgExpr<'s> {
115115

116116
macro_rules! c_is_field {
117117
// characters above F/f in the alphabet mean it can't be a decimal or hex int
118-
($c:expr) => {
118+
($c:expr_2021) => {
119119
(($c.is_ascii_alphanumeric() && !$c.is_ascii_hexdigit()) || $c == '_')
120120
};
121121
}
122122

123123
macro_rules! c_is_field_or_int {
124-
($c:expr) => {
124+
($c:expr_2021) => {
125125
($c.is_ascii_alphanumeric() || $c == '_')
126126
};
127127
}
@@ -343,11 +343,12 @@ impl<'s> ValueExpr<'s> for FunctionCallExpr<'s> {
343343
}
344344
} else {
345345
CompiledValueExpr::new(move |ctx| {
346-
if let Some(value) = call(&mut args.iter().map(|arg| arg.execute(ctx))) {
347-
debug_assert!(value.get_type() == return_type);
348-
Ok(value)
349-
} else {
350-
Err(return_type)
346+
match call(&mut args.iter().map(|arg| arg.execute(ctx))) {
347+
Some(value) => {
348+
debug_assert!(value.get_type() == return_type);
349+
Ok(value)
350+
}
351+
_ => Err(return_type),
351352
}
352353
})
353354
}

engine/src/ast/index_expr.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,13 @@ impl<'s> IndexExpr<'s> {
280280
let call = compiler.compile_function_call_expr(call);
281281
CompiledVecExpr::new(move |ctx| {
282282
let mut iter = MapEachIterator::from_indexes(&indexes[..]);
283-
if let Ok(val) = call.execute(ctx) {
284-
iter.reset(val);
285-
} else {
286-
return TypedArray::default();
283+
match call.execute(ctx) {
284+
Ok(val) => {
285+
iter.reset(val);
286+
}
287+
_ => {
288+
return TypedArray::default();
289+
}
287290
}
288291

289292
TypedArray::from_iter(iter.map(|item| func(&item, ctx)))

engine/src/ast/logical_expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub enum LogicalExpr<'s> {
6969
impl GetType for LogicalExpr<'_> {
7070
fn get_type(&self) -> Type {
7171
match &self {
72-
LogicalExpr::Combining { ref items, .. } => items[0].get_type(),
72+
LogicalExpr::Combining { items, .. } => items[0].get_type(),
7373
LogicalExpr::Comparison(comparison) => comparison.get_type(),
7474
LogicalExpr::Parenthesized(parenthesized) => parenthesized.expr.get_type(),
7575
LogicalExpr::Unary { arg, .. } => arg.get_type(),

engine/src/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl<'a> FunctionParam<'a> {
193193
/// Returns the underlying type if the current parameter is a variable, otherwise an error.
194194
pub fn as_variable(&self) -> Result<&Type, FunctionArgKindMismatchError> {
195195
match self {
196-
Self::Variable(ref ty) => Ok(ty),
196+
Self::Variable(ty) => Ok(ty),
197197
Self::Constant(_) => Err(FunctionArgKindMismatchError {
198198
expected: FunctionArgKind::Field,
199199
actual: FunctionArgKind::Literal,

engine/src/lex.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ macro_rules! lex_enum {
227227
// On the parser side, tries to parse either of the given string values,
228228
// and returns the variant if any of them succeeded.
229229
(@decl $preamble:tt $name:ident $input:ident { $($decl:tt)* } { $($expr:tt)* } {
230-
$(#[$meta:meta])* $($s:literal)|+ => $item:ident $(= $value:expr)*,
230+
$(#[$meta:meta])* $($s:literal)|+ => $item:ident $(= $value:expr_2021)*,
231231
$($rest:tt)*
232232
}) => {
233233
lex_enum!(@decl $preamble $name $input {
@@ -324,27 +324,27 @@ pub fn complete<T>(res: LexResult<'_, T>) -> Result<T, LexError<'_>> {
324324

325325
#[cfg(test)]
326326
macro_rules! assert_ok {
327-
($s:expr, $res:expr, $rest:expr) => {{
327+
($s:expr_2021, $res:expr_2021, $rest:expr_2021) => {{
328328
let expr = $s.unwrap();
329329
assert_eq!(expr, ($res, $rest));
330330
expr.0
331331
}};
332332

333-
($s:expr, $res:expr) => {
333+
($s:expr_2021, $res:expr_2021) => {
334334
assert_ok!($s, $res, "")
335335
};
336336
}
337337

338338
#[cfg(test)]
339339
macro_rules! assert_err {
340-
($s:expr, $kind:expr, $span:expr) => {
340+
($s:expr_2021, $kind:expr_2021, $span:expr_2021) => {
341341
assert_eq!($s, Err(($kind, $span)))
342342
};
343343
}
344344

345345
#[cfg(test)]
346346
macro_rules! assert_json {
347-
($expr:expr, $json:tt) => {{
347+
($expr:expr_2021, $json:tt) => {{
348348
let json = ::serde_json::to_value(&$expr).unwrap();
349349
assert_eq!(json, ::serde_json::json!($json));
350350
json

engine/src/lhs_types/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ impl<'a, 'b> ArrayMut<'a, 'b> {
470470
/// Get a mutable reference to an element if it exists
471471
#[inline]
472472
pub fn get_mut(&'a mut self, idx: usize) -> Option<LhsValueMut<'a, 'b>> {
473-
self.0.get_mut(idx).map(LhsValueMut::from)
473+
self.0.get_mut(idx)
474474
}
475475
}
476476

engine/src/lhs_types/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'a, 'b> MapMut<'a, 'b> {
444444
/// Get a mutable reference to an element if it exists
445445
#[inline]
446446
pub fn get_mut(&'a mut self, key: &[u8]) -> Option<LhsValueMut<'a, 'b>> {
447-
self.0.get_mut(key).map(LhsValueMut::from)
447+
self.0.get_mut(key)
448448
}
449449

450450
/// Inserts an element, overwriting if one already exists

engine/src/rhs_types/ip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ impl Lex<'_> for IpRange {
105105
}
106106

107107
macro_rules! impl_ip_range_from {
108-
(@single $v:ident, |$input:ident: $ty:ty| $transform:expr) => {
108+
(@single $v:ident, |$input:ident: $ty:ty| $transform:expr_2021) => {
109109
impl From<$ty> for ExplicitIpRange {
110110
fn from($input: $ty) -> Self {
111111
ExplicitIpRange::$v($transform)
112112
}
113113
}
114114
};
115115

116-
($ty:ident { $v4:ty, $v6:ty }, |$input:ident| $transform:expr) => {
116+
($ty:ident { $v4:ty, $v6:ty }, |$input:ident| $transform:expr_2021) => {
117117
impl_ip_range_from!(@single V4, |$input: $v4| $transform);
118118
impl_ip_range_from!(@single V6, |$input: $v6| $transform);
119119

0 commit comments

Comments
 (0)