From 187dcc4d3aede829be4d763e6c7afd20c18a6774 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 19 Jul 2025 10:25:48 +0200 Subject: [PATCH] More unlocatables --- crates/typst-library/src/foundations/content/mod.rs | 9 +++++++-- crates/typst-library/src/foundations/symbol.rs | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/typst-library/src/foundations/content/mod.rs b/crates/typst-library/src/foundations/content/mod.rs index 7ba790d88..0dbde4f13 100644 --- a/crates/typst-library/src/foundations/content/mod.rs +++ b/crates/typst-library/src/foundations/content/mod.rs @@ -30,6 +30,7 @@ use crate::foundations::{ RecipeIndex, Repr, Selector, Str, Style, StyleChain, Styles, Value, }; use crate::introspection::Location; +use crate::introspection::Unlocatable; use crate::layout::{AlignElem, Alignment, Axes, Length, MoveElem, PadElem, Rel, Sides}; use crate::model::{Destination, EmphElem, LinkElem, StrongElem}; use crate::text::UnderlineElem; @@ -705,7 +706,7 @@ impl Serialize for Content { } /// A sequence of content. -#[elem(Debug, Repr)] +#[elem(Debug, Repr, Unlocatable)] pub struct SequenceElem { /// The elements. #[required] @@ -719,6 +720,8 @@ impl Debug for SequenceElem { } } +impl Unlocatable for Packed {} + // Derive is currently incompatible with `elem` macro. #[allow(clippy::derivable_impls)] impl Default for SequenceElem { @@ -742,7 +745,7 @@ impl Repr for SequenceElem { } /// Content alongside styles. -#[elem(Debug, Repr, PartialEq)] +#[elem(Debug, Repr, PartialEq, Unlocatable)] pub struct StyledElem { /// The content. #[required] @@ -761,6 +764,8 @@ impl Debug for StyledElem { } } +impl Unlocatable for Packed {} + impl PartialEq for StyledElem { fn eq(&self, other: &Self) -> bool { self.child == other.child diff --git a/crates/typst-library/src/foundations/symbol.rs b/crates/typst-library/src/foundations/symbol.rs index f57bb0c2a..4b54a5e2e 100644 --- a/crates/typst-library/src/foundations/symbol.rs +++ b/crates/typst-library/src/foundations/symbol.rs @@ -13,6 +13,7 @@ use crate::foundations::{ cast, elem, func, scope, ty, Array, Content, Func, NativeElement, NativeFunc, Packed, PlainText, Repr as _, }; +use crate::introspection::Unlocatable; /// A Unicode symbol. /// @@ -413,7 +414,7 @@ impl<'a> Iterator for Variants<'a> { } /// A single character. -#[elem(Repr, PlainText)] +#[elem(Repr, PlainText, Unlocatable)] pub struct SymbolElem { /// The symbol's character. #[required] @@ -439,3 +440,5 @@ impl crate::foundations::Repr for SymbolElem { eco_format!("[{}]", self.text) } } + +impl Unlocatable for Packed {}