diff --git a/src/engine_api.rs b/src/engine_api.rs index fd1ac1c8..6636481f 100644 --- a/src/engine_api.rs +++ b/src/engine_api.rs @@ -1658,15 +1658,16 @@ impl Engine { mut ast: AST, optimization_level: OptimizationLevel, ) -> AST { - let lib = if cfg!(not(feature = "no_function")) { - ast.lib() - .iter_fn() - .filter(|f| f.func.is_script()) - .map(|f| (**f.func.get_fn_def()).clone()) - .collect() - } else { - Default::default() - }; + #[cfg(not(feature = "no_function"))] + let lib = ast + .lib() + .iter_fn() + .filter(|f| f.func.is_script()) + .map(|f| (**f.func.get_fn_def()).clone()) + .collect(); + + #[cfg(feature = "no_function")] + let lib = Default::default(); let stmt = mem::take(ast.statements_mut()); optimize_into_ast(self, scope, stmt, lib, optimization_level) diff --git a/src/module/mod.rs b/src/module/mod.rs index 6188b64f..20b56455 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1265,6 +1265,7 @@ impl Module { /// Get an iterator to the functions in the module. #[cfg(not(feature = "no_optimize"))] + #[cfg(not(feature = "no_function"))] #[inline(always)] pub(crate) fn iter_fn(&self) -> impl Iterator { self.functions.values() diff --git a/src/parser.rs b/src/parser.rs index f4f08b81..55819dd8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -32,7 +32,7 @@ use crate::{ use crate::stdlib::{ borrow::Cow, boxed::Box, - collections::{HashMap, HashSet}, + collections::HashMap, format, hash::Hash, iter::empty, @@ -45,6 +45,9 @@ use crate::stdlib::{ #[cfg(not(feature = "no_function"))] use crate::stdlib::hash::Hasher; +#[cfg(not(feature = "no_closure"))] +use crate::stdlib::collections::HashSet; + #[cfg(not(feature = "no_std"))] #[cfg(not(feature = "no_function"))] use crate::stdlib::collections::hash_map::DefaultHasher;