From 80491a459c335f4e13aa11da89641caf83175117 Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Tue, 20 May 2025 14:35:57 +0200 Subject: [PATCH] docs: update some comments --- crates/typst-library/src/diag.rs | 5 ++++- crates/typst-library/src/model/bibliography.rs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/typst-library/src/diag.rs b/crates/typst-library/src/diag.rs index e12a53a22..aa2783af7 100644 --- a/crates/typst-library/src/diag.rs +++ b/crates/typst-library/src/diag.rs @@ -151,7 +151,7 @@ pub struct Warned { pub warnings: EcoVec, } -/// An error or warning in a source file. +/// An error or warning in a source or text file. /// /// The contained spans will only be detached if any of the input source files /// were detached. @@ -574,8 +574,11 @@ impl From for EcoString { pub type LoadResult = Result; /// A callsite independent error that occurred during data loading. +/// This avoids polluting the memoization with [`Span`]s and [`FileId`]s from source files. /// Can be turned into a [`SourceDiagnostic`] using the [`LoadedAt::in_text`] /// or [`LoadedAt::in_invalid_text`] methods available on [`LoadResult`]. +/// +/// [`FileId`]: typst_syntax::FileId #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct LoadError { pub pos: ReportPos, diff --git a/crates/typst-library/src/model/bibliography.rs b/crates/typst-library/src/model/bibliography.rs index 6c447ff1e..f1e3c7665 100644 --- a/crates/typst-library/src/model/bibliography.rs +++ b/crates/typst-library/src/model/bibliography.rs @@ -307,7 +307,6 @@ impl Bibliography { #[typst_macros::time(name = "load bibliography")] fn decode(data: &[Loaded]) -> SourceResult { let mut map = IndexMap::new(); - // TODO: store spans of entries for duplicate key error messages let mut duplicates = Vec::::new(); // We might have multiple bib/yaml files @@ -326,8 +325,9 @@ impl Bibliography { } if !duplicates.is_empty() { - // TODO: errors with spans of source files, - // requires hayagriva entries to store the range + // TODO: Store spans of entries for duplicate key error messages. + // Requires hayagriva entries to store their location, which should + // be fine, since they are 1kb anyway. let span = data.first().unwrap().source.span; bail!(span, "duplicate bibliography keys: {}", duplicates.join(", ")); }