Fix builds.

This commit is contained in:
Stephen Chung 2022-06-09 18:22:53 +08:00
parent a31a4e4887
commit 09e19790fe
2 changed files with 29 additions and 13 deletions

View File

@ -6,9 +6,9 @@ use crate::types::dynamic::Variant;
use crate::{
Dynamic, Engine, OptimizationLevel, Position, RhaiResult, RhaiResultOf, Scope, AST, ERR,
};
use std::any::type_name;
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{any::type_name, mem};
impl Engine {
/// Evaluate a string.
@ -222,7 +222,7 @@ impl Engine {
global.source = ast.source_raw().clone();
#[cfg(not(feature = "no_module"))]
let orig_embedded_module_resolver = mem::replace(
let orig_embedded_module_resolver = std::mem::replace(
&mut global.embedded_module_resolver,
ast.resolver().cloned(),
);

View File

@ -497,10 +497,14 @@ impl Engine {
let root = namespace.root();
let index = state.find_module(root);
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_module"))]
let is_global = root == crate::engine::KEYWORD_GLOBAL;
#[cfg(any(feature = "no_function", feature = "no_module"))]
let is_global = false;
if settings.options.contains(LangOptions::STRICT_VAR) && index.is_none() {
if root != crate::engine::KEYWORD_GLOBAL
&& !self.global_sub_modules.contains_key(root)
{
if !is_global && !self.global_sub_modules.contains_key(root) {
return Err(PERR::ModuleUndefined(root.to_string())
.into_err(namespace.position()));
}
@ -557,10 +561,14 @@ impl Engine {
let root = namespace.root();
let index = state.find_module(root);
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_module"))]
let is_global = root == crate::engine::KEYWORD_GLOBAL;
#[cfg(any(feature = "no_function", feature = "no_module"))]
let is_global = false;
if settings.options.contains(LangOptions::STRICT_VAR) && index.is_none() {
if root != crate::engine::KEYWORD_GLOBAL
&& !self.global_sub_modules.contains_key(root)
{
if !is_global && !self.global_sub_modules.contains_key(root) {
return Err(PERR::ModuleUndefined(root.to_string())
.into_err(namespace.position()));
}
@ -1262,7 +1270,9 @@ impl Engine {
Token::Pipe | Token::Or if settings.options.contains(LangOptions::ANON_FN) => {
let mut new_state =
ParseState::new(self, state.scope, state.tokenizer_control.clone());
new_state.imports = state.imports.clone();
#[cfg(not(feature = "no_module"))]
new_state.imports.clone_from(&state.imports);
#[cfg(not(feature = "unchecked"))]
{
@ -1676,10 +1686,14 @@ impl Engine {
let root = namespace.root();
let index = state.find_module(root);
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_module"))]
let is_global = root == crate::engine::KEYWORD_GLOBAL;
#[cfg(any(feature = "no_function", feature = "no_module"))]
let is_global = false;
if settings.options.contains(LangOptions::STRICT_VAR) && index.is_none() {
if root != crate::engine::KEYWORD_GLOBAL
&& !self.global_sub_modules.contains_key(root)
{
if !is_global && !self.global_sub_modules.contains_key(root) {
return Err(PERR::ModuleUndefined(root.to_string())
.into_err(namespace.position()));
}
@ -3072,7 +3086,9 @@ impl Engine {
(Token::Fn, pos) => {
let mut new_state =
ParseState::new(self, state.scope, state.tokenizer_control.clone());
new_state.imports = state.imports.clone();
#[cfg(not(feature = "no_module"))]
new_state.imports.clone_from(&state.imports);
#[cfg(not(feature = "unchecked"))]
{