about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-22T20·01+0300
committertazjin <tazjin@tvl.su>2022-09-01T17·41+0000
commit51be6542c98158feb89e0e2d89f6b5165a070914 (patch)
tree48e6442ea010be3c19569043fd5000eb5503e692 /tvix
parent3bf487b98b747b5726713bc3abfc6af7a4b7ed33 (diff)
refactor(tvix/eval): add helper for emitting compiler warnings r/4570
Change-Id: I2d98dbb7274d07985f64e7cc8944e316bf42e1bf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6234
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/compiler.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs
index 7a27022d96de..0718f45ba777 100644
--- a/tvix/eval/src/compiler.rs
+++ b/tvix/eval/src/compiler.rs
@@ -135,10 +135,7 @@ impl Compiler {
                 Ok(())
             }
             ast::LiteralKind::Uri(u) => {
-                self.warnings.push(EvalWarning {
-                    node: node.syntax().clone(),
-                    kind: WarningKind::DeprecatedLiteralURL,
-                });
+                self.emit_warning(node.syntax().clone(), WarningKind::DeprecatedLiteralURL);
 
                 let idx = self
                     .chunk
@@ -610,10 +607,7 @@ impl Compiler {
                 // Within a `let` binding, inheriting from the outer
                 // scope is practically a no-op.
                 None => {
-                    self.warnings.push(EvalWarning {
-                        node: inherit.syntax().clone(),
-                        kind: WarningKind::UselessInherit,
-                    });
+                    self.emit_warning(inherit.syntax().clone(), WarningKind::UselessInherit);
 
                     continue;
                 }
@@ -827,6 +821,10 @@ impl Compiler {
 
         None
     }
+
+    fn emit_warning(&mut self, node: rnix::SyntaxNode, kind: WarningKind) {
+        self.warnings.push(EvalWarning { node, kind })
+    }
 }
 
 /// Convert a non-dynamic string expression to a string if possible,