about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-12T12·24+0300
committertazjin <tazjin@tvl.su>2022-09-13T11·12+0000
commit118ac688008593276baa6160b186ba23e5a473de (patch)
tree38ce2dc3490fa63f42f545ccfea26a1995568cc5
parent4f67cf221ab4328637025c2b39e43d68a30c6813 (diff)
feat(corp/tvixbolt): use fancy warning formatting r/4831
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
-rw-r--r--corp/tvixbolt/src/main.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/corp/tvixbolt/src/main.rs b/corp/tvixbolt/src/main.rs
index c359eaed63..ee73fce71d 100644
--- a/corp/tvixbolt/src/main.rs
+++ b/corp/tvixbolt/src/main.rs
@@ -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();
     }