steal from jai
This commit is contained in:
+15
-4
@@ -1,3 +1,5 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Span {
|
||||
pub file: usize,
|
||||
@@ -32,7 +34,7 @@ pub struct CompilerMsg {
|
||||
#[derive(Default)]
|
||||
pub struct CompilerOutput {
|
||||
pub errors: Vec<CompilerMsg>,
|
||||
pub files: Vec<String>,
|
||||
pub files: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl CompilerOutput {
|
||||
@@ -98,7 +100,7 @@ impl Span {
|
||||
&text[self.start..=srange.end - 1],
|
||||
)?;
|
||||
if *eline != *sline + 1 {
|
||||
writeln!(w, " ...")?;
|
||||
writeln!(w, " ...")?;
|
||||
}
|
||||
writeln!(
|
||||
w,
|
||||
@@ -112,10 +114,19 @@ impl Span {
|
||||
}
|
||||
|
||||
impl From<String> for CompilerMsg {
|
||||
fn from(value: String) -> Self {
|
||||
fn from(msg: String) -> Self {
|
||||
Self {
|
||||
spans: Vec::new(),
|
||||
msg: value.to_string(),
|
||||
msg,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Into<String>> From<(S, Span)> for CompilerMsg {
|
||||
fn from((msg, span): (S, Span)) -> Self {
|
||||
Self {
|
||||
spans: vec![span],
|
||||
msg: msg.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user