Fix no_std builds.

This commit is contained in:
Stephen Chung 2020-07-31 17:26:49 +08:00
parent c8a60875ec
commit d563b878aa
3 changed files with 15 additions and 6 deletions

View File

@ -696,6 +696,7 @@ impl Dynamic {
match self.0 {
Union::Variant(value) => (*value).as_box_any().downcast().map(|x| *x).ok(),
#[cfg(not(feature = "no_shared"))]
Union::Shared(_) => unreachable!(),
_ => None,
}

View File

@ -1354,6 +1354,7 @@ impl Engine {
.get_fn(hash_fn, false)
.or_else(|| self.packages.get_fn(hash_fn, false))
{
#[cfg(not(feature = "no_shared"))]
let mut lock_guard;
#[cfg(not(feature = "no_shared"))]

View File

@ -5,7 +5,7 @@ use crate::calc_fn_hash;
use crate::engine::{
search_imports, search_namespace, search_scope_only, Engine, Imports, State, KEYWORD_DEBUG,
KEYWORD_EVAL, KEYWORD_FN_PTR, KEYWORD_FN_PTR_CALL, KEYWORD_FN_PTR_CURRY, KEYWORD_PRINT,
KEYWORD_TYPE_OF,
KEYWORD_SHARED, KEYWORD_TAKE, KEYWORD_TYPE_OF,
};
use crate::error::ParseErrorType;
use crate::fn_native::{FnCallArgs, FnPtr};
@ -34,9 +34,6 @@ use crate::engine::{FN_IDX_GET, FN_IDX_SET};
#[cfg(not(feature = "no_object"))]
use crate::engine::{Map, Target, FN_GET, FN_SET};
#[cfg(not(feature = "no_shared"))]
use crate::engine::{KEYWORD_SHARED, KEYWORD_TAKE};
use crate::stdlib::{
any::{type_name, TypeId},
boxed::Box,
@ -661,10 +658,20 @@ impl Engine {
))
} else if _fn_name == KEYWORD_SHARED && idx.is_empty() {
// take call
Ok((obj.clone().into_shared(), false))
#[cfg(not(feature = "no_shared"))]
{
Ok((obj.clone().into_shared(), false))
}
#[cfg(feature = "no_shared")]
unreachable!()
} else if _fn_name == KEYWORD_TAKE && idx.is_empty() {
// take call
Ok((obj.clone_inner_data::<Dynamic>().unwrap(), false))
#[cfg(not(feature = "no_shared"))]
{
Ok((obj.clone_inner_data::<Dynamic>().unwrap(), false))
}
#[cfg(feature = "no_shared")]
unreachable!()
} else {
#[cfg(not(feature = "no_object"))]
let redirected;