Add constant NO_POS.

This commit is contained in:
Stephen Chung
2020-11-02 12:50:27 +08:00
parent 6f3ce96d9d
commit d7d6f74dfd
29 changed files with 253 additions and 292 deletions

View File

@@ -4,7 +4,7 @@ use super::str::ImmutableStringDeserializer;
use crate::dynamic::{Dynamic, Union};
use crate::parse_error::ParseErrorType;
use crate::result::EvalAltResult;
use crate::token::Position;
use crate::token::NO_POS;
use crate::utils::ImmutableString;
use serde::de::{
@@ -45,12 +45,8 @@ impl<'de> DynamicDeserializer<'de> {
}
/// Shortcut for a type conversion error.
fn type_error_str<T>(&self, error: &str) -> Result<T, Box<EvalAltResult>> {
EvalAltResult::ErrorMismatchOutputType(
error.into(),
self.value.type_name().into(),
Position::none(),
)
.into()
EvalAltResult::ErrorMismatchOutputType(error.into(), self.value.type_name().into(), NO_POS)
.into()
}
fn deserialize_int<V: Visitor<'de>>(
&mut self,
@@ -127,8 +123,11 @@ pub fn from_dynamic<'de, T: Deserialize<'de>>(
impl Error for Box<EvalAltResult> {
fn custom<T: fmt::Display>(err: T) -> Self {
EvalAltResult::ErrorParsing(ParseErrorType::BadInput(err.to_string()), Position::none())
.into()
EvalAltResult::ErrorParsing(ParseErrorType::BadInput(
LexError::ImproperSymbol(err.to_string()),
NO_POS,
))
.into()
}
}