diff --git a/src/eval/eval_context.rs b/src/eval/eval_context.rs index 82b3750b..a38f800b 100644 --- a/src/eval/eval_context.rs +++ b/src/eval/eval_context.rs @@ -1,7 +1,7 @@ //! Evaluation context. use super::{Caches, GlobalRuntimeState}; -use crate::{Dynamic, Engine, Module, Scope}; +use crate::{Dynamic, Engine, Scope}; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -68,7 +68,7 @@ impl<'a, 's, 'ps, 'g, 'c, 't> EvalContext<'a, 's, 'ps, 'g, 'c, 't> { /// in reverse order (i.e. modules imported last come first). #[cfg(not(feature = "no_module"))] #[inline(always)] - pub fn iter_imports(&self) -> impl Iterator { + pub fn iter_imports(&self) -> impl Iterator { self.global.iter_imports() } /// Custom state kept in a [`Dynamic`]. @@ -104,7 +104,7 @@ impl<'a, 's, 'ps, 'g, 'c, 't> EvalContext<'a, 's, 'ps, 'g, 'c, 't> { /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] #[inline] - pub fn iter_namespaces(&self) -> impl Iterator { + pub fn iter_namespaces(&self) -> impl Iterator { self.global.lib.iter().map(|m| m.as_ref()) } /// _(internals)_ The current set of namespaces containing definitions of all script-defined functions. diff --git a/src/eval/expr.rs b/src/eval/expr.rs index 5a2455bb..5a6c5b3c 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -4,7 +4,7 @@ use super::{Caches, EvalContext, GlobalRuntimeState, Target}; use crate::ast::{Expr, OpAssignment}; use crate::engine::{KEYWORD_THIS, OP_CONCAT}; use crate::types::dynamic::AccessMode; -use crate::{Dynamic, Engine, Position, RhaiResult, RhaiResultOf, Scope, SharedModule, ERR}; +use crate::{Dynamic, Engine, Position, RhaiResult, RhaiResultOf, Scope, ERR}; use std::num::NonZeroUsize; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -18,7 +18,7 @@ impl Engine { &self, global: &GlobalRuntimeState, namespace: &crate::ast::Namespace, - ) -> Option { + ) -> Option { assert!(!namespace.is_empty()); let root = namespace.root(); diff --git a/src/eval/global_state.rs b/src/eval/global_state.rs index 703ae510..4f3f75bc 100644 --- a/src/eval/global_state.rs +++ b/src/eval/global_state.rs @@ -1,6 +1,6 @@ //! Global runtime state. -use crate::{Dynamic, Engine, ImmutableString, SharedModule, StaticVec}; +use crate::{Dynamic, Engine, ImmutableString}; use std::fmt; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -25,13 +25,13 @@ pub type GlobalConstants = pub struct GlobalRuntimeState { /// Names of imported [modules][crate::Module]. #[cfg(not(feature = "no_module"))] - imports: StaticVec, + imports: crate::StaticVec, /// Stack of imported [modules][crate::Module]. #[cfg(not(feature = "no_module"))] - modules: StaticVec, + modules: crate::StaticVec, /// The current stack of loaded [modules][crate::Module] containing script-defined functions. #[cfg(not(feature = "no_function"))] - pub lib: StaticVec, + pub lib: crate::StaticVec, /// Source of the current context. /// /// No source if the string is empty. @@ -84,11 +84,11 @@ impl GlobalRuntimeState { pub fn new(engine: &Engine) -> Self { Self { #[cfg(not(feature = "no_module"))] - imports: StaticVec::new_const(), + imports: crate::StaticVec::new_const(), #[cfg(not(feature = "no_module"))] - modules: StaticVec::new_const(), + modules: crate::StaticVec::new_const(), #[cfg(not(feature = "no_function"))] - lib: StaticVec::new_const(), + lib: crate::StaticVec::new_const(), source: None, num_operations: 0, #[cfg(not(feature = "no_module"))] @@ -135,7 +135,7 @@ impl GlobalRuntimeState { #[cfg(not(feature = "no_module"))] #[inline(always)] #[must_use] - pub fn get_shared_import(&self, index: usize) -> Option { + pub fn get_shared_import(&self, index: usize) -> Option { self.modules.get(index).cloned() } /// Get a mutable reference to the globally-imported [module][crate::Module] at a @@ -146,7 +146,10 @@ impl GlobalRuntimeState { #[allow(dead_code)] #[inline(always)] #[must_use] - pub(crate) fn get_shared_import_mut(&mut self, index: usize) -> Option<&mut SharedModule> { + pub(crate) fn get_shared_import_mut( + &mut self, + index: usize, + ) -> Option<&mut crate::SharedModule> { self.modules.get_mut(index) } /// Get the index of a globally-imported [module][crate::Module] by name. @@ -170,7 +173,7 @@ impl GlobalRuntimeState { pub fn push_import( &mut self, name: impl Into, - module: impl Into, + module: impl Into, ) { self.imports.push(name.into()); self.modules.push(module.into()); @@ -203,7 +206,7 @@ impl GlobalRuntimeState { #[inline] pub(crate) fn iter_imports_raw( &self, - ) -> impl Iterator { + ) -> impl Iterator { self.imports.iter().zip(self.modules.iter()).rev() } /// Get an iterator to the stack of globally-imported [modules][crate::Module] in forward order. @@ -211,7 +214,9 @@ impl GlobalRuntimeState { /// Not available under `no_module`. #[cfg(not(feature = "no_module"))] #[inline] - pub fn scan_imports_raw(&self) -> impl Iterator { + pub fn scan_imports_raw( + &self, + ) -> impl Iterator { self.imports.iter().zip(self.modules.iter()) } /// Can the particular function with [`Dynamic`] parameter(s) exist in the stack of @@ -318,7 +323,7 @@ impl GlobalRuntimeState { } #[cfg(not(feature = "no_module"))] -impl, M: Into> Extend<(K, M)> for GlobalRuntimeState { +impl, M: Into> Extend<(K, M)> for GlobalRuntimeState { #[inline] fn extend>(&mut self, iter: T) { for (k, m) in iter { diff --git a/src/eval/mod.rs b/src/eval/mod.rs index b4944850..b1b215dc 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -25,7 +25,7 @@ pub use target::{calc_index, calc_offset_len, Target}; #[cfg(feature = "unchecked")] mod unchecked { - use crate::{eval::GlobalRuntimeState, Dynamic, Engine, Position, RhaiResult, RhaiResultOf}; + use crate::{eval::GlobalRuntimeState, Dynamic, Engine, Position, RhaiResultOf}; use std::borrow::Borrow; #[cfg(feature = "no_std")] use std::prelude::v1::*; diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 8465657b..4842ac7f 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -8,7 +8,7 @@ use crate::ast::{ use crate::func::{get_builtin_op_assignment_fn, get_hasher}; use crate::types::dynamic::AccessMode; use crate::types::RestoreOnDrop; -use crate::{Dynamic, Engine, ImmutableString, RhaiResult, RhaiResultOf, Scope, ERR, INT}; +use crate::{Dynamic, Engine, RhaiResult, RhaiResultOf, Scope, ERR, INT}; use std::hash::{Hash, Hasher}; #[cfg(feature = "no_std")] use std::prelude::v1::*; @@ -228,7 +228,7 @@ impl Engine { // (returned by a variable resolver, for example) let is_temp_result = !target.is_ref() && !target.is_shared(); #[cfg(feature = "no_closure")] - let is_temp_result = !lhs_ptr.is_ref(); + let is_temp_result = !target.is_ref(); // Cannot assign to temp result from expression if is_temp_result { @@ -773,8 +773,8 @@ impl Engine { let v = self.eval_expr(global, caches, scope, this_ptr, expr)?; let typ = v.type_name(); - let path = v.try_cast::().ok_or_else(|| { - self.make_type_mismatch_err::(typ, expr.position()) + let path = v.try_cast::().ok_or_else(|| { + self.make_type_mismatch_err::(typ, expr.position()) })?; use crate::ModuleResolver; diff --git a/src/func/call.rs b/src/func/call.rs index 1b9054e8..4e6ef6cb 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -166,7 +166,7 @@ impl Engine { #[must_use] fn resolve_fn<'s>( &self, - global: &GlobalRuntimeState, + _global: &GlobalRuntimeState, caches: &'s mut Caches, local_entry: &'s mut Option, op_token: Option<&Token>, @@ -194,7 +194,7 @@ impl Engine { loop { #[cfg(not(feature = "no_function"))] - let func = global + let func = _global .lib .iter() .rev() @@ -214,7 +214,7 @@ impl Engine { // Scripted functions are not exposed globally func } else { - func.or_else(|| global.get_qualified_fn(hash)).or_else(|| { + func.or_else(|| _global.get_qualified_fn(hash)).or_else(|| { self.global_sub_modules .values() .find_map(|m| m.get_qualified_fn(hash).map(|f| (f, m.id_raw()))) @@ -246,14 +246,14 @@ impl Engine { #[cfg(not(feature = "no_function"))] let is_dynamic = is_dynamic - || global + || _global .lib .iter() .any(|m| m.may_contain_dynamic_fn(hash_base)); #[cfg(not(feature = "no_module"))] let is_dynamic = is_dynamic - || global.may_contain_dynamic_fn(hash_base) + || _global.may_contain_dynamic_fn(hash_base) || self .global_sub_modules .values() diff --git a/src/func/native.rs b/src/func/native.rs index 5010a2f4..b22c39ad 100644 --- a/src/func/native.rs +++ b/src/func/native.rs @@ -7,8 +7,8 @@ use crate::plugin::PluginFunction; use crate::tokenizer::{is_valid_function_name, Token, TokenizeState}; use crate::types::dynamic::Variant; use crate::{ - calc_fn_hash, Dynamic, Engine, EvalContext, FuncArgs, Module, Position, RhaiResult, - RhaiResultOf, SharedModule, StaticVec, VarDefInfo, ERR, + calc_fn_hash, Dynamic, Engine, EvalContext, FuncArgs, Position, RhaiResult, RhaiResultOf, + StaticVec, VarDefInfo, ERR, }; use std::any::type_name; #[cfg(feature = "no_std")] @@ -249,7 +249,7 @@ impl<'a> NativeCallContext<'a> { /// Not available under `no_module`. #[cfg(not(feature = "no_module"))] #[inline] - pub fn iter_imports(&self) -> impl Iterator { + pub fn iter_imports(&self) -> impl Iterator { self.global.iter_imports() } /// Get an iterator over the current set of modules imported via `import` statements in reverse order. @@ -258,7 +258,7 @@ impl<'a> NativeCallContext<'a> { #[inline] pub(crate) fn iter_imports_raw( &self, - ) -> impl Iterator { + ) -> impl Iterator { self.global.iter_imports_raw() } /// _(internals)_ The current [`GlobalRuntimeState`], if any. @@ -277,7 +277,7 @@ impl<'a> NativeCallContext<'a> { /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] #[inline] - pub fn iter_namespaces(&self) -> impl Iterator { + pub fn iter_namespaces(&self) -> impl Iterator { self.global.lib.iter().map(|m| m.as_ref()) } /// _(internals)_ The current stack of namespaces containing definitions of all script-defined functions. @@ -288,7 +288,7 @@ impl<'a> NativeCallContext<'a> { #[cfg(feature = "internals")] #[inline(always)] #[must_use] - pub fn namespaces(&self) -> &[SharedModule] { + pub fn namespaces(&self) -> &[crate::SharedModule] { &self.global.lib } /// Call a function inside the call context with the provided arguments.