difftreelog
refactor switch to jrsonnet-gc
in: master
27 files changed
Cargo.lockdiffbeforeafterboth63 packageslockfile v3
Might be heavy and slow!
annotate-snippets
0.9.0crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5c96c3d1062ea7101741480185a6a1275eab01cbe8b20e378d1311bc056d2e08depends onused byanyhow
1.0.40crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063bused byatty
0.2.14crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8depends onused byautocfg
1.0.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464aused bybase64
0.13.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fdused bybincode
1.3.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcaddepends onused bybitflags
1.2.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693used bycc
1.0.67crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fdused byclap
3.0.0-beta.2github.com/clap-rs/clap↘ 10↖ 3sourcegit+https://github.com/clap-rs/clap?rev=92f744cc49d12d32261010d355dc215a6d2487b9#92f744cc49d12d32261010d355dc215a6d2487b9depends onclap_derive
3.0.0-beta.2github.com/clap-rs/clap↘ 5↖ 1sourcegit+https://github.com/clap-rs/clap?rev=92f744cc49d12d32261010d355dc215a6d2487b9#92f744cc49d12d32261010d355dc215a6d2487b9used byclap_generate
3.0.0-beta.2github.com/clap-rs/clap↘ 1↖ 1sourcegit+https://github.com/clap-rs/clap?rev=92f744cc49d12d32261010d355dc215a6d2487b9#92f744cc49d12d32261010d355dc215a6d2487b9depends onused bygc
0.4.1crates.io↘ 1↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum3edaac0f5832202ebc99520cb77c932248010c4645d20be1dc62d6579f5b3752depends ongc_derive
0.4.1crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum60df8444f094ff7885631d80e78eb7d88c3c2361a98daaabb06256e4500db941used byhashbrown
0.9.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04used byheck
0.3.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6acdepends onused byhermit-abi
0.1.18crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5cdepends onused byindexmap
1.6.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3depends onused byitoa
0.4.7crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumdd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736used byjrsonnet
0.3.8workspace↘ 7↖ 0jrsonnet-cli
0.3.8workspace↘ 3↖ 1jrsonnet-evaluator
0.3.8workspace↘ 15↖ 3jrsonnet-interner
0.3.8workspace↘ 3↖ 2jrsonnet-parser
0.3.8workspace↘ 6↖ 4jrsonnet-stdlib
0.3.8workspace↘ 0↖ 2jrsonnet-types
0.3.8workspace↘ 2↖ 1used byjsonnet
0.3.8workspace↘ 3↖ 0lazy_static
1.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646used bylibc
0.2.94crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5emd5
0.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771used bymimalloc-sys
0.1.6crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum4aa3cefb626f6ae3d0b2f71c5378c89d2b1d4d7bc246b0ca9a7ee61a4daad291depends onused bymimallocator
0.1.3crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2d44fe4ebf6b538fcf39d9975c2b90bb3232d1ba8e8bffeacd004f27b20c577adepends onused byos_str_bytes
3.0.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume293568965aea261bdf010db17df7030e3c9a275c415d51d6112f7cf9b7af012used bypathdiff
0.2.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum877630b3de15c0b64cc52f659345724fbf6bdad9bd9566699fc53688f3c34a34used bypeg
0.7.0crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166adepends onpeg-macros
0.7.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844cused bypeg-runtime
0.7.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088used byproc-macro-error
1.0.4crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumda25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38cused byproc-macro-error-attr
1.0.4crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869used byproc-macro2
1.0.26crates.io↘ 1↖ 10sourceregistry+https://github.com/rust-lang/crates.io-indexchecksuma152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cecdepends onquote
1.0.9crates.io↘ 1↖ 9sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7depends onrustc-hash
1.1.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2ryu
1.0.5crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86eused byserde
1.0.125crates.io↘ 1↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171depends onserde_derive
1.0.125crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06ddepends onused byserde_json
1.0.64crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79depends onused bystrsim
0.10.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623used bysyn
1.0.71crates.io↘ 3↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373synstructure
0.12.4crates.io↘ 4↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701used bytermcolor
1.1.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4depends onused bytextwrap
0.13.4crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835depends onused bythiserror
1.0.24crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98edepends onthiserror-impl
1.0.24crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0depends onused byunescape
0.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6eused byunicode-segmentation
1.7.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796used byunicode-width
0.1.8crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3unicode-xid
0.2.2crates.io↘ 0↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3vec_map
0.8.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191used byversion_check
0.9.3crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fewinapi
0.3.9crates.io↘ 2↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419winapi-i686-pc-windows-gnu
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6used bywinapi-util
0.1.5crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178depends onused bywinapi-x86_64-pc-windows-gnu
0.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183fused byyansi-term
0.1.2crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumfe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1depends onused by
bindings/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.3.8" }
jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.3.8" }
-gc = { version = "0.4.1", features = ["derive"] }
+jrsonnet-gc = { version = "0.4.2", features = ["derive"] }
[lib]
crate-type = ["cdylib"]
bindings/jsonnet/src/native.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/native.rs
+++ b/bindings/jsonnet/src/native.rs
@@ -1,9 +1,9 @@
-use gc::{unsafe_empty_trace, Finalize, Gc, Trace};
use jrsonnet_evaluator::{
error::{Error, LocError},
native::{NativeCallback, NativeCallbackHandler},
EvaluationState, Val,
};
+use jrsonnet_gc::{unsafe_empty_trace, Finalize, Gc, Trace};
use jrsonnet_parser::{Param, ParamsDesc};
use std::{
ffi::{c_void, CStr},
bindings/jsonnet/src/val_make.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/val_make.rs
+++ b/bindings/jsonnet/src/val_make.rs
@@ -1,7 +1,7 @@
//! Create values in VM
-use gc::Gc;
use jrsonnet_evaluator::{ArrValue, EvaluationState, ObjValue, Val};
+use jrsonnet_gc::Gc;
use std::{
ffi::CStr,
os::raw::{c_char, c_double, c_int},
bindings/jsonnet/src/val_modify.rsdiffbeforeafterboth--- a/bindings/jsonnet/src/val_modify.rs
+++ b/bindings/jsonnet/src/val_modify.rs
@@ -2,8 +2,8 @@
//! Only tested with variables, which haven't altered by code before appearing here
//! In jrsonnet every value is immutable, and this code is probally broken
-use gc::Gc;
use jrsonnet_evaluator::{ArrValue, EvaluationState, LazyBinding, LazyVal, ObjMember, Val};
+use jrsonnet_gc::Gc;
use jrsonnet_parser::Visibility;
use std::{ffi::CStr, os::raw::c_char};
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -35,7 +35,7 @@
rustc-hash = "1.1.0"
thiserror = "1.0"
-gc = { version = "0.4.1", features = ["derive"] }
+jrsonnet-gc = { version = "0.4.2", features = ["derive"] }
[dependencies.anyhow]
version = "1.0"
crates/jrsonnet-evaluator/src/builtin/format.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/format.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/format.rs
@@ -2,12 +2,13 @@
#![allow(clippy::too_many_arguments)]
use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val};
-use gc::{Finalize, Trace};
+use jrsonnet_gc::Trace;
use jrsonnet_interner::IStr;
use jrsonnet_types::ValType;
use thiserror::Error;
-#[derive(Debug, Clone, Error, Trace, Finalize)]
+#[derive(Debug, Clone, Error, Trace)]
+#[trivially_drop]
pub enum FormatError {
#[error("truncated format code")]
TruncatedFormatCode,
crates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -5,7 +5,7 @@
EvaluationState, FuncVal, LazyVal, Val,
};
use format::{format_arr, format_obj};
-use gc::Gc;
+use jrsonnet_gc::Gc;
use jrsonnet_interner::IStr;
use jrsonnet_parser::{ArgsDesc, BinaryOpType, ExprLocation};
use jrsonnet_types::ty;
@@ -454,7 +454,7 @@
0, rest: ty!(any);
], {
println!("GC start");
- gc::force_collect();
+ jrsonnet_gc::force_collect();
println!("GC done");
Ok(rest)
crates/jrsonnet-evaluator/src/builtin/sort.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/sort.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/sort.rs
@@ -2,7 +2,7 @@
error::{Error, LocError, Result},
throw, Context, FuncVal, Val,
};
-use gc::{Finalize, Gc, Trace};
+use jrsonnet_gc::{Finalize, Gc, Trace};
#[derive(Debug, Clone, thiserror::Error, Trace, Finalize)]
pub enum SortError {
crates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -2,13 +2,14 @@
error::Error::*, map::LayeredHashMap, FutureWrapper, LazyBinding, LazyVal, ObjValue, Result,
Val,
};
-use gc::{Finalize, Gc, Trace};
+use jrsonnet_gc::{Gc, Trace};
use jrsonnet_interner::IStr;
use rustc_hash::FxHashMap;
use std::fmt::Debug;
use std::hash::BuildHasherDefault;
-#[derive(Clone, Trace, Finalize)]
+#[derive(Clone, Trace)]
+#[trivially_drop]
pub struct ContextCreator(pub Context, pub FutureWrapper<FxHashMap<IStr, LazyBinding>>);
impl ContextCreator {
pub fn create(&self, this: Option<ObjValue>, super_obj: Option<ObjValue>) -> Result<Context> {
@@ -21,12 +22,13 @@
}
}
-#[derive(Trace, Finalize)]
+#[derive(Trace)]
+#[trivially_drop]
struct ContextInternals {
dollar: Option<ObjValue>,
this: Option<ObjValue>,
super_obj: Option<ObjValue>,
- bindings: LayeredHashMap<LazyVal>,
+ bindings: LayeredHashMap,
}
impl Debug for ContextInternals {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -34,7 +36,8 @@
}
}
-#[derive(Debug, Clone, Trace, Finalize)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub struct Context(Gc<ContextInternals>);
impl Context {
pub fn new_future() -> FutureWrapper<Self> {
crates/jrsonnet-evaluator/src/dynamic.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/dynamic.rs
+++ b/crates/jrsonnet-evaluator/src/dynamic.rs
@@ -1,6 +1,7 @@
-use gc::{Finalize, Gc, GcCell, Trace};
+use jrsonnet_gc::{Gc, GcCell, Trace};
-#[derive(Clone, Trace, Finalize)]
+#[derive(Clone, Trace)]
+#[trivially_drop]
pub struct FutureWrapper<V: Trace + 'static>(pub Gc<GcCell<Option<V>>>);
impl<T: Trace + 'static> FutureWrapper<T> {
pub fn new() -> Self {
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -2,7 +2,7 @@
builtin::{format::FormatError, sort::SortError},
typed::TypeLocError,
};
-use gc::{Finalize, Trace};
+use jrsonnet_gc::Trace;
use jrsonnet_interner::IStr;
use jrsonnet_parser::{BinaryOpType, ExprLocation, UnaryOpType};
use jrsonnet_types::ValType;
@@ -12,7 +12,8 @@
};
use thiserror::Error;
-#[derive(Error, Debug, Clone, Trace, Finalize)]
+#[derive(Error, Debug, Clone, Trace)]
+#[trivially_drop]
pub enum Error {
#[error("intrinsic not found: {0}")]
IntrinsicNotFound(IStr),
@@ -149,15 +150,18 @@
}
}
-#[derive(Clone, Debug, Trace, Finalize)]
+#[derive(Clone, Debug, Trace)]
+#[trivially_drop]
pub struct StackTraceElement {
pub location: Option<ExprLocation>,
pub desc: String,
}
-#[derive(Debug, Clone, Trace, Finalize)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub struct StackTrace(pub Vec<StackTraceElement>);
-#[derive(Debug, Clone, Trace, Finalize)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub struct LocError(Box<(Error, StackTrace)>);
impl LocError {
pub fn new(e: Error) -> Self {
crates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate.rs
@@ -3,7 +3,7 @@
FuncDesc, FuncVal, FutureWrapper, LazyBinding, LazyVal, LazyValValue, ObjMember, ObjValue,
ObjectAssertion, Result, Val,
};
-use gc::{custom_trace, Finalize, Gc, Trace};
+use jrsonnet_gc::{Gc, Trace};
use jrsonnet_interner::IStr;
use jrsonnet_parser::{
ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprLocation, FieldMember,
@@ -22,21 +22,14 @@
if let Some(params) = &b.params {
let params = params.clone();
+ #[derive(Trace)]
+ #[trivially_drop]
struct LazyMethodBinding {
context_creator: FutureWrapper<Context>,
name: IStr,
params: ParamsDesc,
value: LocExpr,
}
- impl Finalize for LazyMethodBinding {}
- unsafe impl Trace for LazyMethodBinding {
- custom_trace!(this, {
- mark(&this.context_creator);
- mark(&this.name);
- mark(&this.params);
- mark(&this.value);
- });
- }
impl LazyValValue for LazyMethodBinding {
fn get(self: Box<Self>) -> Result<Val> {
Ok(evaluate_method(
@@ -55,19 +48,13 @@
value: b.value.clone(),
}))
} else {
+ #[derive(Trace)]
+ #[trivially_drop]
struct LazyNamedBinding {
context_creator: FutureWrapper<Context>,
name: IStr,
value: LocExpr,
}
- impl Finalize for LazyNamedBinding {}
- unsafe impl Trace for LazyNamedBinding {
- custom_trace!(this, {
- mark(&this.context_creator);
- mark(&this.name);
- mark(&this.value);
- });
- }
impl LazyValValue for LazyNamedBinding {
fn get(self: Box<Self>) -> Result<Val> {
evaluate_named(self.context_creator.unwrap(), &self.value, self.name)
@@ -86,6 +73,8 @@
if let Some(params) = &b.params {
let params = params.clone();
+ #[derive(Trace)]
+ #[trivially_drop]
struct BindableMethodLazyVal {
this: Option<ObjValue>,
super_obj: Option<ObjValue>,
@@ -94,17 +83,6 @@
name: IStr,
params: ParamsDesc,
value: LocExpr,
- }
- impl Finalize for BindableMethodLazyVal {}
- unsafe impl Trace for BindableMethodLazyVal {
- custom_trace!(this, {
- mark(&this.this);
- mark(&this.super_obj);
- mark(&this.context_creator);
- mark(&this.name);
- mark(&this.params);
- mark(&this.value);
- });
}
impl LazyValValue for BindableMethodLazyVal {
fn get(self: Box<Self>) -> Result<Val> {
@@ -117,7 +95,8 @@
}
}
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct BindableMethod {
context_creator: ContextCreator,
name: IStr,
@@ -148,6 +127,8 @@
}))),
)
} else {
+ #[derive(Trace)]
+ #[trivially_drop]
struct BindableNamedLazyVal {
this: Option<ObjValue>,
super_obj: Option<ObjValue>,
@@ -156,16 +137,6 @@
name: IStr,
value: LocExpr,
}
- impl Finalize for BindableNamedLazyVal {}
- unsafe impl Trace for BindableNamedLazyVal {
- custom_trace!(this, {
- mark(&this.this);
- mark(&this.super_obj);
- mark(&this.context_creator);
- mark(&this.name);
- mark(&this.value);
- });
- }
impl LazyValValue for BindableNamedLazyVal {
fn get(self: Box<Self>) -> Result<Val> {
evaluate_named(
@@ -176,7 +147,8 @@
}
}
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct BindableNamed {
context_creator: ContextCreator,
name: IStr,
@@ -414,7 +386,8 @@
}
let name = name.unwrap();
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct ObjMemberBinding {
context_creator: ContextCreator,
value: LocExpr,
@@ -458,7 +431,8 @@
continue;
}
let name = name.unwrap();
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct ObjMemberBinding {
context_creator: ContextCreator,
value: LocExpr,
@@ -496,16 +470,11 @@
}
Member::BindStmt(_) => {}
Member::AssertStmt(stmt) => {
+ #[derive(Trace)]
+ #[trivially_drop]
struct ObjectAssert {
context_creator: ContextCreator,
assert: AssertStmt,
- }
- impl Finalize for ObjectAssert {}
- unsafe impl Trace for ObjectAssert {
- custom_trace!(this, {
- mark(&this.context_creator);
- mark(&this.assert);
- });
}
impl ObjectAssertion for ObjectAssert {
fn run(
@@ -558,7 +527,8 @@
match key {
Val::Null => {}
Val::Str(n) => {
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct ObjCompBinding {
context: Context,
value: LocExpr,
@@ -768,16 +738,11 @@
let mut out = Vec::with_capacity(items.len());
for item in items {
// TODO: Implement ArrValue::Lazy with same context for every element?
+ #[derive(Trace)]
+ #[trivially_drop]
struct ArrayElement {
context: Context,
item: LocExpr,
- }
- impl Finalize for ArrayElement {}
- unsafe impl Trace for ArrayElement {
- custom_trace!(this, {
- mark(&this.context);
- mark(&this.item);
- });
}
impl LazyValValue for ArrayElement {
fn get(self: Box<Self>) -> Result<Val> {
crates/jrsonnet-evaluator/src/function.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function.rs
+++ b/crates/jrsonnet-evaluator/src/function.rs
@@ -1,5 +1,5 @@
use crate::{error::Error::*, evaluate, throw, Context, LazyVal, LazyValValue, Result, Val};
-use gc::{custom_trace, Finalize, Trace};
+use jrsonnet_gc::Trace;
use jrsonnet_interner::IStr;
use jrsonnet_parser::{ArgsDesc, LocExpr, ParamsDesc};
use rustc_hash::FxHashMap;
@@ -55,16 +55,11 @@
let val = if tailstrict {
LazyVal::new_resolved(evaluate(ctx, expr)?)
} else {
+ #[derive(Trace)]
+ #[trivially_drop]
struct EvaluateLazyVal {
context: Context,
expr: LocExpr,
- }
- impl Finalize for EvaluateLazyVal {}
- unsafe impl Trace for EvaluateLazyVal {
- custom_trace!(this, {
- mark(&this.context);
- mark(&this.expr);
- });
}
impl LazyValValue for EvaluateLazyVal {
fn get(self: Box<Self>) -> Result<Val> {
@@ -119,7 +114,8 @@
} else {
let body_ctx = body_ctx.clone();
let default = default.clone();
- #[derive(Trace, Finalize)]
+ #[derive(Trace)]
+ #[trivially_drop]
struct EvaluateLazyVal {
body_ctx: Option<Context>,
default: LocExpr,
crates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -2,7 +2,7 @@
error::{Error::*, LocError, Result},
throw, LazyBinding, LazyVal, ObjMember, ObjValue, Val,
};
-use gc::Gc;
+use jrsonnet_gc::Gc;
use jrsonnet_parser::Visibility;
use rustc_hash::FxHasher;
use serde_json::{Map, Number, Value};
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -25,8 +25,8 @@
use error::{Error::*, LocError, Result, StackTraceElement};
pub use evaluate::*;
pub use function::parse_function_call;
-use gc::{Finalize, Gc, Trace};
pub use import::*;
+use jrsonnet_gc::{Finalize, Gc, Trace};
pub use jrsonnet_interner::IStr;
use jrsonnet_parser::*;
use native::NativeCallback;
crates/jrsonnet-evaluator/src/map.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/map.rs
+++ b/crates/jrsonnet-evaluator/src/map.rs
@@ -1,32 +1,29 @@
-use gc::{Finalize, Gc, Trace};
+use jrsonnet_gc::{Gc, Trace};
use jrsonnet_interner::IStr;
use rustc_hash::FxHashMap;
-pub struct LayeredHashMapInternals<V: Trace + Finalize + 'static> {
- parent: Option<LayeredHashMap<V>>,
- current: FxHashMap<IStr, V>,
-}
+use crate::LazyVal;
-unsafe impl<V: Trace + Finalize + 'static> Trace for LayeredHashMapInternals<V> {
- gc::custom_trace!(this, {
- mark(&this.parent);
- mark(&this.current);
- });
+#[derive(Trace)]
+#[trivially_drop]
+pub struct LayeredHashMapInternals {
+ parent: Option<LayeredHashMap>,
+ current: FxHashMap<IStr, LazyVal>,
}
-impl<V: Trace + Finalize + 'static> Finalize for LayeredHashMapInternals<V> {}
-#[derive(Trace, Finalize)]
-pub struct LayeredHashMap<V: Trace + Finalize + 'static>(Gc<LayeredHashMapInternals<V>>);
+#[derive(Trace)]
+#[trivially_drop]
+pub struct LayeredHashMap(Gc<LayeredHashMapInternals>);
-impl<V: Trace + 'static> LayeredHashMap<V> {
- pub fn extend(self, new_layer: FxHashMap<IStr, V>) -> Self {
+impl LayeredHashMap {
+ pub fn extend(self, new_layer: FxHashMap<IStr, LazyVal>) -> Self {
Self(Gc::new(LayeredHashMapInternals {
parent: Some(self),
current: new_layer,
}))
}
- pub fn get(&self, key: &IStr) -> Option<&V> {
+ pub fn get(&self, key: &IStr) -> Option<&LazyVal> {
(self.0)
.current
.get(key)
@@ -34,13 +31,13 @@
}
}
-impl<V: Trace + 'static> Clone for LayeredHashMap<V> {
+impl Clone for LayeredHashMap {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
-impl<V: Trace + 'static> Default for LayeredHashMap<V> {
+impl Default for LayeredHashMap {
fn default() -> Self {
Self(Gc::new(LayeredHashMapInternals {
parent: None,
crates/jrsonnet-evaluator/src/native.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/native.rs
+++ b/crates/jrsonnet-evaluator/src/native.rs
@@ -1,7 +1,7 @@
#![allow(clippy::type_complexity)]
use crate::{error::Result, Val};
-use gc::{Finalize, Trace};
+use jrsonnet_gc::Trace;
use jrsonnet_parser::ParamsDesc;
use std::fmt::Debug;
use std::path::Path;
@@ -11,7 +11,8 @@
fn call(&self, from: Option<Rc<Path>>, args: &[Val]) -> Result<Val>;
}
-#[derive(Trace, Finalize)]
+#[derive(Trace)]
+#[trivially_drop]
pub struct NativeCallback {
pub params: ParamsDesc,
handler: Box<dyn NativeCallbackHandler>,
crates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -1,12 +1,13 @@
use crate::{evaluate_add_op, LazyBinding, Result, Val};
-use gc::{Finalize, Gc, GcCell, Trace};
+use jrsonnet_gc::{Gc, GcCell, Trace};
use jrsonnet_interner::IStr;
use jrsonnet_parser::{ExprLocation, Visibility};
use rustc_hash::{FxHashMap, FxHashSet};
use std::hash::{Hash, Hasher};
use std::{fmt::Debug, hash::BuildHasherDefault};
-#[derive(Debug, Trace, Finalize)]
+#[derive(Debug, Trace)]
+#[trivially_drop]
pub struct ObjMember {
pub add: bool,
pub visibility: Visibility,
@@ -20,7 +21,8 @@
// Field => This
type CacheKey = (IStr, ObjValue);
-#[derive(Trace, Finalize)]
+#[derive(Trace)]
+#[trivially_drop]
pub struct ObjValueInternals {
super_obj: Option<ObjValue>,
assertions: Gc<Vec<Box<dyn ObjectAssertion>>>,
@@ -30,7 +32,8 @@
value_cache: GcCell<FxHashMap<CacheKey, Option<Val>>>,
}
-#[derive(Clone, Trace, Finalize)]
+#[derive(Clone, Trace)]
+#[trivially_drop]
pub struct ObjValue(pub(crate) Gc<ObjValueInternals>);
impl Debug for ObjValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
crates/jrsonnet-evaluator/src/typed.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/typed.rs
+++ b/crates/jrsonnet-evaluator/src/typed.rs
@@ -4,7 +4,7 @@
error::{Error, LocError, Result},
push, Val,
};
-use gc::{Finalize, Trace};
+use jrsonnet_gc::Trace;
use jrsonnet_parser::ExprLocation;
use jrsonnet_types::{ComplexValType, ValType};
use thiserror::Error;
@@ -21,7 +21,8 @@
}};
}
-#[derive(Debug, Error, Clone, Trace, Finalize)]
+#[derive(Debug, Error, Clone, Trace)]
+#[trivially_drop]
pub enum TypeError {
#[error("expected {0}, got {1}")]
ExpectedGot(ComplexValType, ValType),
@@ -38,7 +39,8 @@
}
}
-#[derive(Debug, Clone, Trace, Finalize)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub struct TypeLocError(Box<TypeError>, ValuePathStack);
impl From<TypeError> for TypeLocError {
fn from(e: TypeError) -> Self {
@@ -60,7 +62,8 @@
}
}
-#[derive(Debug, Clone, Trace, Finalize)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub struct TypeLocErrorList(Vec<TypeLocError>);
impl Display for TypeLocErrorList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -123,7 +126,8 @@
}
}
-#[derive(Clone, Debug, Trace, Finalize)]
+#[derive(Clone, Debug, Trace)]
+#[trivially_drop]
enum ValuePathItem {
Field(Rc<str>),
Index(u64),
@@ -138,7 +142,8 @@
}
}
-#[derive(Clone, Debug, Trace, Finalize)]
+#[derive(Clone, Debug, Trace)]
+#[trivially_drop]
struct ValuePathStack(Vec<ValuePathItem>);
impl Display for ValuePathStack {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -9,7 +9,7 @@
native::NativeCallback,
throw, with_state, Context, ObjValue, Result,
};
-use gc::{custom_trace, Finalize, Gc, GcCell, Trace};
+use jrsonnet_gc::{Finalize, Gc, GcCell, Trace};
use jrsonnet_interner::IStr;
use jrsonnet_parser::{el, Arg, ArgsDesc, Expr, ExprLocation, LiteralType, LocExpr, ParamsDesc};
use jrsonnet_types::ValType;
@@ -19,25 +19,17 @@
fn get(self: Box<Self>) -> Result<Val>;
}
+#[derive(Trace)]
+#[trivially_drop]
enum LazyValInternals {
Computed(Val),
Errored(LocError),
Waiting(Box<dyn LazyValValue>),
Pending,
-}
-impl Finalize for LazyValInternals {}
-unsafe impl Trace for LazyValInternals {
- custom_trace!(this, {
- match &this {
- LazyValInternals::Computed(v) => mark(v),
- LazyValInternals::Errored(e) => mark(e),
- LazyValInternals::Waiting(w) => mark(w),
- LazyValInternals::Pending => {}
- }
- });
}
-#[derive(Clone, Trace, Finalize)]
+#[derive(Clone, Trace)]
+#[trivially_drop]
pub struct LazyVal(Gc<GcCell<LazyValInternals>>);
impl LazyVal {
pub fn new(f: Box<dyn LazyValValue>) -> Self {
@@ -83,7 +75,8 @@
}
}
-#[derive(Debug, PartialEq, Trace, Finalize)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct FuncDesc {
pub name: IStr,
pub ctx: Context,
@@ -91,7 +84,8 @@
pub body: LocExpr,
}
-#[derive(Debug, Trace, Finalize)]
+#[derive(Debug, Trace)]
+#[trivially_drop]
pub enum FuncVal {
/// Plain function implemented in jsonnet
Normal(FuncDesc),
@@ -195,22 +189,13 @@
String,
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub enum ArrValue {
Lazy(Gc<Vec<LazyVal>>),
Eager(Gc<Vec<Val>>),
Extended(Box<(Self, Self)>),
}
-impl Finalize for ArrValue {}
-unsafe impl Trace for ArrValue {
- custom_trace!(this, {
- match &this {
- ArrValue::Lazy(l) => mark(l),
- ArrValue::Eager(e) => mark(e),
- ArrValue::Extended(x) => mark(x),
- }
- });
-}
impl ArrValue {
pub fn new_eager() -> Self {
Self::Eager(Gc::new(Vec::new()))
@@ -419,7 +404,8 @@
}
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Trace)]
+#[trivially_drop]
pub enum Val {
Bool(bool),
Null,
@@ -429,21 +415,6 @@
Obj(ObjValue),
Func(Gc<FuncVal>),
DebugGcTraceValue(DebugGcTraceValue),
-}
-impl Finalize for Val {}
-unsafe impl Trace for Val {
- custom_trace!(this, {
- match &this {
- Val::Bool(_) => {}
- Val::Null => {}
- Val::Str(_) => {}
- Val::Num(_) => {}
- Val::Arr(a) => mark(a),
- Val::Obj(o) => mark(o),
- Val::Func(f) => mark(f),
- Val::DebugGcTraceValue(v) => mark(v),
- }
- });
}
macro_rules! matches_unwrap {
crates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -9,4 +9,4 @@
[dependencies]
serde = { version = "1.0" }
rustc-hash = "1.1.0"
-gc = { version = "0.4.1", features = ["derive"] }
+jrsonnet-gc = { version = "0.4.2", features = ["derive"] }
crates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -1,4 +1,4 @@
-use gc::{unsafe_empty_trace, Finalize, Trace};
+use jrsonnet_gc::{unsafe_empty_trace, Finalize, Trace};
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use std::{
crates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -18,7 +18,7 @@
unescape = "0.1.0"
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
-gc = { version = "0.4.1", features = ["derive"] }
+jrsonnet-gc = { version = "0.4.2", features = ["derive"] }
[dev-dependencies]
jrsonnet-stdlib = { path = "../jrsonnet-stdlib", version = "0.3.8" }
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -1,4 +1,4 @@
-use gc::{unsafe_empty_trace, Finalize, Trace};
+use jrsonnet_gc::{unsafe_empty_trace, Finalize, Trace};
use jrsonnet_interner::IStr;
#[cfg(feature = "deserialize")]
use serde::Deserialize;
@@ -13,21 +13,19 @@
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub enum FieldName {
/// {fixed: 2}
Fixed(IStr),
/// {["dyn"+"amic"]: 3}
Dyn(LocExpr),
}
-impl Finalize for FieldName {}
-unsafe impl Trace for FieldName {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[trivially_drop]
pub enum Visibility {
/// :
Normal,
@@ -36,10 +34,6 @@
/// :::
Unhide,
}
-impl Finalize for Visibility {}
-unsafe impl Trace for Visibility {
- unsafe_empty_trace!();
-}
impl Visibility {
pub fn is_visible(&self) -> bool {
@@ -49,16 +43,14 @@
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);
-impl Finalize for AssertStmt {}
-unsafe impl Trace for AssertStmt {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct FieldMember {
pub name: FieldName,
pub plus: bool,
@@ -66,36 +58,26 @@
pub visibility: Visibility,
pub value: LocExpr,
}
-impl Finalize for FieldMember {}
-unsafe impl Trace for FieldMember {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub enum Member {
Field(FieldMember),
BindStmt(BindSpec),
AssertStmt(AssertStmt),
}
-impl Finalize for Member {}
-unsafe impl Trace for Member {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[trivially_drop]
pub enum UnaryOpType {
Plus,
Minus,
BitNot,
Not,
-}
-impl Finalize for UnaryOpType {}
-unsafe impl Trace for UnaryOpType {
- unsafe_empty_trace!();
}
impl Display for UnaryOpType {
@@ -116,7 +98,8 @@
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[trivially_drop]
pub enum BinaryOpType {
Mul,
Div,
@@ -145,10 +128,6 @@
And,
Or,
}
-impl Finalize for BinaryOpType {}
-unsafe impl Trace for BinaryOpType {
- unsafe_empty_trace!();
-}
impl Display for BinaryOpType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -183,22 +162,22 @@
/// name, default value
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct Param(pub IStr, pub Option<LocExpr>);
-impl Finalize for Param {}
-unsafe impl Trace for Param {
- unsafe_empty_trace!();
-}
/// Defined function parameters
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[derive(Debug, Clone, PartialEq)]
pub struct ParamsDesc(pub Rc<Vec<Param>>);
-impl Finalize for ParamsDesc {}
+
+/// Safety:
+/// AST is acyclic, and there should be no gc pointers
unsafe impl Trace for ParamsDesc {
unsafe_empty_trace!();
}
+impl Finalize for ParamsDesc {}
impl Deref for ParamsDesc {
type Target = Vec<Param>;
@@ -209,21 +188,15 @@
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct Arg(pub Option<String>, pub LocExpr);
-impl Finalize for Arg {}
-unsafe impl Trace for Arg {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct ArgsDesc(pub Vec<Arg>);
-impl Finalize for ArgsDesc {}
-unsafe impl Trace for ArgsDesc {
- unsafe_empty_trace!();
-}
impl Deref for ArgsDesc {
type Target = Vec<Arg>;
@@ -234,50 +207,39 @@
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Trace)]
+#[trivially_drop]
pub struct BindSpec {
pub name: IStr,
pub params: Option<ParamsDesc>,
pub value: LocExpr,
-}
-impl Finalize for BindSpec {}
-unsafe impl Trace for BindSpec {
- unsafe_empty_trace!();
}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct IfSpecData(pub LocExpr);
-impl Finalize for IfSpecData {}
-unsafe impl Trace for IfSpecData {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct ForSpecData(pub IStr, pub LocExpr);
-impl Finalize for ForSpecData {}
-unsafe impl Trace for ForSpecData {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub enum CompSpec {
IfSpec(IfSpecData),
ForSpec(ForSpecData),
-}
-impl Finalize for CompSpec {}
-unsafe impl Trace for CompSpec {
- unsafe_empty_trace!();
}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct ObjComp {
pub pre_locals: Vec<BindSpec>,
pub key: LocExpr,
@@ -285,26 +247,20 @@
pub post_locals: Vec<BindSpec>,
pub compspecs: Vec<CompSpec>,
}
-impl Finalize for ObjComp {}
-unsafe impl Trace for ObjComp {
- unsafe_empty_trace!();
-}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub enum ObjBody {
MemberList(Vec<Member>),
ObjComp(ObjComp),
-}
-impl Finalize for ObjBody {}
-unsafe impl Trace for ObjBody {
- unsafe_empty_trace!();
}
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Clone, Copy, Trace)]
+#[trivially_drop]
pub enum LiteralType {
This,
Super,
@@ -313,26 +269,20 @@
True,
False,
}
-impl Finalize for LiteralType {}
-unsafe impl Trace for LiteralType {
- unsafe_empty_trace!();
-}
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub struct SliceDesc {
pub start: Option<LocExpr>,
pub end: Option<LocExpr>,
pub step: Option<LocExpr>,
-}
-impl Finalize for SliceDesc {}
-unsafe impl Trace for SliceDesc {
- unsafe_empty_trace!();
}
/// Syntax base
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Trace)]
+#[trivially_drop]
pub enum Expr {
Literal(LiteralType),
@@ -396,20 +346,13 @@
cond_else: Option<LocExpr>,
},
}
-impl Finalize for Expr {}
-unsafe impl Trace for Expr {
- unsafe_empty_trace!();
-}
/// file, begin offset, end offset
#[cfg_attr(feature = "serialize", derive(Serialize))]
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
-#[derive(Clone, PartialEq)]
+#[derive(Clone, PartialEq, Trace)]
+#[trivially_drop]
pub struct ExprLocation(pub Rc<Path>, pub usize, pub usize);
-impl Finalize for ExprLocation {}
-unsafe impl Trace for ExprLocation {
- unsafe_empty_trace!();
-}
impl Debug for ExprLocation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -422,10 +365,12 @@
#[cfg_attr(feature = "deserialize", derive(Deserialize))]
#[derive(Clone, PartialEq)]
pub struct LocExpr(pub Rc<Expr>, pub Option<ExprLocation>);
-impl Finalize for LocExpr {}
+/// Safety:
+/// AST is acyclic, and there should be no gc pointers
unsafe impl Trace for LocExpr {
unsafe_empty_trace!();
}
+impl Finalize for LocExpr {}
impl Debug for LocExpr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
crates/jrsonnet-types/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -8,4 +8,4 @@
[dependencies]
peg = "0.7.0"
-gc = { version = "0.4.1", features = ["derive"] }
+jrsonnet-gc = { version = "0.4.2", features = ["derive"] }
crates/jrsonnet-types/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -1,6 +1,6 @@
#![allow(clippy::redundant_closure_call)]
-use gc::{unsafe_empty_trace, Finalize, Trace};
+use jrsonnet_gc::Trace;
use std::fmt::Display;
#[macro_export]
@@ -78,7 +78,8 @@
);
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
+#[trivially_drop]
pub enum ValType {
Bool,
Null,
@@ -87,10 +88,6 @@
Arr,
Obj,
Func,
-}
-impl Finalize for ValType {}
-unsafe impl Trace for ValType {
- unsafe_empty_trace!();
}
impl ValType {
@@ -114,7 +111,8 @@
}
}
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone, PartialEq, Trace)]
+#[trivially_drop]
pub enum ComplexValType {
Any,
Char,
@@ -127,10 +125,6 @@
UnionRef(&'static [ComplexValType]),
Sum(Vec<ComplexValType>),
SumRef(&'static [ComplexValType]),
-}
-impl Finalize for ComplexValType {}
-unsafe impl Trace for ComplexValType {
- unsafe_empty_trace!();
}
impl From<ValType> for ComplexValType {