diff --git a/src/api/call_fn.rs b/src/api/call_fn.rs index 6ba9fcf3..1a78cae1 100644 --- a/src/api/call_fn.rs +++ b/src/api/call_fn.rs @@ -3,7 +3,6 @@ use crate::eval::{Caches, GlobalRuntimeState}; use crate::types::dynamic::Variant; -use crate::types::RestoreOnDrop; use crate::{ reify, Dynamic, Engine, FuncArgs, Position, RhaiResult, RhaiResultOf, Scope, SharedModule, StaticVec, AST, ERR, @@ -252,7 +251,7 @@ impl Engine { let lib = &[AsRef::::as_ref(ast).clone()]; let mut no_this_ptr = Dynamic::NULL; - let mut this_ptr = this_ptr.unwrap_or(&mut no_this_ptr); + let this_ptr = this_ptr.unwrap_or(&mut no_this_ptr); let orig_scope_len = scope.len(); @@ -262,7 +261,7 @@ impl Engine { ast.resolver().cloned(), ); #[cfg(not(feature = "no_module"))] - let global = &mut *RestoreOnDrop::lock(global, move |g| { + let global = &mut *crate::types::RestoreOnDrop::lock(global, move |g| { g.embedded_module_resolver = orig_embedded_module_resolver }); @@ -278,11 +277,11 @@ impl Engine { Ok(Dynamic::UNIT) } .and_then(|_| { - let mut args: StaticVec<_> = arg_values.iter_mut().collect(); + let args = &mut arg_values.iter_mut().collect::>(); // Check for data race. #[cfg(not(feature = "no_closure"))] - crate::func::ensure_no_data_race(name, &args, false).map(|_| Dynamic::UNIT)?; + crate::func::ensure_no_data_race(name, args, false).map(|_| Dynamic::UNIT)?; if let Some(fn_def) = ast.shared_lib().get_script_fn(name, args.len()) { self.call_script_fn( @@ -290,9 +289,9 @@ impl Engine { caches, lib, scope, - &mut this_ptr, + this_ptr, fn_def, - &mut args, + args, rewind_scope, Position::NONE, ) @@ -305,7 +304,7 @@ impl Engine { if self.debugger.is_some() { global.debugger.status = crate::eval::DebuggerStatus::Terminate; let node = &crate::ast::Stmt::Noop(Position::NONE); - self.run_debugger(global, caches, lib, scope, &mut this_ptr, node)?; + self.run_debugger(global, caches, lib, scope, this_ptr, node)?; } Ok(result) diff --git a/src/api/eval.rs b/src/api/eval.rs index 829c69b0..10cf9040 100644 --- a/src/api/eval.rs +++ b/src/api/eval.rs @@ -3,7 +3,6 @@ use crate::eval::{Caches, GlobalRuntimeState}; use crate::parser::ParseState; use crate::types::dynamic::Variant; -use crate::types::RestoreOnDrop; use crate::{ Dynamic, Engine, OptimizationLevel, Position, RhaiResult, RhaiResultOf, Scope, AST, ERR, }; @@ -229,7 +228,7 @@ impl Engine { ast.resolver().cloned(), ); #[cfg(not(feature = "no_module"))] - let global = &mut *RestoreOnDrop::lock(global, move |g| { + let global = &mut *crate::types::RestoreOnDrop::lock(global, move |g| { g.embedded_module_resolver = orig_embedded_module_resolver }); diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index faea3923..9a086ed9 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -730,12 +730,11 @@ impl Engine { // Check variable definition filter if let Some(ref filter) = self.def_var_filter { let will_shadow = scope.contains(var_name); - let nesting_level = global.scope_level; let is_const = access == AccessMode::ReadOnly; let info = VarDefInfo { name: var_name, is_const, - nesting_level, + nesting_level: global.scope_level, will_shadow, }; let context = EvalContext::new(self, global, caches, lib, scope, this_ptr); diff --git a/src/types/fn_ptr.rs b/src/types/fn_ptr.rs index 3348d6c2..5d087ef2 100644 --- a/src/types/fn_ptr.rs +++ b/src/types/fn_ptr.rs @@ -161,16 +161,9 @@ impl FnPtr { &lib }; - let global = &mut GlobalRuntimeState::new(engine); + let global = &GlobalRuntimeState::new(engine); - let ctx = NativeCallContext::new_with_all_fields( - engine, - self.fn_name(), - None, - global, - lib, - Position::NONE, - ); + let ctx = (engine, self.fn_name(), None, global, lib, Position::NONE).into(); let result = self.call_raw(&ctx, None, arg_values)?;