Fix no_function build.

This commit is contained in:
Stephen Chung 2020-11-08 10:56:33 +08:00
parent b3d318ef7f
commit 760f6c3678
3 changed files with 15 additions and 10 deletions

View File

@ -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)

View File

@ -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<Item = &FuncInfo> {
self.functions.values()

View File

@ -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;