git.delta.rocks / jrsonnet / refs/commits / bde2637fa85f

difftreelog

build switch to released gcmodule fork

Yaroslav Bolyukin2022-06-05parent: #d76beb2.patch.diff
in: master

38 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -25,9 +25,9 @@
 
 [[package]]
 name = "anyhow"
-version = "1.0.49"
+version = "1.0.57"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a03e93e97a28fbc9f42fbc5ba0886a3c67eb637b476dbee711f80a6ffe8223d"
+checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
 
 [[package]]
 name = "atty"
@@ -42,9 +42,9 @@
 
 [[package]]
 name = "autocfg"
-version = "1.0.1"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
 [[package]]
 name = "base64"
@@ -69,9 +69,9 @@
 
 [[package]]
 name = "cc"
-version = "1.0.72"
+version = "1.0.73"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
 
 [[package]]
 name = "cfg-if"
@@ -87,9 +87,9 @@
 
 [[package]]
 name = "clap"
-version = "3.1.13"
+version = "3.1.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4b3ee449efa0c4f95cd48b00539829d3655a98e189a90617246492788d22404"
+checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
 dependencies = [
  "atty",
  "bitflags",
@@ -104,18 +104,18 @@
 
 [[package]]
 name = "clap_complete"
-version = "3.1.3"
+version = "3.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d7ca9141e27e6ebc52e3c378b0c07f3cea52db46ed1cc5861735fb697b56356"
+checksum = "da92e6facd8d73c22745a5d3cbb59bdf8e46e3235c923e516527d8e81eec14a4"
 dependencies = [
  "clap",
 ]
 
 [[package]]
 name = "clap_derive"
-version = "3.1.7"
+version = "3.1.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
+checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
 dependencies = [
  "heck",
  "proc-macro-error",
@@ -147,26 +147,6 @@
 version = "0.4.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0"
-
-[[package]]
-name = "gcmodule"
-version = "0.3.3"
-source = "git+https://github.com/CertainLach/gcmodule?branch=jrsonnet#f72713c24c2b1bf5a78f1d01bee5a0f52bc2a094"
-dependencies = [
- "gcmodule_derive",
- "parking_lot",
-]
-
-[[package]]
-name = "gcmodule_derive"
-version = "0.3.3"
-source = "git+https://github.com/CertainLach/gcmodule?branch=jrsonnet#f72713c24c2b1bf5a78f1d01bee5a0f52bc2a094"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
-]
 
 [[package]]
 name = "getrandom"
@@ -211,9 +191,9 @@
 
 [[package]]
 name = "indexmap"
-version = "1.7.0"
+version = "1.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
+checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
 dependencies = [
  "autocfg",
  "hashbrown 0.11.2",
@@ -221,9 +201,9 @@
 
 [[package]]
 name = "itoa"
-version = "0.4.8"
+version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
+checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
 
 [[package]]
 name = "jrsonnet"
@@ -231,9 +211,9 @@
 dependencies = [
  "clap",
  "clap_complete",
- "gcmodule",
  "jrsonnet-cli",
  "jrsonnet-evaluator",
+ "jrsonnet-gcmodule",
  "jrsonnet-parser",
  "mimallocator",
  "thiserror",
@@ -244,8 +224,8 @@
 version = "0.4.2"
 dependencies = [
  "clap",
- "gcmodule",
  "jrsonnet-evaluator",
+ "jrsonnet-gcmodule",
  "jrsonnet-parser",
 ]
 
@@ -257,8 +237,8 @@
  "anyhow",
  "base64",
  "bincode",
- "gcmodule",
  "hashbrown 0.12.1",
+ "jrsonnet-gcmodule",
  "jrsonnet-interner",
  "jrsonnet-macros",
  "jrsonnet-parser",
@@ -276,11 +256,32 @@
 ]
 
 [[package]]
+name = "jrsonnet-gcmodule"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22d4e1572e4b61e4f5deb3701312a330df0e69b48805a540d740e5e53ac8c78a"
+dependencies = [
+ "jrsonnet-gcmodule-derive",
+ "parking_lot",
+]
+
+[[package]]
+name = "jrsonnet-gcmodule-derive"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae2f3bf7d38e0a9098b5b9062a7d9e7a97a206bc3c91118d76e7e37f2e0f1202"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
 name = "jrsonnet-interner"
 version = "0.4.2"
 dependencies = [
- "gcmodule",
  "hashbrown 0.12.1",
+ "jrsonnet-gcmodule",
  "rustc-hash",
  "serde",
 ]
@@ -298,7 +299,7 @@
 name = "jrsonnet-parser"
 version = "0.4.2"
 dependencies = [
- "gcmodule",
+ "jrsonnet-gcmodule",
  "jrsonnet-interner",
  "jrsonnet-stdlib",
  "peg",
@@ -314,7 +315,7 @@
 name = "jrsonnet-types"
 version = "0.4.2"
 dependencies = [
- "gcmodule",
+ "jrsonnet-gcmodule",
  "peg",
 ]
 
@@ -322,8 +323,8 @@
 name = "jsonnet"
 version = "0.4.2"
 dependencies = [
- "gcmodule",
  "jrsonnet-evaluator",
+ "jrsonnet-gcmodule",
  "jrsonnet-parser",
 ]
 
@@ -335,9 +336,9 @@
 
 [[package]]
 name = "libc"
-version = "0.2.125"
+version = "0.2.126"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
+checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
 
 [[package]]
 name = "linked-hash-map"
@@ -381,15 +382,15 @@
 
 [[package]]
 name = "once_cell"
-version = "1.10.0"
+version = "1.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
+checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
 
 [[package]]
 name = "os_str_bytes"
-version = "6.0.0"
+version = "6.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
+checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
 
 [[package]]
 name = "parking_lot"
@@ -474,18 +475,18 @@
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.32"
+version = "1.0.39"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
+checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
 dependencies = [
- "unicode-xid",
+ "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.10"
+version = "1.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
 dependencies = [
  "proc-macro2",
 ]
@@ -504,9 +505,9 @@
 
 [[package]]
 name = "ryu"
-version = "1.0.5"
+version = "1.0.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
+checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695"
 
 [[package]]
 name = "scopeguard"
@@ -516,18 +517,18 @@
 
 [[package]]
 name = "serde"
-version = "1.0.130"
+version = "1.0.137"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
+checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.130"
+version = "1.0.137"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
+checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -536,9 +537,9 @@
 
 [[package]]
 name = "serde_json"
-version = "1.0.72"
+version = "1.0.81"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527"
+checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
 dependencies = [
  "indexmap",
  "itoa",
@@ -559,9 +560,9 @@
 
 [[package]]
 name = "smallvec"
-version = "1.7.0"
+version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
+checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
 
 [[package]]
 name = "static_assertions"
@@ -577,32 +578,20 @@
 
 [[package]]
 name = "syn"
-version = "1.0.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-xid",
-]
-
-[[package]]
-name = "synstructure"
-version = "0.12.6"
+version = "1.0.96"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
+checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
- "unicode-xid",
+ "unicode-ident",
 ]
 
 [[package]]
 name = "termcolor"
-version = "1.1.2"
+version = "1.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
 dependencies = [
  "winapi-util",
 ]
@@ -615,18 +604,18 @@
 
 [[package]]
 name = "thiserror"
-version = "1.0.30"
+version = "1.0.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
+checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.30"
+version = "1.0.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
+checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -634,22 +623,22 @@
 ]
 
 [[package]]
-name = "unicode-width"
-version = "0.1.9"
+name = "unicode-ident"
+version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
+checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
 
 [[package]]
-name = "unicode-xid"
-version = "0.2.2"
+name = "unicode-width"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
 
 [[package]]
 name = "version_check"
-version = "0.9.3"
+version = "0.9.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
 
 [[package]]
 name = "wasi"
modifiedbindings/jsonnet/Cargo.tomldiffbeforeafterboth
--- a/bindings/jsonnet/Cargo.toml
+++ b/bindings/jsonnet/Cargo.toml
@@ -10,7 +10,7 @@
 [dependencies]
 jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2" }
 jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
+jrsonnet-gcmodule = { version = "0.3.4" }
 
 [lib]
 crate-type = ["cdylib"]
modifiedbindings/jsonnet/src/native.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/native.rs
+++ b/bindings/jsonnet/src/native.rs
@@ -3,7 +3,6 @@
 	os::raw::{c_char, c_int},
 };
 
-use gcmodule::Cc;
 use jrsonnet_evaluator::{
 	error::{Error, LocError},
 	function::builtin::{BuiltinParam, NativeCallback, NativeCallbackHandler},
@@ -11,6 +10,7 @@
 	typed::Typed,
 	IStr, State, Val,
 };
+use jrsonnet_gcmodule::Cc;
 
 type JsonnetNativeCallback = unsafe extern "C" fn(
 	ctx: *const c_void,
@@ -18,11 +18,11 @@
 	success: *mut c_int,
 ) -> *mut Val;
 
-#[derive(gcmodule::Trace)]
+#[derive(jrsonnet_gcmodule::Trace)]
 struct JsonnetNativeCallbackHandler {
-	#[skip_trace]
+	#[trace(skip)]
 	ctx: *const c_void,
-	#[skip_trace]
+	#[trace(skip)]
 	cb: JsonnetNativeCallback,
 }
 impl NativeCallbackHandler for JsonnetNativeCallbackHandler {
modifiedbindings/jsonnet/src/val_make.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_make.rs
+++ b/bindings/jsonnet/src/val_make.rs
@@ -5,8 +5,8 @@
 	os::raw::{c_char, c_double, c_int},
 };
 
-use gcmodule::Cc;
 use jrsonnet_evaluator::{val::ArrValue, ObjValue, State, Val};
+use jrsonnet_gcmodule::Cc;
 
 /// # Safety
 ///
modifiedbindings/jsonnet/src/val_modify.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_modify.rs
+++ b/bindings/jsonnet/src/val_modify.rs
@@ -4,8 +4,8 @@
 
 use std::{ffi::CStr, os::raw::c_char};
 
-use gcmodule::Cc;
 use jrsonnet_evaluator::{val::ArrValue, State, Thunk, Val};
+use jrsonnet_gcmodule::Cc;
 
 /// # Safety
 ///
modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -23,8 +23,9 @@
 jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2" }
 jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
 jrsonnet-cli = { path = "../../crates/jrsonnet-cli", version = "0.4.2" }
+jrsonnet-gcmodule = { version = "0.3.4" }
+
 mimallocator = { version = "0.1.3", optional = true }
 thiserror = "1.0"
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
 clap = { version = "3.1", features = ["derive"] }
 clap_complete = { version = "3.1" }
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -115,7 +115,6 @@
 }
 
 fn main_real(s: &State, opts: Opts) -> Result<(), Error> {
-	opts.gc.configure_global();
 	opts.general.configure(s)?;
 	opts.manifest.configure(s)?;
 
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -14,6 +14,6 @@
     "explaining-traces",
 ] }
 jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
