From c3bfc5c6fde245bd5a1e31afc0b029824ddf7c86 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 23 Jul 2025 17:46:41 +0200 Subject: [PATCH] Try 483e073 --- Cargo.lock | 7 +++---- Cargo.toml | 3 +++ crates/typst-library/src/engine.rs | 2 +- .../typst-library/src/introspection/locator.rs | 2 +- crates/typst/src/lib.rs | 16 ++++++++++++---- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e5fb87ee..d3460ad20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,9 +451,9 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comemo" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df6916408a724339aa77b18214233355f3eb04c42eb895e5f8909215bd8a7a91" +source = "git+https://github.com/typst/comemo?rev=483e073#483e07350cc17b191c7968fa51eb6364d3edbbf4" dependencies = [ + "bumpalo", "comemo-macros", "once_cell", "parking_lot", @@ -463,8 +463,7 @@ dependencies = [ [[package]] name = "comemo-macros" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8936e42f9b4f5bdfaf23700609ac1f11cb03ad4c1ec128a4ee4fd0903e228db" +source = "git+https://github.com/typst/comemo?rev=483e073#483e07350cc17b191c7968fa51eb6364d3edbbf4" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 500d116a6..d9cb5dfa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -163,3 +163,6 @@ manual_range_contains = "allow" mutable_key_type = "allow" uninlined_format_args = "warn" wildcard_in_or_patterns = "allow" + +[patch.crates-io] +comemo = { git = "https://github.com/typst/comemo", rev = "483e073" } diff --git a/crates/typst-library/src/engine.rs b/crates/typst-library/src/engine.rs index cb98f4599..af12e9136 100644 --- a/crates/typst-library/src/engine.rs +++ b/crates/typst-library/src/engine.rs @@ -219,7 +219,7 @@ pub struct Route<'a> { // 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 // world of lifetime pain. - outer: Option as Validate>::Constraint>>, + outer: Option as Validate>::Call>>, /// This is set if this route segment was inserted through the start of a /// module evaluation. id: Option, diff --git a/crates/typst-library/src/introspection/locator.rs b/crates/typst-library/src/introspection/locator.rs index 3ba3d6486..9b28e5236 100644 --- a/crates/typst-library/src/introspection/locator.rs +++ b/crates/typst-library/src/introspection/locator.rs @@ -312,7 +312,7 @@ enum LinkKind<'a> { /// 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 /// world of lifetime pain. - Outer(Tracked<'a, Locator<'a>, as Validate>::Constraint>), + Outer(Tracked<'a, Locator<'a>, as Validate>::Call>), /// A link which indicates that we are in measurement mode. Measure(Location), } diff --git a/crates/typst/src/lib.rs b/crates/typst/src/lib.rs index 47e5531fd..c3db27f54 100644 --- a/crates/typst/src/lib.rs +++ b/crates/typst/src/lib.rs @@ -39,7 +39,7 @@ pub use typst_syntax as syntax; pub use typst_utils as utils; use std::collections::HashSet; -use std::sync::LazyLock; +use std::sync::{LazyLock, Mutex}; use comemo::{Track, Tracked, Validate}; use ecow::{EcoString, EcoVec, eco_format, eco_vec}; @@ -135,10 +135,11 @@ fn compile_impl( subsink = Sink::new(); - let constraint = ::Constraint::new(); + let calls = Mutex::new(Vec::new()); + let tracker = |call, hash| calls.lock().unwrap().push((call, hash)); let mut engine = Engine { world, - introspector: introspector.track_with(&constraint), + introspector: introspector.track_with(&tracker), traced, sink: subsink.track_mut(), route: Route::default(), @@ -150,7 +151,14 @@ fn compile_impl( introspector = document.introspector(); 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; }