diff --git a/src/ast/stmt.rs b/src/ast/stmt.rs index 81f47d3d..6c980e1d 100644 --- a/src/ast/stmt.rs +++ b/src/ast/stmt.rs @@ -477,9 +477,11 @@ impl Stmt { | Self::Expr(..) | Self::FnCall(..) => true, - Self::Noop(..) | Self::While(..) | Self::Do(..) | Self::For(..) | Self::TryCatch(..) => { - false - } + Self::Noop(..) + | Self::While(..) + | Self::Do(..) + | Self::For(..) + | Self::TryCatch(..) => false, Self::Var(..) | Self::Assignment(..) | Self::BreakLoop(..) | Self::Return(..) => false, diff --git a/src/eval/chaining.rs b/src/eval/chaining.rs index 1185b720..898ab201 100644 --- a/src/eval/chaining.rs +++ b/src/eval/chaining.rs @@ -4,7 +4,9 @@ use super::{EvalState, GlobalRuntimeState, Target}; use crate::ast::{Expr, OpAssignment}; use crate::types::dynamic::Union; -use crate::{Dynamic, Engine, Module, Position, RhaiResult, RhaiResultOf, Scope, StaticVec, ERR}; +use crate::{ + Dynamic, Engine, Module, Position, RhaiError, RhaiResult, RhaiResultOf, Scope, StaticVec, ERR, +}; use std::hash::Hash; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -733,7 +735,7 @@ impl Engine { let (values, pos) = args.iter().try_fold( (crate::FnArgsVec::with_capacity(args.len()), Position::NONE), - |(mut values, mut pos), expr| -> RhaiResultOf<_> { + |(mut values, mut pos), expr| { let (value, arg_pos) = self.get_arg_value( scope, global, state, lib, this_ptr, expr, constants, level, )?; @@ -741,7 +743,7 @@ impl Engine { pos = arg_pos; } values.push(value.flatten()); - Ok((values, pos)) + Ok::<_, RhaiError>((values, pos)) }, )?; @@ -779,7 +781,7 @@ impl Engine { let (values, pos) = args.iter().try_fold( (crate::FnArgsVec::with_capacity(args.len()), Position::NONE), - |(mut values, mut pos), expr| -> RhaiResultOf<_> { + |(mut values, mut pos), expr| { let (value, arg_pos) = self.get_arg_value( scope, global, state, lib, this_ptr, expr, constants, level, )?; @@ -787,7 +789,7 @@ impl Engine { pos = arg_pos } values.push(value.flatten()); - Ok((values, pos)) + Ok::<_, RhaiError>((values, pos)) }, )?; super::ChainArgument::from_fn_call_args(values, pos) diff --git a/src/func/call.rs b/src/func/call.rs index f4c6a07f..5a13b03f 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -12,8 +12,8 @@ use crate::engine::{ use crate::eval::{EvalState, GlobalRuntimeState}; use crate::{ calc_fn_hash, calc_fn_params_hash, combine_hashes, Dynamic, Engine, FnArgsVec, FnPtr, - Identifier, ImmutableString, Module, OptimizationLevel, Position, RhaiResult, RhaiResultOf, - Scope, ERR, + Identifier, ImmutableString, Module, OptimizationLevel, Position, RhaiError, RhaiResult, + RhaiResultOf, Scope, ERR, }; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -1079,16 +1079,13 @@ impl Engine { let (name, fn_curry) = arg_value.cast::().take_data(); // Append the new curried arguments to the existing list. - let fn_curry = - a_expr - .iter() - .try_fold(fn_curry, |mut curried, expr| -> RhaiResultOf<_> { - let (value, ..) = self.get_arg_value( - scope, global, state, lib, this_ptr, expr, constants, level, - )?; - curried.push(value); - Ok(curried) - })?; + let fn_curry = a_expr.iter().try_fold(fn_curry, |mut curried, expr| { + let (value, ..) = self.get_arg_value( + scope, global, state, lib, this_ptr, expr, constants, level, + )?; + curried.push(value); + Ok::<_, RhaiError>(curried) + })?; return Ok(FnPtr::new_unchecked(name, fn_curry).into()); } diff --git a/src/parser.rs b/src/parser.rs index e9e382e4..8f5a28ca 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1264,8 +1264,10 @@ fn parse_primary( let (expr, func) = parse_anon_fn(input, &mut new_state, lib, new_settings)?; #[cfg(not(feature = "no_closure"))] - new_state.external_vars.iter().try_for_each( - |crate::ast::Ident { name, pos }| -> ParseResult<_> { + new_state + .external_vars + .iter() + .try_for_each(|crate::ast::Ident { name, pos }| { let index = state.access_var(name, *pos); if settings.strict_var && !settings.is_closure && index.is_none() { @@ -1274,10 +1276,9 @@ fn parse_primary( // Under Strict Variables mode, this is not allowed. Err(PERR::VariableUndefined(name.to_string()).into_err(*pos)) } else { - Ok(()) + Ok::<_, ParseError>(()) } - }, - )?; + })?; let hash_script = calc_fn_hash(&func.name, func.params.len()); lib.insert(hash_script, func.into());