feat(corp/tvixbolt): use fancy warning formatting

Unfortunately the codemap-diagnostic crate doesn't provide a way to
get colour control characters written to an arbitrary writer, so this
is black & white only, but we can look at this later if we introduce
something even fancier. For now it's reasonable.

Change-Id: I1c7655cc4b254f77768b5931bc95fa13b3bd7e12
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6533
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-09-12 15:24:51 +03:00 committed by tazjin
parent 4f67cf221a
commit 118ac68800

View file

@ -222,7 +222,7 @@ fn eval(trace: bool, code: &str) -> Output {
.expect("expression should exist if no errors occured");
let codemap = Rc::new(codemap);
let mut compilation_observer = DisassemblingObserver::new(codemap, &mut out.bytecode);
let mut compilation_observer = DisassemblingObserver::new(codemap.clone(), &mut out.bytecode);
let result = tvix_eval::compile(
root_expr,
@ -236,10 +236,8 @@ fn eval(trace: bool, code: &str) -> Output {
for warning in result.warnings {
writeln!(
&mut out.warnings,
"warning: {:?} at `{}` [line {}]",
warning.kind,
file.source_slice(warning.span),
file.find_line(warning.span.low()) + 1
"{}\n",
warning.fancy_format_str(&codemap).trim(),
)
.unwrap();
}