diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-03-15 11:30:13 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-03-15 11:30:13 +0100 |
| commit | ae0a56cdffa515ed6bb7cb566c025cc66ff00f33 (patch) | |
| tree | 586f4b12af74c7fc29e34960bab004b39425195c /src/eval | |
| parent | 6f5b721fe56fe6e3735d03b07e3716fc39572639 (diff) | |
Non-returning error macro
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/control.rs | 10 | ||||
| -rw-r--r-- | src/eval/mod.rs | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/eval/control.rs b/src/eval/control.rs index b310bfb8..166676d4 100644 --- a/src/eval/control.rs +++ b/src/eval/control.rs @@ -1,5 +1,5 @@ use super::{ops, EvalResult, Value}; -use crate::diag::{At, Error, TypError}; +use crate::diag::{At, TypError}; use crate::syntax::Span; /// A control flow event that occurred during evaluation. @@ -25,12 +25,14 @@ impl From<TypError> for Control { impl From<Control> for TypError { fn from(control: Control) -> Self { match control { - Control::Break(_, span) => Error::boxed(span, "cannot break outside of loop"), + Control::Break(_, span) => { + error!(span, "cannot break outside of loop") + } Control::Continue(_, span) => { - Error::boxed(span, "cannot continue outside of loop") + error!(span, "cannot continue outside of loop") } Control::Return(_, _, span) => { - Error::boxed(span, "cannot return outside of function") + error!(span, "cannot return outside of function") } Control::Err(e) => e, } diff --git a/src/eval/mod.rs b/src/eval/mod.rs index e00a40f2..4ccf377b 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -37,7 +37,7 @@ pub use value::*; use unicode_segmentation::UnicodeSegmentation; -use crate::diag::{At, Error, StrResult, Trace, Tracepoint, TypResult}; +use crate::diag::{At, StrResult, Trace, Tracepoint, TypResult}; use crate::geom::{Angle, Fractional, Length, Relative}; use crate::library; use crate::syntax::ast::*; @@ -725,11 +725,9 @@ impl Eval for IncludeExpr { fn import(ctx: &mut Context, path: &str, span: Span) -> TypResult<Module> { // Load the source file. let full = ctx.resolve(path); - let id = ctx.sources.load(&full).map_err(|err| { - Error::boxed(span, match err.kind() { - std::io::ErrorKind::NotFound => "file not found".into(), - _ => format!("failed to load source file ({})", err), - }) + let id = ctx.sources.load(&full).map_err(|err| match err.kind() { + std::io::ErrorKind::NotFound => error!(span, "file not found"), + _ => error!(span, "failed to load source file ({})", err), })?; // Prevent cyclic importing. |
