pub struct SpanContext<'a> {
pub line: usize,
pub col_start: Option<usize>,
pub col_end: Option<usize>,
pub source_line: Option<String>,
pub source: Option<&'a str>,
pub step_index: Option<usize>,
}Expand description
Location and diagnostic context threaded through lowering.
String parsers fill col_start, col_end, and source_line from
pest spans. Token stream parsers leave source_line as None;
macro call sites keep their own proc_macro2::Span for
syn::Error conversion (a span handle is not Send/Sync, so it
never lives inside ParseError, which must stay convertible into
anyhow::Error). Integer coordinates extracted from the span are
attached here instead.
Fields§
§line: usize1-based line number. Always populated on the string path.
col_start: Option<usize>1-based start column. None on token stream paths without locations.
col_end: Option<usize>1-based end column (inclusive). None on token stream paths.
source_line: Option<String>Raw source line text. None on token stream paths.
source: Option<&'a str>Full script text (borrowed, zero copy). Lets span refinement
resolve the exact source line for any line number, including
multi-line bodies, without ever faking text. None on token
stream paths and bare line fallbacks.
step_index: Option<usize>Zero-based step index in ScriptParser::parse, when known.
Implementations§
Source§impl<'a> SpanContext<'a>
impl<'a> SpanContext<'a>
Sourcepub fn line_only(line: usize) -> Self
pub fn line_only(line: usize) -> Self
Bare line context. Used only where no span is available
(direct lower_command calls, end of script errors).
Sourcepub fn full(
line: usize,
col_start: usize,
col_end: usize,
source_line: String,
) -> Self
pub fn full( line: usize, col_start: usize, col_end: usize, source_line: String, ) -> Self
Full string path context with column span and source text.
Sourcepub fn with_source(self, source: &'a str) -> Self
pub fn with_source(self, source: &'a str) -> Self
Attach the full script text for multi-line span resolution.
Trait Implementations§
Source§impl<'a> Clone for SpanContext<'a>
impl<'a> Clone for SpanContext<'a>
Source§fn clone(&self) -> SpanContext<'a>
fn clone(&self) -> SpanContext<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more