Rust API

ErrorSource

A source location attached to CompileError and PluginError.

ErrorSource is the shared source-location type attached to different errors. Both error types and ErrorSource are re-exported from the telarel crate.

pub struct ErrorSource { /* private fields */ }

Constructors and accessors

impl ErrorSource {
    pub fn from_code(
        file: impl Into<Arc<str>>,
        code: impl Into<Arc<str>>,
        span: Span,
    ) -> Self;

    pub fn from_ast(
        file: impl Into<Arc<str>>,
        ast: &Ast,
        span: Span,
    ) -> Self;

    pub fn file(&self) -> &str;

    pub fn code(&self) -> &str;

    pub fn span(&self) -> Span;
}
MethodDescription
from_codeCreates a location from a file name, its code, and a span.
from_astCreates a location that shares the Ast's source text.
fileThe file the span belongs to.
codeThe source text the span refers to.
spanThe span within code.

ErrorSource shares its source text, so attaching it to many errors does not copy the code.

Rust spans are UTF-8 byte offsets into the source text, matching oxc::span::Span.

Last updated on

Copyright © 2026, Alpheus

On this page