refactor(frontmatter): Clarify the span

This commit is contained in:
Ed Page 2025-09-16 11:12:54 -05:00
parent b6326d3255
commit 42027af706
2 changed files with 6 additions and 6 deletions

View File

@ -286,14 +286,14 @@ fn is_whitespace(c: char) -> bool {
#[derive(Debug)]
pub struct FrontmatterError {
message: String,
span: Span,
primary_span: Span,
}
impl FrontmatterError {
pub fn new(message: impl Into<String>, span: Span) -> Self {
Self {
message: message.into(),
span,
primary_span: span,
}
}
@ -301,8 +301,8 @@ impl FrontmatterError {
self.message.as_str()
}
pub fn span(&self) -> Span {
self.span.clone()
pub fn primary_span(&self) -> Span {
self.primary_span.clone()
}
}

View File

@ -2783,7 +2783,7 @@ fn emit_frontmatter_diagnostic(
manifest_file: &Path,
gctx: &GlobalContext,
) -> anyhow::Error {
let span = e.span();
let primary_span = e.primary_span();
// Get the path to the manifest, relative to the cwd
let manifest_path = diff_paths(manifest_file, gctx.cwd())
@ -2793,7 +2793,7 @@ fn emit_frontmatter_diagnostic(
let group = Group::with_title(Level::ERROR.primary_title(e.message())).element(
Snippet::source(contents)
.path(manifest_path)
.annotation(AnnotationKind::Primary.span(span)),
.annotation(AnnotationKind::Primary.span(primary_span)),
);
if let Err(err) = gctx.shell().print_report(&[group], true) {