+jrsonnet-gcmodule = { version = "0.3.4" }
 
 clap = { version = "3.1", features = ["derive"] }
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -8,6 +8,7 @@
 use clap::Parser;
 pub use ext::*;
 use jrsonnet_evaluator::{error::Result, FileImportResolver, State};
+use jrsonnet_gcmodule::with_thread_object_space;
 pub use manifest::*;
 pub use tla::*;
 pub use trace::*;
@@ -111,15 +112,21 @@
 	gc_collect_before_printing_stats: bool,
 }
 impl GcOpts {
-	pub fn configure_global(&self) {
-		if !self.gc_collect_on_exit {
-			gcmodule::set_thread_collect_on_drop(false)
-		}
+	pub fn stats_printer(&self) -> (Option<GcStatsPrinter>, Option<LeakSpace>) {
+		(
+			self.gc_print_stats.then(|| GcStatsPrinter {
+				collect_before_printing_stats: self.gc_collect_before_printing_stats,
+			}),
+			(!self.gc_collect_on_exit).then(|| LeakSpace {}),
+		)
 	}
-	pub fn stats_printer(&self) -> Option<GcStatsPrinter> {
-		self.gc_print_stats.then(|| GcStatsPrinter {
-			collect_before_printing_stats: self.gc_collect_before_printing_stats,
-		})
+}
+
+pub struct LeakSpace {}
+
+impl Drop for LeakSpace {
+	fn drop(&mut self) {
+		with_thread_object_space(|s| s.leak())
 	}
 }
 
@@ -130,9 +137,9 @@
 	fn drop(&mut self) {
 		eprintln!("=== GC STATS ===");
 		if self.collect_before_printing_stats {
-			let collected = gcmodule::collect_thread_cycles();
+			let collected = jrsonnet_gcmodule::collect_thread_cycles();
 			eprintln!("Collected: {}", collected);
 		}
-		eprintln!("Tracked: {}", gcmodule::count_thread_tracked())
+		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())
 	}
 }
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -30,6 +30,8 @@
 jrsonnet-stdlib = { path = "../jrsonnet-stdlib", version = "0.4.2" }
 jrsonnet-types = { path = "../jrsonnet-types", version = "0.4.2" }
 jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
+jrsonnet-gcmodule = { version = "0.3.4" }
+
 pathdiff = "0.2.1"
 hashbrown = "0.12.1"
 static_assertions = "1.1.0"
