Run rustfmt on error.rs

This commit is contained in:
Greg Shuflin 2021-10-30 00:07:05 -07:00
parent 6e7bd1ccb8
commit 08d66f0a43
1 changed files with 21 additions and 36 deletions

View File

@ -1,8 +1,10 @@
use crate::parsing::ParseError; use crate::{
use crate::schala::{SourceReference, Stage}; parsing::ParseError,
use crate::tokenizing::{Location, Token, TokenKind}; schala::{SourceReference, Stage},
use crate::symbol_table::SymbolError; symbol_table::SymbolError,
use crate::type_inference::TypeError; tokenizing::{Location, Token, TokenKind},
type_inference::TypeError,
};
pub struct SchalaError { pub struct SchalaError {
errors: Vec<Error>, errors: Vec<Error>,
@ -23,42 +25,28 @@ impl SchalaError {
pub(crate) fn from_type_error(err: TypeError) -> Self { pub(crate) fn from_type_error(err: TypeError) -> Self {
Self { Self {
formatted_parse_error: None, formatted_parse_error: None,
errors: vec![Error { errors: vec![Error { location: None, text: Some(err.msg), stage: Stage::Typechecking }],
location: None,
text: Some(err.msg),
stage: Stage::Typechecking,
}],
} }
} }
pub(crate) fn from_symbol_table(symbol_errs: Vec<SymbolError>) -> Self { pub(crate) fn from_symbol_table(symbol_errs: Vec<SymbolError>) -> Self {
//TODO this could be better //TODO this could be better
let errors = symbol_errs.into_iter().map(|_symbol_err| Error { let errors = symbol_errs
location: None, .into_iter()
text: Some("symbol table error".to_string()), .map(|_symbol_err| Error {
stage: Stage::Symbols location: None,
}).collect(); text: Some("symbol table error".to_string()),
Self { stage: Stage::Symbols,
errors, })
formatted_parse_error: None .collect();
} Self { errors, formatted_parse_error: None }
} }
pub(crate) fn from_string(text: String, stage: Stage) -> Self { pub(crate) fn from_string(text: String, stage: Stage) -> Self {
Self { Self { formatted_parse_error: None, errors: vec![Error { location: None, text: Some(text), stage }] }
formatted_parse_error: None,
errors: vec![Error {
location: None,
text: Some(text),
stage,
}],
}
} }
pub(crate) fn from_parse_error( pub(crate) fn from_parse_error(parse_error: ParseError, source_reference: &SourceReference) -> Self {
parse_error: ParseError,
source_reference: &SourceReference,
) -> Self {
Self { Self {
formatted_parse_error: Some(format_parse_error(parse_error, source_reference)), formatted_parse_error: Some(format_parse_error(parse_error, source_reference)),
errors: vec![], errors: vec![],
@ -81,10 +69,7 @@ impl SchalaError {
if token_errors.is_empty() { if token_errors.is_empty() {
None None
} else { } else {
Some(SchalaError { Some(SchalaError { errors: token_errors, formatted_parse_error: None })
errors: token_errors,
formatted_parse_error: None,
})
} }
} }
} }