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