@@ -39,7 +41,6 @@
 rustc-hash = "1.1"
 
 thiserror = "1.0"
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
 
 serde = "1.0"
 serde_json = "1.0"
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -1,11 +1,10 @@
 use std::fmt::Debug;
 
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 
 use crate::{
-	cc_ptr_eq, error::Error::*, gc::GcHashMap, map::LayeredHashMap, ObjValue, Pending, Result,
-	Thunk, Val,
+	error::Error::*, gc::GcHashMap, map::LayeredHashMap, ObjValue, Pending, Result, Thunk, Val,
 };
 
 #[derive(Trace)]
@@ -136,6 +135,6 @@
 
 impl PartialEq for Context {
 	fn eq(&self, other: &Self) -> bool {
-		cc_ptr_eq(&self.0, &other.0)
+		Cc::ptr_eq(&self.0, &other.0)
 	}
 }
modifiedcrates/jrsonnet-evaluator/src/dynamic.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/dynamic.rs
+++ b/crates/jrsonnet-evaluator/src/dynamic.rs
@@ -1,6 +1,6 @@
 use std::cell::RefCell;
 
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 
 #[derive(Clone, Trace)]
 pub struct Pending<V: Trace + 'static>(pub Cc<RefCell<Option<V>>>);
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -1,6 +1,6 @@
 use std::{fmt::Debug, path::PathBuf};
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{BinaryOpType, ExprLocation, Source, UnaryOpType};
 use jrsonnet_types::ValType;
@@ -125,7 +125,7 @@
 	ImportSyntaxError {
 		path: Source,
 		source_code: IStr,
-		#[skip_trace]
+		#[trace(skip)]
 		error: Box<jrsonnet_parser::ParseError>,
 	},
 
modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -1,4 +1,4 @@
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{BindSpec, Destruct, LocExpr, ParamsDesc};
 
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -1,6 +1,6 @@
 use std::{cmp::Ordering, rc::Rc};
 
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{
 	ArgsDesc, AssertStmt, BindSpec, CompSpec, Expr, FieldMember, FieldName, ForSpecData,
@@ -151,7 +151,7 @@
 				value,
 			}) => {
 				#[derive(Trace)]
-				struct UnboundValue<B> {
+				struct UnboundValue<B: Trace> {
 					uctx: B,
 					value: LocExpr,
 					name: IStr,
@@ -201,7 +201,7 @@
 				..
 			}) => {
 				#[derive(Trace)]
-				struct UnboundMethod<B> {
+				struct UnboundMethod<B: Trace> {
 					uctx: B,
 					value: LocExpr,
 					params: ParamsDesc,
@@ -247,7 +247,7 @@
 			Member::BindStmt(_) => {}
 			Member::AssertStmt(stmt) => {
 				#[derive(Trace)]
-				struct ObjectAssert<B> {
+				struct ObjectAssert<B: Trace> {
 					uctx: B,
 					assert: AssertStmt,
 				}
@@ -299,7 +299,7 @@
 					Val::Null => {}
 					Val::Str(n) => {
 						#[derive(Trace)]
-						struct UnboundValue<B> {
+						struct UnboundValue<B: Trace> {
 							uctx: B,
 							value: LocExpr,
 						}
modifiedcrates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/arglike.rs
+++ b/crates/jrsonnet-evaluator/src/function/arglike.rs
@@ -1,6 +1,6 @@
 use std::collections::HashMap;
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{ArgsDesc, LocExpr};
 
modifiedcrates/jrsonnet-evaluator/src/function/builtin.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/builtin.rs
+++ b/crates/jrsonnet-evaluator/src/function/builtin.rs
@@ -1,6 +1,6 @@
 use std::borrow::Cow;
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 
 use super::{arglike::ArgsLike, parse::parse_builtin_call, CallLocation};
 use crate::{error::Result, gc::TraceBox, Context, State, Val};
modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -1,7 +1,7 @@
 use std::fmt::Debug;
 
 pub use arglike::{ArgLike, ArgsLike, TlaArg};
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 pub use jrsonnet_macros::builtin;
 use jrsonnet_parser::{ExprLocation, LocExpr, ParamsDesc};
@@ -91,7 +91,7 @@
 	/// Plain function implemented in jsonnet
 	Normal(Cc<FuncDesc>),
 	/// Standard library function
-	StaticBuiltin(#[skip_trace] &'static dyn StaticBuiltin),
+	StaticBuiltin(#[trace(skip)] &'static dyn StaticBuiltin),
 	/// User-provided function
 	Builtin(Cc<TraceBox<dyn Builtin>>),
 }
modifiedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/function/parse.rs
+++ b/crates/jrsonnet-evaluator/src/function/parse.rs
@@ -1,4 +1,4 @@
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{LocExpr, ParamsDesc};
 
modifiedcrates/jrsonnet-evaluator/src/gc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/gc.rs
+++ b/crates/jrsonnet-evaluator/src/gc.rs
@@ -6,8 +6,8 @@
 	ops::{Deref, DerefMut},
 };
 
-use gcmodule::{Trace, Tracer};
 use hashbrown::HashMap;
+use jrsonnet_gcmodule::{Trace, Tracer};
 use rustc_hash::{FxHashSet, FxHasher};
 
 /// Replacement for box, which assumes that the underlying type is [`Trace`]
@@ -92,7 +92,7 @@
 where
 	V: Trace,
 {
-	fn trace(&self, tracer: &mut gcmodule::Tracer) {
+	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {
 		for v in &self.0 {
 			v.trace(tracer);
 		}
@@ -133,7 +133,7 @@
 	K: Trace,
 	V: Trace,
 {
-	fn trace(&self, tracer: &mut gcmodule::Tracer) {
+	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {
 		for (k, v) in &self.0 {
 			k.trace(tracer);
 			v.trace(tracer);
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/lib.rs
1#![warn(clippy::all, clippy::nursery, clippy::pedantic)]2#![allow(3	macro_expanded_macro_exports_accessed_by_absolute_paths,4	clippy::ptr_arg,5	// Too verbose6	clippy::must_use_candidate,7	// A lot of functions pass around errors thrown by code8	clippy::missing_errors_doc,9	// A lot of pointers have interior Rc10	clippy::needless_pass_by_value,11	// Its fine12	clippy::wildcard_imports,13	clippy::enum_glob_use,14	clippy::module_name_repetitions,15	// TODO: fix individual issues, however this works as intended almost everywhere16	clippy::cast_precision_loss,17	clippy::cast_possible_wrap,18	clippy::cast_possible_truncation,19	clippy::cast_sign_loss,20	// False positives21	// https://github.com/rust-lang/rust-clippy/issues/690222	clippy::use_self,23	// https://github.com/rust-lang/rust-clippy/issues/853924	clippy::iter_with_drain,25)]2627// For jrsonnet-macros28extern crate self as jrsonnet_evaluator;2930mod ctx;31mod dynamic;32pub mod error;33mod evaluate;34pub mod function;35pub mod gc;36mod import;37mod integrations;38mod map;39mod obj;40mod stdlib;41pub mod trace;42pub mod typed;43pub mod val;4445use std::{46	borrow::Cow,47	cell::{Ref, RefCell, RefMut},48	collections::HashMap,49	fmt::{self, Debug},50	path::{Path, PathBuf},51	rc::Rc,52};5354pub use ctx::*;55pub use dynamic::*;56use error::{Error::*, LocError, Result, StackTraceElement};57pub use evaluate::*;58use function::{builtin::Builtin, CallLocation, TlaArg};59use gc::{GcHashMap, TraceBox};60use gcmodule::{Cc, Trace, Weak};61use hashbrown::hash_map::RawEntryMut;62pub use import::*;63use jrsonnet_interner::IBytes;64pub use jrsonnet_interner::IStr;65pub use jrsonnet_parser as parser;66use jrsonnet_parser::*;67pub use obj::*;68use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};69pub use val::{ManifestFormat, Thunk, Val};7071pub trait Unbound: Trace {72	type Bound;73	fn bind(&self, s: State, sup: Option<ObjValue>, this: Option<ObjValue>) -> Result<Self::Bound>;74}7576#[derive(Clone, Trace)]77pub enum LazyBinding {78	Bindable(Cc<TraceBox<dyn Unbound<Bound = Thunk<Val>>>>),79	Bound(Thunk<Val>),80}8182impl Debug for LazyBinding {83	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {84		write!(f, "LazyBinding")85	}86}87impl LazyBinding {88	pub fn evaluate(89		&self,90		s: State,91		sup: Option<ObjValue>,92		this: Option<ObjValue>,93	) -> Result<Thunk<Val>> {94		match self {95			Self::Bindable(v) => v.bind(s, sup, this),96			Self::Bound(v) => Ok(v.clone()),97		}98	}99}100101pub struct EvaluationSettings {102	/// Limits recursion by limiting the number of stack frames103	pub max_stack: usize,104	/// Limits amount of stack trace items preserved105	pub max_trace: usize,106	/// Used for s`td.extVar`107	pub ext_vars: HashMap<IStr, TlaArg>,108	/// Used for ext.native109	pub ext_natives: HashMap<IStr, Cc<TraceBox<dyn Builtin>>>,110	/// TLA vars111	pub tla_vars: HashMap<IStr, TlaArg>,112	/// Global variables are inserted in default context113	pub globals: HashMap<IStr, Val>,114	/// Used to resolve file locations/contents115	pub import_resolver: Box<dyn ImportResolver>,116	/// Used in manifestification functions117	pub manifest_format: ManifestFormat,118	/// Used for bindings119	pub trace_format: Box<dyn TraceFormat>,120}121impl Default for EvaluationSettings {122	fn default() -> Self {123		Self {124			max_stack: 200,125			max_trace: 20,126			globals: HashMap::default(),127			ext_vars: HashMap::default(),128			ext_natives: HashMap::default(),129			tla_vars: HashMap::default(),130			import_resolver: Box::new(DummyImportResolver),131			manifest_format: ManifestFormat::Json {132				padding: 4,133				#[cfg(feature = "exp-preserve-order")]134				preserve_order: false,135			},136			trace_format: Box::new(CompactFormat {137				padding: 4,138				resolver: trace::PathResolver::Absolute,139			}),140		}141	}142}143144#[derive(Default)]145struct EvaluationData {146	/// Used for stack overflow detection, stacktrace is populated on unwind147	stack_depth: usize,148	/// Updated every time stack entry is popt149	stack_generation: usize,150151	breakpoints: Breakpoints,152153	/// Contains file source codes and evaluation results for imports and pretty-printed stacktraces154	files: GcHashMap<PathBuf, FileData>,155	/// Contains tla arguments and others, which aren't needed to be obtained by name156	volatile_files: GcHashMap<String, String>,157}158struct FileData {159	string: Option<IStr>,160	bytes: Option<IBytes>,161	parsed: Option<LocExpr>,162	evaluated: Option<Val>,163164	evaluating: bool,165}166impl FileData {167	fn new_string(data: IStr) -> Self {168		Self {169			string: Some(data),170			bytes: None,171			parsed: None,172			evaluated: None,173			evaluating: false,174		}175	}176	fn new_bytes(data: IBytes) -> Self {177		Self {178			string: None,179			bytes: Some(data),180			parsed: None,181			evaluated: None,182			evaluating: false,183		}184	}185}186187#[allow(clippy::type_complexity)]188pub struct Breakpoint {189	loc: ExprLocation,190	collected: RefCell<HashMap<usize, (usize, Vec<Result<Val>>)>>,191}192#[derive(Default)]193struct Breakpoints(Vec<Rc<Breakpoint>>);194impl Breakpoints {195	fn insert(196		&self,197		stack_depth: usize,198		stack_generation: usize,199		loc: &ExprLocation,200		result: Result<Val>,201	) -> Result<Val> {202		if self.0.is_empty() {203			return result;204		}205		for item in &self.0 {206			if item.loc.belongs_to(loc) {207				let mut collected = item.collected.borrow_mut();208				let (depth, vals) = collected.entry(stack_generation).or_default();209				if stack_depth > *depth {210					vals.clear();211				}212				vals.push(result.clone());213			}214		}215		result216	}217}218219#[derive(Default)]220pub struct EvaluationStateInternals {221	/// Internal state222	data: RefCell<EvaluationData>,223	/// Settings, safe to change at runtime224	settings: RefCell<EvaluationSettings>,225}226227/// Maintains stack trace and import resolution228#[derive(Default, Clone)]229pub struct State(Rc<EvaluationStateInternals>);230231impl State {232	pub fn import_str(&self, path: PathBuf) -> Result<IStr> {233		let mut data = self.data_mut();234		let mut file = data.files.raw_entry_mut().from_key(&path);235236		let file = match file {237			RawEntryMut::Occupied(ref mut d) => d.get_mut(),238			RawEntryMut::Vacant(v) => {239				let data = self.settings().import_resolver.load_file_contents(&path)?;240				v.insert(241					path.clone(),242					FileData::new_string(243						std::str::from_utf8(&data)244							.map_err(|_| ImportBadFileUtf8(path.clone()))?245							.into(),246					),247				)248				.1249			}250		};251		if let Some(str) = &file.string {252			return Ok(str.clone());253		}254		if file.string.is_none() {255			file.string = Some(256				file.bytes257					.as_ref()258					.expect("either string or bytes should be set")259					.clone()260					.cast_str()261					.ok_or_else(|| ImportBadFileUtf8(path.clone()))?,262			);263		}264		Ok(file.string.as_ref().expect("just set").clone())265	}266	pub fn import_bin(&self, path: PathBuf) -> Result<IBytes> {267		let mut data = self.data_mut();268		let mut file = data.files.raw_entry_mut().from_key(&path);269270		let file = match file {271			RawEntryMut::Occupied(ref mut d) => d.get_mut(),272			RawEntryMut::Vacant(v) => {273				let data = self.settings().import_resolver.load_file_contents(&path)?;274				v.insert(path.clone(), FileData::new_bytes(data.as_slice().into()))275					.1276			}277		};278		if let Some(str) = &file.bytes {279			return Ok(str.clone());280		}281		if file.bytes.is_none() {282			file.bytes = Some(283				file.string284					.as_ref()285					.expect("either string or bytes should be set")286					.clone()287					.cast_bytes(),288			);289		}290		Ok(file.bytes.as_ref().expect("just set").clone())291	}292	pub fn import(&self, path: PathBuf) -> Result<Val> {293		let mut data = self.data_mut();294		let mut file = data.files.raw_entry_mut().from_key(&path);295296		let file = match file {297			RawEntryMut::Occupied(ref mut d) => d.get_mut(),298			RawEntryMut::Vacant(v) => {299				let data = self.settings().import_resolver.load_file_contents(&path)?;300				v.insert(301					path.clone(),302					FileData::new_string(303						std::str::from_utf8(&data)304							.map_err(|_| ImportBadFileUtf8(path.clone()))?305							.into(),306					),307				)308				.1309			}310		};311		if let Some(val) = &file.evaluated {312			return Ok(val.clone());313		}314		if file.string.is_none() {315			file.string = Some(316				std::str::from_utf8(317					file.bytes318						.as_ref()319						.expect("either string or bytes should be set"),320				)321				.map_err(|_| ImportBadFileUtf8(path.clone()))?322				.into(),323			);324		}325		let code = file.string.as_ref().expect("just set");326		let file_name = Source::new(path.clone()).expect("resolver should return correct name");327		if file.parsed.is_none() {328			file.parsed = Some(329				jrsonnet_parser::parse(330					code,331					&ParserSettings {332						file_name: file_name.clone(),333					},334				)335				.map_err(|e| ImportSyntaxError {336					path: file_name,337					source_code: code.clone(),338					error: Box::new(e),339				})?,340			);341		}342		let parsed = file.parsed.as_ref().expect("just set").clone();343		if file.evaluating {344			throw!(InfiniteRecursionDetected)345		}346		file.evaluating = true;347		// Dropping file here, as it borrows data, which may be used in evaluation348		drop(data);349		let res = evaluate(self.clone(), self.create_default_context(), &parsed);350351		let mut data = self.data_mut();352		let mut file = data.files.raw_entry_mut().from_key(&path);353354		let file = match file {355			RawEntryMut::Occupied(ref mut d) => d.get_mut(),356			RawEntryMut::Vacant(_) => unreachable!("this file was just here!"),357		};358		file.evaluating = false;359		match res {360			Ok(v) => {361				file.evaluated = Some(v.clone());362				Ok(v)363			}364			Err(e) => Err(e),365		}366	}367368	pub fn get_source(&self, name: Source) -> Option<String> {369		let data = self.data();370		match name.repr() {371			Ok(real) => data372				.files373				.get(real)374				.and_then(|f| f.string.as_ref())375				.map(ToString::to_string),376			Err(e) => data.volatile_files.get(e).map(ToOwned::to_owned),377		}378	}379	pub fn map_source_locations(&self, file: Source, locs: &[u32]) -> Vec<CodeLocation> {380		offset_to_location(&self.get_source(file).unwrap_or_else(|| "".into()), locs)381	}382	pub fn map_from_source_location(383		&self,384		file: Source,385		line: usize,386		column: usize,387	) -> Option<usize> {388		location_to_offset(389			&self.get_source(file).expect("file not found"),390			line,391			column,392		)393	}394	/// Adds standard library global variable (std) to this evaluator395	pub fn with_stdlib(&self) -> &Self {396		let val = evaluate(397			self.clone(),398			self.create_default_context(),399			&stdlib::get_parsed_stdlib(),400		)401		.expect("std should not fail");402		self.settings_mut().globals.insert("std".into(), val);403		self404	}405406	/// Creates context with all passed global variables407	pub fn create_default_context(&self) -> Context {408		let globals = &self.settings().globals;409		let mut new_bindings = GcHashMap::with_capacity(globals.len());410		for (name, value) in globals.iter() {411			new_bindings.insert(name.clone(), Thunk::evaluated(value.clone()));412		}413		Context::new().extend(new_bindings, None, None, None)414	}415416	/// Executes code creating a new stack frame417	pub fn push<T>(418		&self,419		e: CallLocation,420		frame_desc: impl FnOnce() -> String,421		f: impl FnOnce() -> Result<T>,422	) -> Result<T> {423		{424			let mut data = self.data_mut();425			let stack_depth = &mut data.stack_depth;426			if *stack_depth > self.max_stack() {427				// Error creation uses data, so i drop guard here428				drop(data);429				throw!(StackOverflow);430			}431			*stack_depth += 1;432		}433		let result = f();434		{435			let mut data = self.data_mut();436			data.stack_depth -= 1;437			data.stack_generation += 1;438		}439		if let Err(mut err) = result {440			err.trace_mut().0.push(StackTraceElement {441				location: e.0.cloned(),442				desc: frame_desc(),443			});444			return Err(err);445		}446		result447	}448449	/// Executes code creating a new stack frame450	pub fn push_val(451		&self,452		e: &ExprLocation,453		frame_desc: impl FnOnce() -> String,454		f: impl FnOnce() -> Result<Val>,455	) -> Result<Val> {456		{457			let mut data = self.data_mut();458			let stack_depth = &mut data.stack_depth;459			if *stack_depth > self.max_stack() {460				// Error creation uses data, so i drop guard here461				drop(data);462				throw!(StackOverflow);463			}464			*stack_depth += 1;465		}466		let mut result = f();467		{468			let mut data = self.data_mut();469			data.stack_depth -= 1;470			data.stack_generation += 1;471			result = data472				.breakpoints473				.insert(data.stack_depth, data.stack_generation, e, result);474		}475		if let Err(mut err) = result {476			err.trace_mut().0.push(StackTraceElement {477				location: Some(e.clone()),478				desc: frame_desc(),479			});480			return Err(err);481		}482		result483	}484	/// Executes code creating a new stack frame485	pub fn push_description<T>(486		&self,487		frame_desc: impl FnOnce() -> String,488		f: impl FnOnce() -> Result<T>,489	) -> Result<T> {490		{491			let mut data = self.data_mut();492			let stack_depth = &mut data.stack_depth;493			if *stack_depth > self.max_stack() {494				// Error creation uses data, so i drop guard here495				drop(data);496				throw!(StackOverflow);497			}498			*stack_depth += 1;499		}500		let result = f();501		{502			let mut data = self.data_mut();503			data.stack_depth -= 1;504			data.stack_generation += 1;505		}506		if let Err(mut err) = result {507			err.trace_mut().0.push(StackTraceElement {508				location: None,509				desc: frame_desc(),510			});511			return Err(err);512		}513		result514	}515516	/// # Panics517	/// In case of formatting failure518	pub fn stringify_err(&self, e: &LocError) -> String {519		let mut out = String::new();520		self.settings()521			.trace_format522			.write_trace(&mut out, self, e)523			.unwrap();524		out525	}526527	pub fn manifest(&self, val: Val) -> Result<IStr> {528		self.push_description(529			|| "manifestification".to_string(),530			|| val.manifest(self.clone(), &self.manifest_format()),531		)532	}533	pub fn manifest_multi(&self, val: Val) -> Result<Vec<(IStr, IStr)>> {534		val.manifest_multi(self.clone(), &self.manifest_format())535	}536	pub fn manifest_stream(&self, val: Val) -> Result<Vec<IStr>> {537		val.manifest_stream(self.clone(), &self.manifest_format())538	}539540	/// If passed value is function then call with set TLA541	pub fn with_tla(&self, val: Val) -> Result<Val> {542		Ok(match val {543			Val::Func(func) => self.push_description(544				|| "during TLA call".to_owned(),545				|| {546					func.evaluate(547						self.clone(),548						self.create_default_context(),549						CallLocation::native(),550						&self.settings().tla_vars,551						true,552					)553				},554			)?,555			v => v,556		})557	}558}559560/// Internals561impl State {562	fn data(&self) -> Ref<EvaluationData> {563		self.0.data.borrow()564	}565	fn data_mut(&self) -> RefMut<EvaluationData> {566		self.0.data.borrow_mut()567	}568	pub fn settings(&self) -> Ref<EvaluationSettings> {569		self.0.settings.borrow()570	}571	pub fn settings_mut(&self) -> RefMut<EvaluationSettings> {572		self.0.settings.borrow_mut()573	}574}575576/// Raw methods evaluate passed values but don't perform TLA execution577impl State {578	/// Parses and evaluates the given snippet579	pub fn evaluate_snippet(&self, name: String, code: String) -> Result<Val> {580		let source = Source::new_virtual(Cow::Owned(name.clone()));581		let parsed = jrsonnet_parser::parse(582			&code,583			&ParserSettings {584				file_name: source.clone(),585			},586		)587		.map_err(|e| ImportSyntaxError {588			path: source,589			source_code: code.clone().into(),590			error: Box::new(e),591		})?;592		self.data_mut().volatile_files.insert(name, code);593		evaluate(self.clone(), self.create_default_context(), &parsed)594	}595}596597/// Settings utilities598impl State {599	pub fn add_ext_var(&self, name: IStr, value: Val) {600		self.settings_mut()601			.ext_vars602			.insert(name, TlaArg::Val(value));603	}604	pub fn add_ext_str(&self, name: IStr, value: IStr) {605		self.settings_mut()606			.ext_vars607			.insert(name, TlaArg::String(value));608	}609	pub fn add_ext_code(&self, name: &str, code: String) -> Result<()> {610		let source_name = format!("<extvar:{}>", name);611		let source = Source::new_virtual(Cow::Owned(source_name.clone()));612		let parsed = jrsonnet_parser::parse(613			&code,614			&ParserSettings {615				file_name: source.clone(),616			},617		)618		.map_err(|e| ImportSyntaxError {619			path: source,620			source_code: code.clone().into(),621			error: Box::new(e),622		})?;623		self.data_mut().volatile_files.insert(source_name, code);624		self.settings_mut()625			.ext_vars626			.insert(name.into(), TlaArg::Code(parsed));627		Ok(())628	}629630	pub fn add_tla(&self, name: IStr, value: Val) {631		self.settings_mut()632			.tla_vars633			.insert(name, TlaArg::Val(value));634	}635	pub fn add_tla_str(&self, name: IStr, value: IStr) {636		self.settings_mut()637			.tla_vars638			.insert(name, TlaArg::String(value));639	}640	pub fn add_tla_code(&self, name: IStr, code: &str) -> Result<()> {641		let source_name = format!("<top-level-arg:{}>", name);642		let source = Source::new_virtual(Cow::Owned(source_name.clone()));643		let parsed = jrsonnet_parser::parse(644			code,645			&ParserSettings {646				file_name: source.clone(),647			},648		)649		.map_err(|e| ImportSyntaxError {650			path: source,651			source_code: code.into(),652			error: Box::new(e),653		})?;654		self.data_mut()655			.volatile_files656			.insert(source_name, code.to_owned());657		self.settings_mut()658			.tla_vars659			.insert(name, TlaArg::Code(parsed));660		Ok(())661	}662663	pub fn resolve_file(&self, from: &Path, path: &str) -> Result<PathBuf> {664		self.settings()665			.import_resolver666			.resolve_file(from, path.as_ref())667	}668669	pub fn import_resolver(&self) -> Ref<dyn ImportResolver> {670		Ref::map(self.settings(), |s| &*s.import_resolver)671	}672	pub fn set_import_resolver(&self, resolver: Box<dyn ImportResolver>) {673		self.settings_mut().import_resolver = resolver;674	}675676	pub fn add_native(&self, name: IStr, cb: Cc<TraceBox<dyn Builtin>>) {677		self.settings_mut().ext_natives.insert(name, cb);678	}679680	pub fn manifest_format(&self) -> ManifestFormat {681		self.settings().manifest_format.clone()682	}683	pub fn set_manifest_format(&self, format: ManifestFormat) {684		self.settings_mut().manifest_format = format;685	}686687	pub fn trace_format(&self) -> Ref<dyn TraceFormat> {688		Ref::map(self.settings(), |s| &*s.trace_format)689	}690	pub fn set_trace_format(&self, format: Box<dyn TraceFormat>) {691		self.settings_mut().trace_format = format;692	}693694	pub fn max_trace(&self) -> usize {695		self.settings().max_trace696	}697	pub fn set_max_trace(&self, trace: usize) {698		self.settings_mut().max_trace = trace;699	}700701	pub fn max_stack(&self) -> usize {702		self.settings().max_stack703	}704	pub fn set_max_stack(&self, trace: usize) {705		self.settings_mut().max_stack = trace;706	}707}708709pub fn cc_ptr_eq<T>(a: &Cc<T>, b: &Cc<T>) -> bool {710	let a = a as &T;711	let b = b as &T;712	std::ptr::eq(a, b)713}714715fn weak_raw<T>(a: Weak<T>) -> *const () {716	unsafe { std::mem::transmute(a) }717}718fn weak_ptr_eq<T>(a: Weak<T>, b: Weak<T>) -> bool {719	std::ptr::eq(weak_raw(a), weak_raw(b))720}721722#[test]723fn weak_unsafe() {724	let a = Cc::new(1);725	let b = Cc::new(2);726727	let aw1 = a.clone().downgrade();728	let aw2 = a.clone().downgrade();729	let aw3 = a.clone().downgrade();730731	let bw = b.clone().downgrade();732733	assert!(weak_ptr_eq(aw1, aw2));734	assert!(!weak_ptr_eq(aw3, bw));735}
modifiedcrates/jrsonnet-evaluator/src/map.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/map.rs
+++ b/crates/jrsonnet-evaluator/src/map.rs
@@ -1,10 +1,10 @@
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 
 use crate::{GcHashMap, Thunk, Val};
 
 #[derive(Trace)]
-#[force_tracking]
+#[trace(tracking(force))]
 pub struct LayeredHashMapInternals {
 	parent: Option<LayeredHashMap>,
 	current: GcHashMap<IStr, Thunk<Val>>,
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -5,18 +5,17 @@
 	ptr::addr_of,
 };
 
-use gcmodule::{Cc, Trace, Weak};
+use jrsonnet_gcmodule::{Cc, Trace, Weak};
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{ExprLocation, Visibility};
 use rustc_hash::FxHashMap;
 
 use crate::{
-	cc_ptr_eq,
 	error::{Error::*, LocError},
 	function::CallLocation,
 	gc::{GcHashMap, GcHashSet, TraceBox},
 	operator::evaluate_add_op,
-	throw, weak_ptr_eq, weak_raw, LazyBinding, Result, State, Thunk, Unbound, Val,
+	throw, LazyBinding, Result, State, Thunk, Unbound, Val,
 };
 
 #[cfg(not(feature = "exp-preserve-order"))]
@@ -26,7 +25,7 @@
 		clippy::unused_self,
 	)]
 
-	use gcmodule::Trace;
+	use jrsonnet_gcmodule::Trace;
 
 	#[derive(Clone, Copy, Default, Debug, Trace)]
 	pub struct FieldIndex;
@@ -57,7 +56,7 @@
 mod ordering {
 	use std::cmp::Reverse;
 
-	use gcmodule::Trace;
+	use jrsonnet_gcmodule::Trace;
 
 	#[derive(Clone, Copy, Default, Debug, Trace, PartialEq, Eq, PartialOrd, Ord)]
 	pub struct FieldIndex(u32);
@@ -122,7 +121,7 @@
 
 #[allow(clippy::module_name_repetitions)]
 #[derive(Trace)]
-#[force_tracking]
+#[trace(tracking(force))]
 pub struct ObjValueInternals {
 	sup: Option<ObjValue>,
 	this: Option<ObjValue>,
@@ -134,18 +133,20 @@
 }
 
 #[derive(Clone, Trace)]
-pub struct WeakObjValue(#[skip_trace] pub(crate) Weak<ObjValueInternals>);
+pub struct WeakObjValue(#[trace(skip)] pub(crate) Weak<ObjValueInternals>);
 
 impl PartialEq for WeakObjValue {
 	fn eq(&self, other: &Self) -> bool {
-		weak_ptr_eq(self.0.clone(), other.0.clone())
+		Weak::ptr_eq(&self.0, &other.0)
 	}
 }
 
 impl Eq for WeakObjValue {}
 impl Hash for WeakObjValue {
 	fn hash<H: Hasher>(&self, hasher: &mut H) {
-		hasher.write_usize(weak_raw(self.0.clone()) as usize);
+		// Safety: usize is POD
+		let addr = unsafe { *std::ptr::addr_of!(self.0).cast() };
+		hasher.write_usize(addr);
 	}
 }
 
@@ -454,7 +455,7 @@
 	}
 
 	pub fn ptr_eq(a: &Self, b: &Self) -> bool {
-		cc_ptr_eq(&a.0, &b.0)
+		Cc::ptr_eq(&a.0, &b.0)
 	}
 	pub fn downgrade(self) -> WeakObjValue {
 		WeakObjValue(self.0.downgrade())
@@ -463,7 +464,7 @@
 
 impl PartialEq for ObjValue {
 	fn eq(&self, other: &Self) -> bool {
-		cc_ptr_eq(&self.0, &other.0)
+		Cc::ptr_eq(&self.0, &other.0)
 	}
 }
 
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -1,7 +1,7 @@
 //! faster std.format impl
 #![allow(clippy::too_many_arguments)]
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 use jrsonnet_types::ValType;
 use thiserror::Error;
modifiedcrates/jrsonnet-evaluator/src/stdlib/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/mod.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/mod.rs
@@ -4,7 +4,7 @@
 use std::collections::HashMap;
 
 use format::{format_arr, format_obj};
-use gcmodule::Cc;
+use jrsonnet_gcmodule::Cc;
 use jrsonnet_interner::{IBytes, IStr};
 use serde::Deserialize;
 use serde_yaml::DeserializingQuirks;
modifiedcrates/jrsonnet-evaluator/src/stdlib/sort.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/sort.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/sort.rs
@@ -1,4 +1,4 @@
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 
 use crate::{
 	error::{Error, LocError, Result},
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -1,6 +1,6 @@
 use std::ops::Deref;
 
-use gcmodule::Cc;
+use jrsonnet_gcmodule::Cc;
 use jrsonnet_interner::{IBytes, IStr};
 pub use jrsonnet_macros::Typed;
 use jrsonnet_types::{ComplexValType, ValType};
modifiedcrates/jrsonnet-evaluator/src/typed/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/mod.rs
+++ b/crates/jrsonnet-evaluator/src/typed/mod.rs
@@ -2,7 +2,7 @@
 
 mod conversions;
 pub use conversions::*;
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 pub use jrsonnet_types::{ComplexValType, ValType};
 use thiserror::Error;
 
@@ -16,7 +16,7 @@
 	#[error("expected {0}, got {1}")]
 	ExpectedGot(ComplexValType, ValType),
 	#[error("missing property {0} from {1}")]
-	MissingProperty(#[skip_trace] Rc<str>, ComplexValType),
+	MissingProperty(#[trace(skip)] Rc<str>, ComplexValType),
 	#[error("every failed from {0}:\n{1}")]
 	UnionFailed(ComplexValType, TypeLocErrorList),
 	#[error(
@@ -119,7 +119,7 @@
 
 #[derive(Clone, Debug, Trace)]
 enum ValuePathItem {
-	Field(#[skip_trace] Rc<str>),
+	Field(#[trace(skip)] Rc<str>),
 	Index(u64),
 }
 impl Display for ValuePathItem {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -1,11 +1,10 @@
 use std::{cell::RefCell, fmt::Debug, rc::Rc};
 
-use gcmodule::{Cc, Trace};
+use jrsonnet_gcmodule::{Cc, Trace};
 use jrsonnet_interner::{IBytes, IStr};
 use jrsonnet_types::ValType;
 
 use crate::{
-	cc_ptr_eq,
 	error::{Error::*, LocError},
 	function::FuncVal,
 	gc::{GcHashMap, TraceBox},
@@ -21,7 +20,7 @@
 }
 
 #[derive(Trace)]
-enum ThunkInner<T> {
+enum ThunkInner<T: Trace> {
 	Computed(T),
 	Errored(LocError),
 	Waiting(TraceBox<dyn ThunkValue<Output = T>>),
@@ -30,7 +29,7 @@
 
 #[allow(clippy::module_name_repetitions)]
 #[derive(Clone, Trace)]
-pub struct Thunk<T>(Cc<RefCell<ThunkInner<T>>>);
+pub struct Thunk<T: Trace>(Cc<RefCell<ThunkInner<T>>>);
 
 impl<T> Thunk<T>
 where
@@ -78,6 +77,7 @@
 pub struct CachedUnbound<I, T>
 where
 	I: Unbound<Bound = T>,
+	T: Trace,
 {
 	cache: Cc<RefCell<GcHashMap<CacheKey, T>>>,
 	value: I,
@@ -113,14 +113,14 @@
 	}
 }
 
-impl<T: Debug> Debug for Thunk<T> {
+impl<T: Debug + Trace> Debug for Thunk<T> {
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		write!(f, "Lazy")
 	}
 }
-impl<T> PartialEq for Thunk<T> {
+impl<T: Trace> PartialEq for Thunk<T> {
 	fn eq(&self, other: &Self) -> bool {
-		cc_ptr_eq(&self.0, &other.0)
+		Cc::ptr_eq(&self.0, &other.0)
 	}
 }
 
@@ -185,9 +185,10 @@
 }
 
 #[derive(Debug, Clone, Trace)]
-#[force_tracking]
+// may contrain other ArrValue
+#[trace(tracking(force))]
 pub enum ArrValue {
-	Bytes(#[skip_trace] IBytes),
+	Bytes(#[trace(skip)] IBytes),
 	Lazy(Cc<Vec<Thunk<Val>>>),
 	Eager(Cc<Vec<Val>>),
 	Extended(Box<(Self, Self)>),
@@ -434,8 +435,8 @@
 
 	pub fn ptr_eq(a: &Self, b: &Self) -> bool {
 		match (a, b) {
-			(Self::Lazy(a), Self::Lazy(b)) => cc_ptr_eq(a, b),
-			(Self::Eager(a), Self::Eager(b)) => cc_ptr_eq(a, b),
+			(Self::Lazy(a), Self::Lazy(b)) => Cc::ptr_eq(a, b),
+			(Self::Eager(a), Self::Eager(b)) => Cc::ptr_eq(a, b),
 			_ => false,
 		}
 	}
modifiedcrates/jrsonnet-evaluator/tests/builtin.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/tests/builtin.rs
+++ b/crates/jrsonnet-evaluator/tests/builtin.rs
@@ -1,6 +1,5 @@
 mod common;
 
-use gcmodule::Cc;
 use jrsonnet_evaluator::{
 	error::Result,
 	function::{builtin, builtin::Builtin, CallLocation, FuncVal},
@@ -8,6 +7,7 @@
 	typed::Typed,
 	State, Val,
 };
+use jrsonnet_gcmodule::Cc;
 
 #[builtin]
 fn a() -> Result<u32> {
modifiedcrates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -11,7 +11,8 @@
 serde = ["dep:serde"]
 
 [dependencies]
+jrsonnet-gcmodule = { version = "0.3.4" }
+
 serde = { version = "1.0", optional = true }
 rustc-hash = "1.1"
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
 hashbrown = { version = "0.12.1", features = ["inline-more"] }
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -13,8 +13,8 @@
 	str,
 };
 
-use gcmodule::Trace;
 use hashbrown::HashMap;
+use jrsonnet_gcmodule::Trace;
 use rustc_hash::FxHasher;
 
 mod inner;
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -342,7 +342,7 @@
 		#fun
 		#[doc(hidden)]
 		#[allow(non_camel_case_types)]
-		#[derive(Clone, gcmodule::Trace #static_derive_copy)]
+		#[derive(Clone, jrsonnet_gcmodule::Trace #static_derive_copy)]
 		#vis struct #name {
 			#(#fields)*
 		}
modifiedcrates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -11,12 +11,13 @@
 
 [dependencies]
 jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
+jrsonnet-gcmodule = { version = "0.3.4" }
+
 static_assertions = "1.1.0"
 
 peg = "0.8.0"
 
 serde = { version = "1.0", features = ["derive", "rc"], optional = true }
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
 
 [dev-dependencies]
 jrsonnet-stdlib = { path = "../jrsonnet-stdlib", version = "0.4.2" }
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -4,7 +4,7 @@
 	rc::Rc,
 };
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
 #[cfg(feature = "serde")]
 use serde::{Deserialize, Serialize};
@@ -359,7 +359,7 @@
 /// file, begin offset, end offset
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Clone, PartialEq, Eq, Trace)]
-#[skip_trace]
+#[trace(skip)]
 #[repr(C)]
 pub struct ExprLocation(pub Source, pub u32, pub u32);
 impl ExprLocation {
modifiedcrates/jrsonnet-parser/src/source.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/source.rs
+++ b/crates/jrsonnet-parser/src/source.rs
@@ -5,7 +5,7 @@
 	rc::Rc,
 };
 
-use gcmodule::{Trace, Tracer};
+use jrsonnet_gcmodule::{Trace, Tracer};
 #[cfg(feature = "serde")]
 use serde::{Deserialize, Serialize};
 
modifiedcrates/jrsonnet-types/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -7,5 +7,6 @@
 edition = "2021"
 
 [dependencies]
+jrsonnet-gcmodule = { version = "0.3.4" }
+
 peg = "0.8.0"
-gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -2,7 +2,7 @@
 
 use std::fmt::Display;
 
-use gcmodule::Trace;
+use jrsonnet_gcmodule::Trace;
 
 #[macro_export]
 macro_rules! ty {
@@ -115,7 +115,7 @@
 }
 
 #[derive(Debug, Clone, PartialEq, Trace)]
-#[skip_trace]
+#[trace(skip)]
 pub enum ComplexValType {
 	Any,
 	Char,