diff --git a/src/common/src/types/decimal.rs b/src/common/src/types/decimal.rs index 9cf8af19e7054..0d4c1ab30ac00 100644 --- a/src/common/src/types/decimal.rs +++ b/src/common/src/types/decimal.rs @@ -410,7 +410,9 @@ impl Decimal { pub const MAX_PRECISION: u8 = 28; pub fn scale(&self) -> Option { - let Decimal::Normalized(d) = self else { return None }; + let Decimal::Normalized(d) = self else { + return None; + }; Some(d.scale() as _) } @@ -428,7 +430,9 @@ impl Decimal { /// Round to the left of the decimal point, for example `31.5` -> `30`. #[must_use] pub fn round_left_ties_away(&self, left: u32) -> Option { - let Self::Normalized(mut d) = self else { return Some(*self) }; + let Self::Normalized(mut d) = self else { + return Some(*self); + }; // First, move the decimal point to the left so that we can reuse `round`. This is more // efficient than division. diff --git a/src/expr/macro/src/parse.rs b/src/expr/macro/src/parse.rs index 7c5c7c0cbb24e..066705f410601 100644 --- a/src/expr/macro/src/parse.rs +++ b/src/expr/macro/src/parse.rs @@ -113,7 +113,9 @@ impl Parse for UserFunctionAttr { /// Check if the last argument is `&mut dyn Write`. fn last_arg_is_write(sig: &syn::Signature) -> bool { - let Some(syn::FnArg::Typed(arg)) = sig.inputs.last() else { return false }; + let Some(syn::FnArg::Typed(arg)) = sig.inputs.last() else { + return false; + }; let syn::Type::Reference(syn::TypeReference { elem, .. }) = arg.ty.as_ref() else { return false; }; @@ -128,8 +130,12 @@ fn last_arg_is_write(sig: &syn::Signature) -> bool { /// Check if the last argument is `retract: bool`. fn last_arg_is_retract(sig: &syn::Signature) -> bool { - let Some(syn::FnArg::Typed(arg)) = sig.inputs.last() else { return false }; - let syn::Pat::Ident(pat) = &*arg.pat else { return false }; + let Some(syn::FnArg::Typed(arg)) = sig.inputs.last() else { + return false; + }; + let syn::Pat::Ident(pat) = &*arg.pat else { + return false; + }; pat.ident.to_string().contains("retract") } @@ -139,9 +145,15 @@ fn args_contain_option(sig: &syn::Signature) -> bool { return false; } for arg in &sig.inputs { - let syn::FnArg::Typed(arg) = arg else { return false }; - let syn::Type::Path(path) = arg.ty.as_ref() else { return false }; - let Some(seg) = path.path.segments.last() else { return false }; + let syn::FnArg::Typed(arg) = arg else { + return false; + }; + let syn::Type::Path(path) = arg.ty.as_ref() else { + return false; + }; + let Some(seg) = path.path.segments.last() else { + return false; + }; if seg.ident == "Option" { return true; } @@ -168,20 +180,32 @@ fn check_type(ty: &syn::Type) -> (ReturnType, &syn::Type) { /// Check if the type is `type_` and return `T`. fn strip_outer_type<'a>(ty: &'a syn::Type, type_: &str) -> Option<&'a syn::Type> { - let syn::Type::Path(path) = ty else { return None }; - let Some(seg) = path.path.segments.last() else { return None }; + let syn::Type::Path(path) = ty else { + return None; + }; + let Some(seg) = path.path.segments.last() else { + return None; + }; if seg.ident != type_ { return None; } - let syn::PathArguments::AngleBracketed(args) = &seg.arguments else { return None }; - let Some(syn::GenericArgument::Type(ty)) = args.args.first() else { return None }; + let syn::PathArguments::AngleBracketed(args) = &seg.arguments else { + return None; + }; + let Some(syn::GenericArgument::Type(ty)) = args.args.first() else { + return None; + }; Some(ty) } /// Check if the type is `impl Iterator` and return `T`. fn strip_iterator(ty: &syn::Type) -> Option<&syn::Type> { - let syn::Type::ImplTrait(impl_trait) = ty else { return None; }; - let syn::TypeParamBound::Trait(trait_bound) = impl_trait.bounds.first()? else { return None; }; + let syn::Type::ImplTrait(impl_trait) = ty else { + return None; + }; + let syn::TypeParamBound::Trait(trait_bound) = impl_trait.bounds.first()? else { + return None; + }; let segment = trait_bound.path.segments.last().unwrap(); if segment.ident != "Iterator" { return None; diff --git a/src/expr/src/agg/string_agg.rs b/src/expr/src/agg/string_agg.rs index f15d15156712d..8633fd5ec0613 100644 --- a/src/expr/src/agg/string_agg.rs +++ b/src/expr/src/agg/string_agg.rs @@ -22,7 +22,9 @@ fn string_agg( delimiter: Option<&str>, ) -> Option { let Some(value) = value else { return state }; - let Some(mut state) = state else { return Some(value.into()) }; + let Some(mut state) = state else { + return Some(value.into()); + }; state += delimiter.unwrap_or(""); state += value; Some(state) diff --git a/src/expr/src/expr/expr_some_all.rs b/src/expr/src/expr/expr_some_all.rs index 185a53e1ffebb..8b47df11343f3 100644 --- a/src/expr/src/expr/expr_some_all.rs +++ b/src/expr/src/expr/expr_some_all.rs @@ -88,7 +88,9 @@ impl Expression for SomeAllExpression { let mut num_array = Vec::with_capacity(data_chunk.capacity()); let arr_right_inner = arr_right.as_list(); - let DataType::List(datatype) = arr_right_inner.data_type() else { unreachable!() }; + let DataType::List(datatype) = arr_right_inner.data_type() else { + unreachable!() + }; let capacity = arr_right_inner .iter() .flatten() diff --git a/src/frontend/src/binder/expr/function.rs b/src/frontend/src/binder/expr/function.rs index cfb0c615d3d63..e778e3aaeaff1 100644 --- a/src/frontend/src/binder/expr/function.rs +++ b/src/frontend/src/binder/expr/function.rs @@ -1111,19 +1111,22 @@ impl Binder { fn rewrite_format_to_concat_ws(inputs: Vec) -> Result> { let Some((format_expr, args)) = inputs.split_first() else { - return Err( - ErrorCode::BindError("Function `format` takes at least 1 arguments (0 given)".to_string()).into(), - ); + return Err(ErrorCode::BindError( + "Function `format` takes at least 1 arguments (0 given)".to_string(), + ) + .into()); }; let ExprImpl::Literal(expr_literal) = format_expr else { - return Err( - ErrorCode::BindError("Function `format` takes a literal string as the first argument".to_string()).into(), - ); + return Err(ErrorCode::BindError( + "Function `format` takes a literal string as the first argument".to_string(), + ) + .into()); }; let Some(ScalarImpl::Utf8(format_str)) = expr_literal.get_data() else { - return Err( - ErrorCode::BindError("Function `format` takes a literal string as the first argument".to_string()).into(), - ); + return Err(ErrorCode::BindError( + "Function `format` takes a literal string as the first argument".to_string(), + ) + .into()); }; let formatter = Formatter::parse(format_str) .map_err(|err| -> RwError { ErrorCode::BindError(err.to_string()).into() })?; diff --git a/src/frontend/src/expr/type_inference/func.rs b/src/frontend/src/expr/type_inference/func.rs index 72363fc39dd85..58f5115876813 100644 --- a/src/frontend/src/expr/type_inference/func.rs +++ b/src/frontend/src/expr/type_inference/func.rs @@ -863,7 +863,9 @@ fn narrow_category<'a>( .all(|(formal, category)| { // category.is_none() means the actual argument is non-null and skipped category // selection. - let Some(selected) = category else { return true }; + let Some(selected) = category else { + return true; + }; *formal == *selected || !is_preferred(*selected) && implicit_ok(*formal, *selected, false) }) diff --git a/src/frontend/src/handler/create_table.rs b/src/frontend/src/handler/create_table.rs index ff876b1b6f23f..49f57febe47a8 100644 --- a/src/frontend/src/handler/create_table.rs +++ b/src/frontend/src/handler/create_table.rs @@ -893,7 +893,8 @@ mod tests { columns: column_defs, constraints, .. - } = ast.remove(0) else { + } = ast.remove(0) + else { panic!("test case should be create table") }; let actual: Result<_> = (|| { diff --git a/src/frontend/src/optimizer/rule/push_calculation_of_join_rule.rs b/src/frontend/src/optimizer/rule/push_calculation_of_join_rule.rs index a8f4cd02037f3..ce5004b069a31 100644 --- a/src/frontend/src/optimizer/rule/push_calculation_of_join_rule.rs +++ b/src/frontend/src/optimizer/rule/push_calculation_of_join_rule.rs @@ -161,7 +161,9 @@ impl PushCalculationOfJoinRule { ) }; for (index, expr) in exprs.iter().enumerate() { - let ExprImpl::FunctionCall(func) = expr else { continue }; + let ExprImpl::FunctionCall(func) = expr else { + continue; + }; if !is_comparison_type(func.func_type()) { continue; } diff --git a/src/frontend/src/utils/condition.rs b/src/frontend/src/utils/condition.rs index 1c7b31558b6bb..57910083dfbaf 100644 --- a/src/frontend/src/utils/condition.rs +++ b/src/frontend/src/utils/condition.rs @@ -403,9 +403,13 @@ impl Condition { )); } - let Some((lower_bound_conjunctions,upper_bound_conjunctions,eq_conds,part_of_other_conds)) = Self::analyze_group( - group, - )? else { + let Some(( + lower_bound_conjunctions, + upper_bound_conjunctions, + eq_conds, + part_of_other_conds, + )) = Self::analyze_group(group)? + else { return Ok(false_cond()); }; other_conds.extend(part_of_other_conds.into_iter()); @@ -561,9 +565,9 @@ impl Condition { }; let Some(new_cond) = new_expr.fold_const()? else { - // column = NULL, the result is always NULL. - return Ok(None); - }; + // column = NULL, the result is always NULL. + return Ok(None); + }; if Self::mutual_exclusive_with_eq_conds(&new_cond, &eq_conds) { return Ok(None); } @@ -583,8 +587,8 @@ impl Condition { .unwrap(); let value = const_expr.fold_const()?; let Some(value) = value else { - continue; - }; + continue; + }; scalars.insert(Some(value)); } if scalars.is_empty() { @@ -641,9 +645,9 @@ impl Condition { } }; let Some(value) = new_expr.fold_const()? else { - // column compare with NULL, the result is always NULL. - return Ok(None); - }; + // column compare with NULL, the result is always NULL. + return Ok(None); + }; match op { ExprType::LessThan => { upper_bound_conjunctions.push(Bound::Excluded(value)); diff --git a/src/frontend/src/utils/with_options.rs b/src/frontend/src/utils/with_options.rs index 8a879b43cff85..bf17ace34119b 100644 --- a/src/frontend/src/utils/with_options.rs +++ b/src/frontend/src/utils/with_options.rs @@ -112,7 +112,11 @@ impl WithOptions { #[inline(always)] fn is_kafka_connector(with_options: &WithOptions) -> bool { - let Some(connector) = with_options.inner().get(UPSTREAM_SOURCE_KEY).map(|s| s.to_lowercase()) else { + let Some(connector) = with_options + .inner() + .get(UPSTREAM_SOURCE_KEY) + .map(|s| s.to_lowercase()) + else { return false; }; connector == KAFKA_CONNECTOR diff --git a/src/java_binding/src/lib.rs b/src/java_binding/src/lib.rs index 6da90e6931ad9..784ff9cbc7db5 100644 --- a/src/java_binding/src/lib.rs +++ b/src/java_binding/src/lib.rs @@ -643,8 +643,11 @@ pub extern "system" fn Java_com_risingwave_java_binding_Binding_rowGetDateValue< <&JClass<'_>>::from(class_ref.as_obj()), *constructor, ReturnType::Object, - &[jvalue { l: string_value.into_raw() }], - )? else { + &[jvalue { + l: string_value.into_raw(), + }], + )? + else { return Err(BindingError::from(jni::errors::Error::MethodNotFound { name: "valueOf".to_string(), sig: "(Ljava/lang/String;)Ljava/sql/Date;".into(), diff --git a/src/stream/src/executor/backfill/no_shuffle_backfill.rs b/src/stream/src/executor/backfill/no_shuffle_backfill.rs index 27cbe3a12d478..344b16580800c 100644 --- a/src/stream/src/executor/backfill/no_shuffle_backfill.rs +++ b/src/stream/src/executor/backfill/no_shuffle_backfill.rs @@ -525,9 +525,7 @@ where current_state: &mut [Datum], ) -> StreamExecutorResult<()> { // Backwards compatibility with no state table in backfill. - let Some(table) = table else { - return Ok(()) - }; + let Some(table) = table else { return Ok(()) }; utils::persist_state( epoch, table, diff --git a/src/stream/src/executor/over_window/delta_btree_map.rs b/src/stream/src/executor/over_window/delta_btree_map.rs index 4bf2df8567406..de8ef6a5082d1 100644 --- a/src/stream/src/executor/over_window/delta_btree_map.rs +++ b/src/stream/src/executor/over_window/delta_btree_map.rs @@ -168,7 +168,9 @@ enum PeekDirection { impl<'a, K: Ord, V> CursorWithDelta<'a, K, V> { /// Get the cursor position type. pub fn position(&self) -> PositionType { - let Some((key, _)) = self.curr_key_value else { return PositionType::Ghost; }; + let Some((key, _)) = self.curr_key_value else { + return PositionType::Ghost; + }; if self.delta.contains_key(key) { assert!(matches!(self.delta.get(key).unwrap(), Change::Insert(_))); if self.snapshot.contains_key(key) { diff --git a/src/stream/src/executor/rearranged_chain.rs b/src/stream/src/executor/rearranged_chain.rs index c511a0aec2f34..1ad43de432551 100644 --- a/src/stream/src/executor/rearranged_chain.rs +++ b/src/stream/src/executor/rearranged_chain.rs @@ -219,7 +219,9 @@ impl RearrangedChainExecutor { #[for_await] for msg in rearranged { let msg: RearrangedMessage = msg?; - let Some(msg) = msg.phantom_into() else { continue }; + let Some(msg) = msg.phantom_into() else { + continue; + }; if let Some(barrier) = msg.as_barrier() { self.progress.finish(barrier.epoch.curr); } diff --git a/src/tests/simulation/src/ctl_ext.rs b/src/tests/simulation/src/ctl_ext.rs index 8c3a1061ae116..feb2b40be7986 100644 --- a/src/tests/simulation/src/ctl_ext.rs +++ b/src/tests/simulation/src/ctl_ext.rs @@ -106,7 +106,9 @@ pub mod predicate { // The rescheduling of no-shuffle downstreams must be derived from the most upstream // fragment. So if a fragment has no-shuffle upstreams, it cannot be rescheduled. !any(root(f), &|n| { - let Some(NodeBody::Merge(merge)) = &n.node_body else { return false }; + let Some(NodeBody::Merge(merge)) = &n.node_body else { + return false; + }; merge.upstream_dispatcher_type() == DispatcherType::NoShuffle }) };