diff --git a/src/ast.rs b/src/ast.rs index 1f30a3ed..3cf2b739 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -718,7 +718,7 @@ impl AST { /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] #[cfg(not(feature = "no_module"))] - #[inline(always)] + #[inline] pub(crate) fn iter_fn_def(&self) -> impl Iterator { self.functions .iter_script_fn() @@ -728,7 +728,7 @@ impl AST { /// /// Not available under `no_function`. #[cfg(not(feature = "no_function"))] - #[inline(always)] + #[inline] pub fn iter_functions<'a>(&'a self) -> impl Iterator + 'a { self.functions .iter_script_fn() @@ -944,7 +944,7 @@ impl fmt::Debug for StmtBlock { } impl From for Stmt { - #[inline(always)] + #[inline] fn from(block: StmtBlock) -> Self { let block_pos = block.position(); Self::Block(block.0.into_boxed_slice(), block_pos) @@ -1852,7 +1852,7 @@ impl From for FloatWrapper { impl FromStr for FloatWrapper { type Err = ::Err; - #[inline(always)] + #[inline] fn from_str(s: &str) -> Result { F::from_str(s).map(Into::::into) } @@ -2132,7 +2132,7 @@ impl Expr { } } /// Is the expression a simple variable access? - #[inline(always)] + #[inline] #[must_use] pub(crate) const fn is_variable_access(&self, non_qualified: bool) -> bool { match self { @@ -2141,7 +2141,7 @@ impl Expr { } } /// Return the variable name if the expression a simple variable access. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_variable_name(&self, non_qualified: bool) -> Option<&str> { match self { diff --git a/src/dynamic.rs b/src/dynamic.rs index ae2096ab..76d99ad9 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -255,7 +255,7 @@ enum DynamicReadLockInner<'d, T: Clone> { impl<'d, T: Any + Clone> Deref for DynamicReadLock<'d, T> { type Target = T; - #[inline(always)] + #[inline] fn deref(&self) -> &Self::Target { match self.0 { DynamicReadLockInner::Reference(ref reference) => *reference, @@ -296,7 +296,7 @@ enum DynamicWriteLockInner<'d, T: Clone> { impl<'d, T: Any + Clone> Deref for DynamicWriteLock<'d, T> { type Target = T; - #[inline(always)] + #[inline] fn deref(&self) -> &Self::Target { match self.0 { DynamicWriteLockInner::Reference(ref reference) => *reference, @@ -307,7 +307,7 @@ impl<'d, T: Any + Clone> Deref for DynamicWriteLock<'d, T> { } impl<'d, T: Any + Clone> DerefMut for DynamicWriteLock<'d, T> { - #[inline(always)] + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { match self.0 { DynamicWriteLockInner::Reference(ref mut reference) => *reference, @@ -384,17 +384,16 @@ impl Dynamic { #[inline(always)] #[must_use] pub const fn is_shared(&self) -> bool { - match self.0 { - #[cfg(not(feature = "no_closure"))] - Union::Shared(_, _, _) => true, - _ => false, - } + #[cfg(not(feature = "no_closure"))] + return matches!(self.0, Union::Shared(_, _, _)); + #[cfg(feature = "no_closure")] + return false; } /// Is the value held by this [`Dynamic`] a particular type? /// /// If the [`Dynamic`] is a shared variant checking is performed on /// top of its internal value. - #[inline(always)] + #[inline] #[must_use] pub fn is(&self) -> bool { if TypeId::of::() == TypeId::of::() { @@ -1221,7 +1220,7 @@ impl Dynamic { /// /// If the [`Dynamic`] value is already shared, this method returns itself. #[cfg(not(feature = "no_closure"))] - #[inline(always)] + #[inline] #[must_use] pub fn into_shared(self) -> Self { let _access = self.access_mode(); @@ -1452,7 +1451,7 @@ impl Dynamic { /// If the [`Dynamic`] is not a shared value, it returns a cloned copy. /// /// If the [`Dynamic`] is a shared value, it returns a cloned copy of the shared value. - #[inline(always)] + #[inline] #[must_use] pub fn flatten_clone(&self) -> Self { match self.0 { @@ -1471,7 +1470,7 @@ impl Dynamic { /// /// If the [`Dynamic`] is a shared value, it returns the shared value if there are no /// outstanding references, or a cloned copy. - #[inline(always)] + #[inline] #[must_use] pub fn flatten(self) -> Self { match self.0 { @@ -1495,7 +1494,7 @@ impl Dynamic { /// /// If the [`Dynamic`] is a shared value, it is set to the shared value if there are no /// outstanding references, or a cloned copy otherwise. - #[inline(always)] + #[inline] pub(crate) fn flatten_in_place(&mut self) -> &mut Self { match self.0 { #[cfg(not(feature = "no_closure"))] @@ -1528,7 +1527,7 @@ impl Dynamic { /// Access just waits until the [`RwLock`][std::sync::RwLock] is released. /// So this method always returns [`false`] under [`Sync`]. #[cfg(not(feature = "no_closure"))] - #[inline(always)] + #[inline] #[must_use] pub fn is_locked(&self) -> bool { #[cfg(not(feature = "no_closure"))] @@ -1895,7 +1894,7 @@ impl Dynamic { /// Convert the [`Dynamic`] into a [`String`] and return it. /// If there are other references to the same string, a cloned copy is returned. /// Returns the name of the actual type if the cast fails. - #[inline(always)] + #[inline] pub fn into_string(self) -> Result { self.into_immutable_string() .map(ImmutableString::into_owned) @@ -1997,7 +1996,7 @@ impl Dynamic { } #[cfg(not(feature = "no_index"))] impl From> for Dynamic { - #[inline(always)] + #[inline] fn from(value: Vec) -> Self { Self(Union::Array( Box::new(value.into_iter().map(Dynamic::from).collect()), @@ -2008,7 +2007,7 @@ impl From> for Dynamic { } #[cfg(not(feature = "no_index"))] impl From<&[T]> for Dynamic { - #[inline(always)] + #[inline] fn from(value: &[T]) -> Self { Self(Union::Array( Box::new(value.iter().cloned().map(Dynamic::from).collect()), @@ -2019,7 +2018,7 @@ impl From<&[T]> for Dynamic { } #[cfg(not(feature = "no_index"))] impl std::iter::FromIterator for Dynamic { - #[inline(always)] + #[inline] fn from_iter>(iter: X) -> Self { Self(Union::Array( Box::new(iter.into_iter().map(Dynamic::from).collect()), diff --git a/src/engine.rs b/src/engine.rs index 84631a2a..0998d22f 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -144,7 +144,7 @@ impl Imports { } /// Does the specified function hash key exist in this stack of imported [modules][Module]? #[allow(dead_code)] - #[inline(always)] + #[inline] #[must_use] pub fn contains_fn(&self, hash: u64) -> bool { self.modules.iter().any(|m| m.contains_qualified_fn(hash)) @@ -161,7 +161,7 @@ impl Imports { /// Does the specified [`TypeId`][std::any::TypeId] iterator exist in this stack of /// imported [modules][Module]? #[allow(dead_code)] - #[inline(always)] + #[inline] #[must_use] pub fn contains_iter(&self, id: TypeId) -> bool { self.modules.iter().any(|m| m.contains_qualified_iter(id)) @@ -888,7 +888,7 @@ impl<'x, 'px, 'pt> EvalContext<'_, 'x, 'px, '_, '_, '_, '_, 'pt> { self.mods } /// Get an iterator over the namespaces containing definition of all script-defined functions. - #[inline(always)] + #[inline] pub fn iter_namespaces(&self) -> impl Iterator { self.lib.iter().cloned() } @@ -3262,7 +3262,7 @@ impl Engine { /// /// If a type is registered via [`register_type_with_name`][Engine::register_type_with_name], /// the type name provided for the registration will be used. - #[inline(always)] + #[inline] #[must_use] pub fn map_type_name<'a>(&'a self, name: &'a str) -> &'a str { self.type_names @@ -3272,7 +3272,7 @@ impl Engine { } /// Make a `Box<`[`EvalAltResult`][EvalAltResult::ErrorMismatchDataType]`>`. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn make_type_mismatch_err(&self, typ: &str, pos: Position) -> Box { EvalAltResult::ErrorMismatchDataType( diff --git a/src/engine_api.rs b/src/engine_api.rs index 8ba01d01..f78bfe97 100644 --- a/src/engine_api.rs +++ b/src/engine_api.rs @@ -1287,7 +1287,7 @@ impl Engine { /// ``` #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline(always)] + #[inline] pub fn compile_file_with_scope( &self, scope: &Scope, @@ -1491,7 +1491,7 @@ impl Engine { /// ``` #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline(always)] + #[inline] pub fn eval_file( &self, path: std::path::PathBuf, @@ -1521,7 +1521,7 @@ impl Engine { /// ``` #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline(always)] + #[inline] pub fn eval_file_with_scope( &self, scope: &mut Scope, @@ -1569,7 +1569,7 @@ impl Engine { /// # Ok(()) /// # } /// ``` - #[inline(always)] + #[inline] pub fn eval_with_scope( &self, scope: &mut Scope, @@ -1744,7 +1744,7 @@ impl Engine { /// Not available under `no_std` or `WASM`. #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline(always)] + #[inline] pub fn run_file(&self, path: std::path::PathBuf) -> Result<(), Box> { Self::read_file(path).and_then(|contents| self.run(&contents)) } @@ -1753,7 +1753,7 @@ impl Engine { /// Not available under `no_std` or `WASM`. #[cfg(not(feature = "no_std"))] #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] - #[inline(always)] + #[inline] pub fn run_file_with_scope( &self, scope: &mut Scope, diff --git a/src/engine_settings.rs b/src/engine_settings.rs index f1558638..7032f84f 100644 --- a/src/engine_settings.rs +++ b/src/engine_settings.rs @@ -67,7 +67,7 @@ impl Engine { /// /// Not available under `unchecked`. #[cfg(not(feature = "unchecked"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_operations(&self) -> u64 { if let Some(n) = self.limits.max_operations { @@ -117,7 +117,7 @@ impl Engine { /// /// Not available under `unchecked`. #[cfg(not(feature = "unchecked"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_expr_depth(&self) -> usize { if let Some(n) = self.limits.max_expr_depth { @@ -131,7 +131,7 @@ impl Engine { /// Not available under `unchecked` or `no_function`. #[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "no_function"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_function_expr_depth(&self) -> usize { if let Some(n) = self.limits.max_function_expr_depth { @@ -153,7 +153,7 @@ impl Engine { /// /// Not available under `unchecked`. #[cfg(not(feature = "unchecked"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_string_size(&self) -> usize { if let Some(n) = self.limits.max_string_size { @@ -177,7 +177,7 @@ impl Engine { /// Not available under `unchecked` or `no_index`. #[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "no_index"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_array_size(&self) -> usize { if let Some(n) = self.limits.max_array_size { @@ -201,7 +201,7 @@ impl Engine { /// Not available under `unchecked` or `no_object`. #[cfg(not(feature = "unchecked"))] #[cfg(not(feature = "no_object"))] - #[inline(always)] + #[inline] #[must_use] pub const fn max_map_size(&self) -> usize { if let Some(n) = self.limits.max_map_size { diff --git a/src/fn_args.rs b/src/fn_args.rs index 6e6f4621..3f6f11de 100644 --- a/src/fn_args.rs +++ b/src/fn_args.rs @@ -57,7 +57,7 @@ pub trait FuncArgs { } impl FuncArgs for Vec { - #[inline(always)] + #[inline] fn parse>(self, container: &mut CONTAINER) { container.extend(self.into_iter().map(Variant::into_dynamic)); } @@ -69,7 +69,7 @@ macro_rules! impl_args { ($($p:ident),*) => { impl<$($p: Variant + Clone),*> FuncArgs for ($($p,)*) { - #[inline(always)] + #[inline] #[allow(unused_variables)] fn parse>(self, container: &mut CONTAINER) { let ($($p,)*) = self; diff --git a/src/fn_call.rs b/src/fn_call.rs index 87616cc8..1ddca55d 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -57,7 +57,7 @@ impl<'a> ArgBackup<'a> { /// # Panics /// /// Panics when `args` is empty. - #[inline(always)] + #[inline] fn change_first_arg_to_copy(&mut self, args: &mut FnCallArgs<'a>) { // Clone the original value. self.value_copy = args[0].clone(); @@ -91,7 +91,7 @@ impl<'a> ArgBackup<'a> { } impl Drop for ArgBackup<'_> { - #[inline(always)] + #[inline] fn drop(&mut self) { // Panic if the shorter lifetime leaks. assert!( diff --git a/src/fn_func.rs b/src/fn_func.rs index c465dab6..b33e273f 100644 --- a/src/fn_func.rs +++ b/src/fn_func.rs @@ -96,13 +96,13 @@ macro_rules! def_anonymous_fn { #[cfg(not(feature = "sync"))] type Output = Box Result>>; - #[inline(always)] + #[inline] fn create_from_ast(self, ast: AST, entry_point: &str) -> Self::Output { let fn_name: SmartString = entry_point.into(); Box::new(move |$($par),*| self.call_fn(&mut Scope::new(), &ast, &fn_name, ($($par,)*))) } - #[inline(always)] + #[inline] fn create_from_script(self, script: &str, entry_point: &str) -> Result { let ast = self.compile(script)?; Ok(Func::<($($par,)*), RET>::create_from_ast(self, ast, entry_point)) diff --git a/src/fn_native.rs b/src/fn_native.rs index b47e8eff..ac5ad4d5 100644 --- a/src/fn_native.rs +++ b/src/fn_native.rs @@ -144,14 +144,14 @@ impl<'a> NativeCallContext<'a> { /// /// Not available under `no_module`. #[cfg(not(feature = "no_module"))] - #[inline(always)] + #[inline] pub fn iter_imports(&self) -> impl Iterator { self.mods.iter().flat_map(|&m| m.iter()) } /// Get an iterator over the current set of modules imported via `import` statements. #[cfg(not(feature = "no_module"))] #[allow(dead_code)] - #[inline(always)] + #[inline] pub(crate) fn iter_imports_raw( &self, ) -> impl Iterator)> { @@ -169,7 +169,7 @@ impl<'a> NativeCallContext<'a> { self.mods } /// Get an iterator over the namespaces containing definitions of all script-defined functions. - #[inline(always)] + #[inline] pub fn iter_namespaces(&self) -> impl Iterator { self.lib.iter().cloned() } @@ -239,7 +239,7 @@ pub fn shared_make_mut(value: &mut Shared) -> &mut T { } /// Consume a [`Shared`] resource if is unique (i.e. not shared), or clone it otherwise. -#[inline(always)] +#[inline] #[must_use] pub fn shared_take_or_clone(value: Shared) -> T { shared_try_take(value).unwrap_or_else(|v| v.as_ref().clone()) @@ -256,7 +256,7 @@ pub fn shared_try_take(value: Shared) -> Result> { /// # Panics /// /// Panics if the resource is shared (i.e. has other outstanding references). -#[inline(always)] +#[inline] #[must_use] pub fn shared_take(value: Shared) -> T { shared_try_take(value) diff --git a/src/fn_ptr.rs b/src/fn_ptr.rs index 42aa69da..e0140579 100644 --- a/src/fn_ptr.rs +++ b/src/fn_ptr.rs @@ -69,7 +69,7 @@ impl FnPtr { self } /// Set curried arguments to the function pointer. - #[inline(always)] + #[inline] pub fn set_curry(&mut self, values: impl IntoIterator) -> &mut Self { self.1 = values.into_iter().collect(); self diff --git a/src/immutable_string.rs b/src/immutable_string.rs index 8c146897..53ccdab5 100644 --- a/src/immutable_string.rs +++ b/src/immutable_string.rs @@ -90,26 +90,29 @@ impl Borrow for ImmutableString { impl From<&str> for ImmutableString { #[inline(always)] fn from(value: &str) -> Self { - Self(Into::::into(value).into()) + let value: SmartString = value.into(); + Self(value.into()) } } impl From<&String> for ImmutableString { #[inline(always)] fn from(value: &String) -> Self { - Self(Into::::into(value).into()) + let value: SmartString = value.into(); + Self(value.into()) } } impl From for ImmutableString { #[inline(always)] fn from(value: String) -> Self { - Self(Into::::into(value).into()) + let value: SmartString = value.into(); + Self(value.into()) } } #[cfg(not(feature = "no_smartstring"))] impl From<&SmartString> for ImmutableString { #[inline(always)] fn from(value: &SmartString) -> Self { - Self(Into::::into(value.as_str()).into()) + Self(value.clone().into()) } } #[cfg(not(feature = "no_smartstring"))] @@ -137,33 +140,34 @@ impl FromStr for ImmutableString { #[inline(always)] fn from_str(s: &str) -> Result { - Ok(Self(Into::::into(s).into())) + let s: SmartString = s.into(); + Ok(Self(s.into())) } } impl FromIterator for ImmutableString { - #[inline(always)] + #[inline] fn from_iter>(iter: T) -> Self { Self(iter.into_iter().collect::().into()) } } impl<'a> FromIterator<&'a char> for ImmutableString { - #[inline(always)] + #[inline] fn from_iter>(iter: T) -> Self { Self(iter.into_iter().cloned().collect::().into()) } } impl<'a> FromIterator<&'a str> for ImmutableString { - #[inline(always)] + #[inline] fn from_iter>(iter: T) -> Self { Self(iter.into_iter().collect::().into()) } } impl<'a> FromIterator for ImmutableString { - #[inline(always)] + #[inline] fn from_iter>(iter: T) -> Self { Self(iter.into_iter().collect::().into()) } @@ -171,7 +175,7 @@ impl<'a> FromIterator for ImmutableString { #[cfg(not(feature = "no_smartstring"))] impl<'a> FromIterator for ImmutableString { - #[inline(always)] + #[inline] fn from_iter>(iter: T) -> Self { Self(iter.into_iter().collect::().into()) } @@ -278,7 +282,7 @@ impl Add<&str> for &ImmutableString { } impl AddAssign<&str> for ImmutableString { - #[inline(always)] + #[inline] fn add_assign(&mut self, rhs: &str) { if !rhs.is_empty() { self.make_mut().push_str(rhs); @@ -324,7 +328,8 @@ impl AddAssign for ImmutableString { fn add_assign(&mut self, rhs: String) { if !rhs.is_empty() { if self.is_empty() { - self.0 = Into::::into(rhs).into(); + let rhs: SmartString = rhs.into(); + self.0 = rhs.into(); } else { self.make_mut().push_str(&rhs); } @@ -335,7 +340,7 @@ impl AddAssign for ImmutableString { impl Add for ImmutableString { type Output = Self; - #[inline(always)] + #[inline] fn add(mut self, rhs: char) -> Self::Output { self.make_mut().push(rhs); self @@ -345,7 +350,7 @@ impl Add for ImmutableString { impl Add for &ImmutableString { type Output = ImmutableString; - #[inline(always)] + #[inline] fn add(self, rhs: char) -> Self::Output { let mut s = self.clone(); s.make_mut().push(rhs); @@ -354,7 +359,7 @@ impl Add for &ImmutableString { } impl AddAssign for ImmutableString { - #[inline(always)] + #[inline] fn add_assign(&mut self, rhs: char) { self.make_mut().push(rhs); } @@ -397,7 +402,8 @@ impl SubAssign<&ImmutableString> for ImmutableString { if self.is_empty() { self.0 = rhs.0.clone(); } else { - self.0 = Into::::into(self.replace(rhs.as_str(), "")).into(); + let rhs: SmartString = self.replace(rhs.as_str(), "").into(); + self.0 = rhs.into(); } } } @@ -410,7 +416,8 @@ impl SubAssign for ImmutableString { if self.is_empty() { self.0 = rhs.0; } else { - self.0 = Into::::into(self.replace(rhs.as_str(), "")).into(); + let rhs: SmartString = self.replace(rhs.as_str(), "").into(); + self.0 = rhs.into(); } } } @@ -447,9 +454,10 @@ impl Sub for &ImmutableString { } impl SubAssign for ImmutableString { - #[inline(always)] + #[inline] fn sub_assign(&mut self, rhs: String) { - self.0 = Into::::into(self.replace(&rhs, "")).into(); + let rhs: SmartString = self.replace(&rhs, "").into(); + self.0 = rhs.into(); } } @@ -472,9 +480,10 @@ impl Sub for &ImmutableString { } impl SubAssign for ImmutableString { - #[inline(always)] + #[inline] fn sub_assign(&mut self, rhs: char) { - self.0 = Into::::into(self.replace(rhs, "")).into(); + let rhs: SmartString = self.replace(rhs, "").into(); + self.0 = rhs.into(); } } @@ -527,7 +536,7 @@ impl ImmutableString { } /// Consume the [`ImmutableString`] and convert it into a [`String`]. /// If there are other references to the same string, a cloned copy is returned. - #[inline(always)] + #[inline] pub fn into_owned(mut self) -> String { self.make_mut(); // Make sure it is unique reference shared_take(self.0).into() // Should succeed diff --git a/src/module/mod.rs b/src/module/mod.rs index baa9c7fb..0a9ebe39 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -204,7 +204,7 @@ impl AsRef for Module { impl> Add for &Module { type Output = Module; - #[inline(always)] + #[inline] fn add(self, rhs: M) -> Self::Output { let mut module = self.clone(); module.merge(rhs.as_ref()); @@ -240,7 +240,7 @@ impl Module { /// module.set_var("answer", 42_i64); /// assert_eq!(module.get_var_value::("answer").expect("answer should exist"), 42); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn new() -> Self { Self { @@ -269,7 +269,7 @@ impl Module { /// module.set_id("hello"); /// assert_eq!(module.id(), Some("hello")); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn id(&self) -> Option<&str> { self.id_raw().map(|s| s.as_str()) @@ -365,7 +365,7 @@ impl Module { /// Generate signatures for all the non-private functions in the [`Module`]. /// Exported under the `metadata` feature only. #[cfg(feature = "metadata")] - #[inline(always)] + #[inline] pub fn gen_fn_signatures(&self) -> impl Iterator + '_ { self.functions .values() @@ -402,7 +402,7 @@ impl Module { /// module.set_var("answer", 42_i64); /// assert_eq!(module.get_var_value::("answer").expect("answer should exist"), 42); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn get_var_value(&self, name: &str) -> Option { self.get_var(name).and_then(Dynamic::try_cast::) @@ -559,7 +559,7 @@ impl Module { /// module.set_sub_module("question", sub_module); /// assert!(module.get_sub_module("question").is_some()); /// ``` - #[inline(always)] + #[inline] #[must_use] pub fn get_sub_module(&self, name: &str) -> Option<&Module> { self.modules.get(name).map(|m| m.as_ref()) @@ -1113,7 +1113,7 @@ impl Module { /// Get a Rust function. /// /// The [`u64`] hash is returned by the [`set_native_fn`][Module::set_native_fn] call. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_fn(&self, hash_fn: u64) -> Option<&CallableFunction> { self.functions.get(&hash_fn).map(|f| f.func.as_ref()) @@ -1131,7 +1131,7 @@ impl Module { /// Get a namespace-qualified function. /// /// The [`u64`] hash is calculated by [`build_index`][Module::build_index]. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_qualified_fn(&self, hash_qualified_fn: u64) -> Option<&CallableFunction> { self.all_functions @@ -1289,19 +1289,19 @@ impl Module { } /// Get an iterator to the sub-modules in the [`Module`]. - #[inline(always)] + #[inline] pub fn iter_sub_modules(&self) -> impl Iterator)> { self.modules.iter().map(|(k, m)| (k.as_str(), m.clone())) } /// Get an iterator to the variables in the [`Module`]. - #[inline(always)] + #[inline] pub fn iter_var(&self) -> impl Iterator { self.variables.iter().map(|(k, v)| (k.as_str(), v)) } /// Get an iterator to the functions in the [`Module`]. - #[inline(always)] + #[inline] #[allow(dead_code)] pub(crate) fn iter_fn(&self) -> impl Iterator { self.functions.values().map(Box::as_ref) @@ -1316,7 +1316,7 @@ impl Module { /// 4) Number of parameters. /// 5) Shared reference to function definition [`ScriptFnDef`][crate::ast::ScriptFnDef]. #[cfg(not(feature = "no_function"))] - #[inline(always)] + #[inline] pub(crate) fn iter_script_fn( &self, ) -> impl Iterator< @@ -1351,7 +1351,7 @@ impl Module { /// 4) Number of parameters. #[cfg(not(feature = "no_function"))] #[cfg(not(feature = "internals"))] - #[inline(always)] + #[inline] pub fn iter_script_fn_info( &self, ) -> impl Iterator { @@ -1610,7 +1610,7 @@ impl Module { } /// Set a type iterator into the [`Module`]. - #[inline(always)] + #[inline] pub fn set_iterable(&mut self) -> &mut Self where T: Variant + Clone + IntoIterator, @@ -1622,7 +1622,7 @@ impl Module { } /// Set an iterator type into the [`Module`] as a type iterator. - #[inline(always)] + #[inline] pub fn set_iterator(&mut self) -> &mut Self where T: Variant + Clone + Iterator, @@ -1634,14 +1634,14 @@ impl Module { } /// Get the specified type iterator. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_qualified_iter(&self, id: TypeId) -> Option { self.all_type_iterators.get(&id).cloned() } /// Get the specified type iterator. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_iter(&self, id: TypeId) -> Option { self.type_iterators.get(&id).cloned() @@ -1709,8 +1709,7 @@ impl DerefMut for NamespaceRef { impl From> for NamespaceRef { #[inline(always)] - fn from(path: StaticVec) -> Self { - let mut path = path; + fn from(mut path: StaticVec) -> Self { path.shrink_to_fit(); Self { index: None, path } } diff --git a/src/module/resolvers/collection.rs b/src/module/resolvers/collection.rs index c6eac580..6a61ff3f 100644 --- a/src/module/resolvers/collection.rs +++ b/src/module/resolvers/collection.rs @@ -76,7 +76,7 @@ impl ModuleResolversCollection { self.0.remove(index) } /// Get an iterator of all the [module resolvers][ModuleResolver]. - #[inline(always)] + #[inline] pub fn iter(&self) -> impl Iterator { self.0.iter().map(|v| v.as_ref()) } @@ -100,7 +100,7 @@ impl ModuleResolversCollection { } /// Add another [`ModuleResolversCollection`] to the end of this collection. /// The other [`ModuleResolversCollection`] is consumed. - #[inline(always)] + #[inline] pub fn append(&mut self, other: Self) -> &mut Self { self.0.extend(other.0.into_iter()); self diff --git a/src/module/resolvers/file.rs b/src/module/resolvers/file.rs index f3b06113..276243fa 100644 --- a/src/module/resolvers/file.rs +++ b/src/module/resolvers/file.rs @@ -215,7 +215,7 @@ impl FileModuleResolver { return self.cache.write().unwrap().contains_key(&file_path); } /// Empty the internal cache. - #[inline(always)] + #[inline] pub fn clear_cache(&mut self) -> &mut Self { #[cfg(not(feature = "sync"))] self.cache.borrow_mut().clear(); diff --git a/src/module/resolvers/stat.rs b/src/module/resolvers/stat.rs index 0b555884..a5b4d0c9 100644 --- a/src/module/resolvers/stat.rs +++ b/src/module/resolvers/stat.rs @@ -48,7 +48,7 @@ impl StaticModuleResolver { Default::default() } /// Add a [module][Module] keyed by its path. - #[inline(always)] + #[inline] pub fn insert(&mut self, path: impl Into, mut module: Module) { module.build_index(); self.0.insert(path.into(), module.into()); @@ -65,17 +65,17 @@ impl StaticModuleResolver { self.0.contains_key(path) } /// Get an iterator of all the [modules][Module]. - #[inline(always)] + #[inline] pub fn iter(&self) -> impl Iterator)> { self.0.iter().map(|(k, v)| (k.as_str(), v)) } /// Get a mutable iterator of all the [modules][Module]. - #[inline(always)] + #[inline] pub fn iter_mut(&mut self) -> impl Iterator)> { self.0.iter_mut().map(|(k, v)| (k.as_str(), v)) } /// Get an iterator of all the [module][Module] paths. - #[inline(always)] + #[inline] pub fn paths(&self) -> impl Iterator { self.0.keys().map(|s| s.as_str()) } @@ -105,7 +105,7 @@ impl StaticModuleResolver { /// The other [`StaticModuleResolver`] is consumed. /// /// Existing modules of the same path name are overwritten. - #[inline(always)] + #[inline] pub fn merge(&mut self, other: Self) -> &mut Self { if !other.is_empty() { self.0.extend(other.0.into_iter()); @@ -124,7 +124,7 @@ impl IntoIterator for StaticModuleResolver { } impl ModuleResolver for StaticModuleResolver { - #[inline(always)] + #[inline] fn resolve( &self, _: &Engine, diff --git a/src/optimize.rs b/src/optimize.rs index 22878f5b..8479ecd4 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -123,7 +123,7 @@ impl<'a> OptimizerState<'a> { }) } /// Call a registered function - #[inline(always)] + #[inline] pub fn call_fn_with_constant_arguments( &self, fn_name: &str, diff --git a/src/packages/iter_basic.rs b/src/packages/iter_basic.rs index dec48845..c9f481d6 100644 --- a/src/packages/iter_basic.rs +++ b/src/packages/iter_basic.rs @@ -251,7 +251,7 @@ impl Iterator for CharsStream { } } - #[inline(always)] + #[inline] fn size_hint(&self) -> (usize, Option) { let remaining = self.0.len() - self.1; (remaining, Some(remaining)) @@ -261,7 +261,7 @@ impl Iterator for CharsStream { impl FusedIterator for CharsStream {} impl ExactSizeIterator for CharsStream { - #[inline(always)] + #[inline] fn len(&self) -> usize { self.0.len() - self.1 } diff --git a/src/parse.rs b/src/parse.rs index daa57566..4cdb91ef 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -3322,7 +3322,7 @@ impl Engine { } /// Run the parser on an input stream, returning an AST. - #[inline(always)] + #[inline] pub(crate) fn parse( &self, input: &mut TokenStream, diff --git a/src/scope.rs b/src/scope.rs index 028287a5..6f217481 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -482,7 +482,7 @@ impl<'a> Scope<'a> { /// # Panics /// /// Panics if the index is out of bounds. - #[inline(always)] + #[inline] #[must_use] pub(crate) fn get_mut_by_index(&mut self, index: usize) -> &mut Dynamic { self.values.get_mut(index).expect("index is out of bounds") @@ -565,7 +565,7 @@ impl<'a> Scope<'a> { /// assert!(is_constant); /// assert_eq!(value.cast::(), "hello"); /// ``` - #[inline(always)] + #[inline] pub fn iter(&self) -> impl Iterator { self.iter_raw() .map(|(name, constant, value)| (name, constant, value.flatten_clone())) @@ -582,7 +582,7 @@ impl<'a> Scope<'a> { } impl<'a, K: Into>> Extend<(K, Dynamic)> for Scope<'a> { - #[inline(always)] + #[inline] fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(name, value)| { self.names.push((name.into(), Default::default())); diff --git a/src/token.rs b/src/token.rs index 1ffef163..5266b467 100644 --- a/src/token.rs +++ b/src/token.rs @@ -113,7 +113,7 @@ impl Position { /// If `line` is zero, then [`None`] is returned. /// /// If `position` is zero, then it is at the beginning of a line. - #[inline(always)] + #[inline] #[must_use] pub const fn new_const(line: u16, position: u16) -> Option { if line == 0 { @@ -129,7 +129,7 @@ impl Position { }) } /// Get the line number (1-based), or [`None`] if there is no position. - #[inline(always)] + #[inline] #[must_use] pub const fn line(self) -> Option { #[cfg(not(feature = "no_position"))] @@ -143,7 +143,7 @@ impl Position { return None; } /// Get the character position (1-based), or [`None`] if at beginning of a line. - #[inline(always)] + #[inline] #[must_use] pub const fn position(self) -> Option { #[cfg(not(feature = "no_position"))] @@ -157,7 +157,7 @@ impl Position { return None; } /// Advance by one character position. - #[inline(always)] + #[inline] pub(crate) fn advance(&mut self) { #[cfg(not(feature = "no_position"))] { @@ -174,7 +174,7 @@ impl Position { /// # Panics /// /// Panics if already at beginning of a line - cannot rewind to a previous line. - #[inline(always)] + #[inline] pub(crate) fn rewind(&mut self) { #[cfg(not(feature = "no_position"))] { @@ -184,7 +184,7 @@ impl Position { } } /// Advance to the next line. - #[inline(always)] + #[inline] pub(crate) fn new_line(&mut self) { #[cfg(not(feature = "no_position"))] { @@ -198,7 +198,7 @@ impl Position { } } /// Is this [`Position`] at the beginning of a line? - #[inline(always)] + #[inline] #[must_use] pub const fn is_beginning_of_line(self) -> bool { #[cfg(not(feature = "no_position"))] @@ -207,7 +207,7 @@ impl Position { return false; } /// Is there no [`Position`]? - #[inline(always)] + #[inline] #[must_use] pub const fn is_none(self) -> bool { #[cfg(not(feature = "no_position"))] @@ -216,7 +216,7 @@ impl Position { return true; } /// Print this [`Position`] for debug purposes. - #[inline(always)] + #[inline] pub(crate) fn debug_print(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { #[cfg(not(feature = "no_position"))] if !self.is_none() { @@ -1352,7 +1352,7 @@ fn is_numeric_digit(c: char) -> bool { /// Test if the comment block is a doc-comment. #[cfg(not(feature = "no_function"))] #[cfg(feature = "metadata")] -#[inline(always)] +#[inline] #[must_use] pub fn is_doc_comment(comment: &str) -> bool { (comment.starts_with("///") && !comment.starts_with("////")) diff --git a/src/unsafe.rs b/src/unsafe.rs index a6fe76f8..3ce5b4c9 100644 --- a/src/unsafe.rs +++ b/src/unsafe.rs @@ -8,7 +8,7 @@ use std::{ }; /// Cast a type into another type. -#[inline(always)] +#[inline] pub fn unsafe_try_cast(a: A) -> Result { if TypeId::of::() == a.type_id() { // SAFETY: Just checked we have the right type. We explicitly forget the @@ -25,7 +25,7 @@ pub fn unsafe_try_cast(a: A) -> Result { } /// Cast a Boxed type into another type. -#[inline(always)] +#[inline] pub fn unsafe_cast_box(item: Box) -> Result, Box> { // Only allow casting to the exact same type if TypeId::of::() == TypeId::of::() {