summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/model/reference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src/model/reference.rs')
-rw-r--r--crates/typst-library/src/model/reference.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs
index 7d44cccc..f22d70b3 100644
--- a/crates/typst-library/src/model/reference.rs
+++ b/crates/typst-library/src/model/reference.rs
@@ -5,7 +5,7 @@ use crate::diag::{bail, At, Hint, SourceResult};
use crate::engine::Engine;
use crate::foundations::{
cast, elem, Cast, Content, Context, Func, IntoValue, Label, NativeElement, Packed,
- Show, Smart, StyleChain, Synthesize,
+ Repr, Show, Smart, StyleChain, Synthesize,
};
use crate::introspection::{Counter, CounterKey, Locatable};
use crate::math::EquationElem;
@@ -229,8 +229,15 @@ impl Show for Packed<RefElem> {
// RefForm::Normal
if BibliographyElem::has(engine, self.target) {
- if elem.is_ok() {
- bail!(span, "label occurs in the document and its bibliography");
+ if let Ok(elem) = elem {
+ bail!(
+ span,
+ "label `{}` occurs both in the document and its bibliography",
+ self.target.repr();
+ hint: "change either the {}'s label or the \
+ bibliography key to resolve the ambiguity",
+ elem.func().name(),
+ );
}
return Ok(to_citation(self, engine, styles)?.pack().spanned(span));