Try 483e073

This commit is contained in:
Laurenz 2025-07-23 17:46:41 +02:00
parent 78355421ad
commit c3bfc5c6fd
5 changed files with 20 additions and 10 deletions

7
Cargo.lock generated
View File

@ -451,9 +451,9 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]] [[package]]
name = "comemo" name = "comemo"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/typst/comemo?rev=483e073#483e07350cc17b191c7968fa51eb6364d3edbbf4"
checksum = "df6916408a724339aa77b18214233355f3eb04c42eb895e5f8909215bd8a7a91"
dependencies = [ dependencies = [
"bumpalo",
"comemo-macros", "comemo-macros",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
@ -463,8 +463,7 @@ dependencies = [
[[package]] [[package]]
name = "comemo-macros" name = "comemo-macros"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/typst/comemo?rev=483e073#483e07350cc17b191c7968fa51eb6364d3edbbf4"
checksum = "c8936e42f9b4f5bdfaf23700609ac1f11cb03ad4c1ec128a4ee4fd0903e228db"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -163,3 +163,6 @@ manual_range_contains = "allow"
mutable_key_type = "allow" mutable_key_type = "allow"
uninlined_format_args = "warn" uninlined_format_args = "warn"
wildcard_in_or_patterns = "allow" wildcard_in_or_patterns = "allow"
[patch.crates-io]
comemo = { git = "https://github.com/typst/comemo", rev = "483e073" }

View File

@ -219,7 +219,7 @@ pub struct Route<'a> {
// We need to override the constraint's lifetime here so that `Tracked` is // We need to override the constraint's lifetime here so that `Tracked` is
// covariant over the constraint. If it becomes invariant, we're in for a // covariant over the constraint. If it becomes invariant, we're in for a
// world of lifetime pain. // world of lifetime pain.
outer: Option<Tracked<'a, Self, <Route<'static> as Validate>::Constraint>>, outer: Option<Tracked<'a, Self, <Route<'static> as Validate>::Call>>,
/// This is set if this route segment was inserted through the start of a /// This is set if this route segment was inserted through the start of a
/// module evaluation. /// module evaluation.
id: Option<FileId>, id: Option<FileId>,

View File

@ -312,7 +312,7 @@ enum LinkKind<'a> {
/// We need to override the constraint's lifetime here so that `Tracked` is /// We need to override the constraint's lifetime here so that `Tracked` is
/// covariant over the constraint. If it becomes invariant, we're in for a /// covariant over the constraint. If it becomes invariant, we're in for a
/// world of lifetime pain. /// world of lifetime pain.
Outer(Tracked<'a, Locator<'a>, <Locator<'static> as Validate>::Constraint>), Outer(Tracked<'a, Locator<'a>, <Locator<'static> as Validate>::Call>),
/// A link which indicates that we are in measurement mode. /// A link which indicates that we are in measurement mode.
Measure(Location), Measure(Location),
} }

View File

@ -39,7 +39,7 @@ pub use typst_syntax as syntax;
pub use typst_utils as utils; pub use typst_utils as utils;
use std::collections::HashSet; use std::collections::HashSet;
use std::sync::LazyLock; use std::sync::{LazyLock, Mutex};
use comemo::{Track, Tracked, Validate}; use comemo::{Track, Tracked, Validate};
use ecow::{EcoString, EcoVec, eco_format, eco_vec}; use ecow::{EcoString, EcoVec, eco_format, eco_vec};
@ -135,10 +135,11 @@ fn compile_impl<D: Document>(
subsink = Sink::new(); subsink = Sink::new();
let constraint = <Introspector as Validate>::Constraint::new(); let calls = Mutex::new(Vec::new());
let tracker = |call, hash| calls.lock().unwrap().push((call, hash));
let mut engine = Engine { let mut engine = Engine {
world, world,
introspector: introspector.track_with(&constraint), introspector: introspector.track_with(&tracker),
traced, traced,
sink: subsink.track_mut(), sink: subsink.track_mut(),
route: Route::default(), route: Route::default(),
@ -150,7 +151,14 @@ fn compile_impl<D: Document>(
introspector = document.introspector(); introspector = document.introspector();
iter += 1; iter += 1;
if timed!("check stabilized", introspector.validate(&constraint)) { if timed!(
"check stabilized",
calls
.into_inner()
.unwrap()
.into_iter()
.all(|(call, hash)| introspector.call(call) == hash)
) {
break; break;
} }