Remove unnecessary Box::new().
This commit is contained in:
parent
8b0299077b
commit
bd35999b75
@ -345,17 +345,19 @@ impl ModuleResolver for FileModuleResolver {
|
|||||||
let file_path = self.get_file_path(path, source_path);
|
let file_path = self.get_file_path(path, source_path);
|
||||||
|
|
||||||
// Load the script file and compile it
|
// Load the script file and compile it
|
||||||
match engine.compile_file(file_path).map_err(|err| match *err {
|
Some(
|
||||||
EvalAltResult::ErrorSystem(_, err) if err.is::<IoError>() => {
|
engine
|
||||||
Box::new(EvalAltResult::ErrorModuleNotFound(path.to_string(), pos))
|
.compile_file(file_path)
|
||||||
}
|
.map(|mut ast| {
|
||||||
_ => Box::new(EvalAltResult::ErrorInModule(path.to_string(), err, pos)),
|
|
||||||
}) {
|
|
||||||
Ok(mut ast) => {
|
|
||||||
ast.set_source(path);
|
ast.set_source(path);
|
||||||
Some(Ok(ast))
|
ast
|
||||||
}
|
})
|
||||||
err => Some(err),
|
.map_err(|err| match *err {
|
||||||
|
EvalAltResult::ErrorSystem(_, err) if err.is::<IoError>() => {
|
||||||
|
EvalAltResult::ErrorModuleNotFound(path.to_string(), pos).into()
|
||||||
}
|
}
|
||||||
|
_ => EvalAltResult::ErrorInModule(path.to_string(), err, pos).into(),
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,11 @@ where
|
|||||||
return EvalAltResult::ErrorInFunctionCall(
|
return EvalAltResult::ErrorInFunctionCall(
|
||||||
"range".to_string(),
|
"range".to_string(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
Box::new(EvalAltResult::ErrorArithmetic(
|
EvalAltResult::ErrorArithmetic(
|
||||||
"step value cannot be zero".to_string(),
|
"step value cannot be zero".to_string(),
|
||||||
crate::Position::NONE,
|
crate::Position::NONE,
|
||||||
)),
|
)
|
||||||
|
.into(),
|
||||||
crate::Position::NONE,
|
crate::Position::NONE,
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
@ -314,7 +315,7 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
|
|||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
if step == 0.0 {
|
if step == 0.0 {
|
||||||
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
|
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
|
||||||
Box::new(EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE)),
|
EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE).into(),
|
||||||
crate::Position::NONE,
|
crate::Position::NONE,
|
||||||
).into();
|
).into();
|
||||||
}
|
}
|
||||||
@ -376,7 +377,7 @@ def_package!(crate:BasicIteratorPackage:"Basic range iterators.", lib, {
|
|||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
if step.is_zero() {
|
if step.is_zero() {
|
||||||
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
|
return EvalAltResult::ErrorInFunctionCall("range".to_string(), "".to_string(),
|
||||||
Box::new(EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE)),
|
EvalAltResult::ErrorArithmetic("step value cannot be zero".to_string(), crate::Position::NONE).into(),
|
||||||
crate::Position::NONE,
|
crate::Position::NONE,
|
||||||
).into();
|
).into();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ mod core_functions {
|
|||||||
#[rhai_fn(name = "set_tag", set = "tag", return_raw)]
|
#[rhai_fn(name = "set_tag", set = "tag", return_raw)]
|
||||||
pub fn set_tag(value: &mut Dynamic, tag: INT) -> Result<(), Box<EvalAltResult>> {
|
pub fn set_tag(value: &mut Dynamic, tag: INT) -> Result<(), Box<EvalAltResult>> {
|
||||||
if tag < Tag::MIN as INT {
|
if tag < Tag::MIN as INT {
|
||||||
Err(Box::new(EvalAltResult::ErrorArithmetic(
|
EvalAltResult::ErrorArithmetic(
|
||||||
format!(
|
format!(
|
||||||
"{} is too small to fit into a tag (must be between {} and {})",
|
"{} is too small to fit into a tag (must be between {} and {})",
|
||||||
tag,
|
tag,
|
||||||
@ -22,9 +22,10 @@ mod core_functions {
|
|||||||
Tag::MAX
|
Tag::MAX
|
||||||
),
|
),
|
||||||
Position::NONE,
|
Position::NONE,
|
||||||
)))
|
)
|
||||||
|
.into()
|
||||||
} else if tag > Tag::MAX as INT {
|
} else if tag > Tag::MAX as INT {
|
||||||
Err(Box::new(EvalAltResult::ErrorArithmetic(
|
EvalAltResult::ErrorArithmetic(
|
||||||
format!(
|
format!(
|
||||||
"{} is too large to fit into a tag (must be between {} and {})",
|
"{} is too large to fit into a tag (must be between {} and {})",
|
||||||
tag,
|
tag,
|
||||||
@ -32,7 +33,8 @@ mod core_functions {
|
|||||||
Tag::MAX
|
Tag::MAX
|
||||||
),
|
),
|
||||||
Position::NONE,
|
Position::NONE,
|
||||||
)))
|
)
|
||||||
|
.into()
|
||||||
} else {
|
} else {
|
||||||
value.set_tag(tag as Tag);
|
value.set_tag(tag as Tag);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -130,13 +130,9 @@ fn test_custom_syntax_raw() -> Result<(), Box<EvalAltResult>> {
|
|||||||
1 => Ok(Some("$ident$".into())),
|
1 => Ok(Some("$ident$".into())),
|
||||||
2 => match stream[1].as_str() {
|
2 => match stream[1].as_str() {
|
||||||
"world" | "kitty" => Ok(None),
|
"world" | "kitty" => Ok(None),
|
||||||
s => Err(ParseError(
|
s => Err(LexError::ImproperSymbol(s.to_string(), Default::default())
|
||||||
Box::new(ParseErrorType::BadInput(LexError::ImproperSymbol(
|
.into_err(Position::NONE)
|
||||||
s.to_string(),
|
.into()),
|
||||||
Default::default(),
|
|
||||||
))),
|
|
||||||
Position::NONE,
|
|
||||||
)),
|
|
||||||
},
|
},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user