From 008ef0a41be3e62b08bbc62bc5ad741f8995d2d1 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 14 Mar 2021 10:47:21 +0800 Subject: [PATCH] Fix feature builds. --- src/fn_call.rs | 2 ++ src/optimize.rs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index c2b594d3..f4c3c0e6 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -607,6 +607,7 @@ impl Engine { } // Does a scripted function exist? + #[cfg(not(feature = "no_function"))] #[inline(always)] pub(crate) fn has_script_fn( &self, @@ -734,6 +735,7 @@ impl Engine { } // Scripted function call? + #[cfg(not(feature = "no_function"))] let hash_script = if hash.is_native_only() { None } else { diff --git a/src/optimize.rs b/src/optimize.rs index 7c863747..3cf81224 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -240,20 +240,26 @@ fn optimize_stmt_block( .find_map(|(i, stmt)| match stmt { stmt if !is_pure(stmt) => Some(i), - Stmt::Noop(_) | Stmt::Return(_, None, _) | Stmt::Export(_, _) | Stmt::Share(_) => { - None - } + Stmt::Noop(_) | Stmt::Return(_, None, _) => None, Stmt::Let(e, _, _, _) | Stmt::Const(e, _, _, _) | Stmt::Expr(e) | Stmt::Return(_, Some(e), _) - | Stmt::Import(e, _, _) if e.is_constant() => { None } + #[cfg(not(feature = "no_module"))] + Stmt::Import(e, _, _) if e.is_constant() => None, + + #[cfg(not(feature = "no_module"))] + Stmt::Export(_, _) => None, + + #[cfg(not(feature = "no_closure"))] + Stmt::Share(_) => None, + _ => Some(i), }) .map_or(0, |n| statements.len() - n); @@ -370,8 +376,6 @@ fn optimize_stmt_block( state.set_dirty(); } - println!("{:?}", statements); - statements.shrink_to_fit(); statements }