diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 472f4aaf3..1463bb100 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -15,7 +15,6 @@ mod bindings; mod scope; -mod spans; use codemap::Span; use path_clean::PathClean; @@ -31,11 +30,11 @@ use crate::chunk::Chunk; use crate::errors::{Error, ErrorKind, EvalResult}; use crate::observer::CompilerObserver; use crate::opcode::{CodeIdx, Count, JumpOffset, OpCode, UpvalueIdx}; +use crate::spans::ToSpan; use crate::value::{Closure, Lambda, Thunk, Value}; use crate::warnings::{EvalWarning, WarningKind}; use self::scope::{LocalIdx, LocalPosition, Scope, Upvalue, UpvalueKind}; -use self::spans::ToSpan; /// Represents the result of compiling a piece of Nix code. If /// compilation was successful, the resulting bytecode can be passed @@ -99,6 +98,12 @@ struct Compiler<'observer> { observer: &'observer mut dyn CompilerObserver, } +impl Compiler<'_> { + pub(super) fn span_for(&self, to_span: &S) -> Span { + to_span.span_for(&self.file) + } +} + /// Compiler construction impl<'observer> Compiler<'observer> { pub(crate) fn new( diff --git a/tvix/eval/src/lib.rs b/tvix/eval/src/lib.rs index 847447cc8..b4ffd2585 100644 --- a/tvix/eval/src/lib.rs +++ b/tvix/eval/src/lib.rs @@ -6,6 +6,7 @@ mod eval; pub mod observer; mod opcode; mod source; +mod spans; mod upvalues; mod value; mod vm; diff --git a/tvix/eval/src/compiler/spans.rs b/tvix/eval/src/spans.rs similarity index 89% rename from tvix/eval/src/compiler/spans.rs rename to tvix/eval/src/spans.rs index 6c11961e0..c17ad2102 100644 --- a/tvix/eval/src/compiler/spans.rs +++ b/tvix/eval/src/spans.rs @@ -1,11 +1,12 @@ -//! Utilities for dealing with span tracking in the compiler. +//! Utilities for dealing with span tracking in the compiler and in +//! error reporting. -use super::*; use codemap::{File, Span}; +use rnix::ast; use rowan::ast::AstNode; /// Trait implemented by all types from which we can retrieve a span. -pub(super) trait ToSpan { +pub trait ToSpan { fn span_for(&self, file: &File) -> Span; } @@ -76,9 +77,3 @@ expr_to_span!(ast::Select); expr_to_span!(ast::Str); expr_to_span!(ast::UnaryOp); expr_to_span!(ast::With); - -impl Compiler<'_> { - pub(super) fn span_for(&self, to_span: &S) -> Span { - to_span.span_for(&self.file) - } -}