Skip to content

Commit 42027af

Browse files
committed
refactor(frontmatter): Clarify the span
1 parent b6326d3 commit 42027af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cargo/util/frontmatter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,23 @@ fn is_whitespace(c: char) -> bool {
286286
#[derive(Debug)]
287287
pub struct FrontmatterError {
288288
message: String,
289-
span: Span,
289+
primary_span: Span,
290290
}
291291

292292
impl FrontmatterError {
293293
pub fn new(message: impl Into<String>, span: Span) -> Self {
294294
Self {
295295
message: message.into(),
296-
span,
296+
primary_span: span,
297297
}
298298
}
299299

300300
pub fn message(&self) -> &str {
301301
self.message.as_str()
302302
}
303303

304-
pub fn span(&self) -> Span {
305-
self.span.clone()
304+
pub fn primary_span(&self) -> Span {
305+
self.primary_span.clone()
306306
}
307307
}
308308

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,7 +2783,7 @@ fn emit_frontmatter_diagnostic(
27832783
manifest_file: &Path,
27842784
gctx: &GlobalContext,
27852785
) -> anyhow::Error {
2786-
let span = e.span();
2786+
let primary_span = e.primary_span();
27872787

27882788
// Get the path to the manifest, relative to the cwd
27892789
let manifest_path = diff_paths(manifest_file, gctx.cwd())
@@ -2793,7 +2793,7 @@ fn emit_frontmatter_diagnostic(
27932793
let group = Group::with_title(Level::ERROR.primary_title(e.message())).element(
27942794
Snippet::source(contents)
27952795
.path(manifest_path)
2796-
.annotation(AnnotationKind::Primary.span(span)),
2796+
.annotation(AnnotationKind::Primary.span(primary_span)),
27972797
);
27982798

27992799
if let Err(err) = gctx.shell().print_report(&[group], true) {

0 commit comments

Comments
 (0)