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

difftreelog

build use `workspace.dependencies`

Yaroslav Bolyukin2022-10-26parent: #fe52b32.patch.diff
in: master

16 files changed

modifiedCargo.lockdiffbeforeafterboth
before · Cargo.lock
81 packageslockfile v3
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,16 @@
 [workspace]
+package.version = "0.5.0"
 members = ["crates/*", "bindings/jsonnet", "cmds/jrsonnet", "tests"]
 
+[workspace.dependencies]
+jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0" }
+jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0" }
+jrsonnet-parser = { path = "./crates/jrsonnet-parser", version = "0.5.0" }
+jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0" }
+jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0" }
+jrsonnet-cli = { path = "./crates/jrsonnet-cli", version = "0.5.0" }
+jrsonnet-types = { path = "./crates/jrsonnet-types", version = "0.5.0" }
+
 [profile.test]
 opt-level = 1
 
modifiedbindings/jsonnet/Cargo.tomldiffbeforeafterboth
--- a/bindings/jsonnet/Cargo.toml
+++ b/bindings/jsonnet/Cargo.toml
@@ -1,16 +1,16 @@
 [package]
 name = "libjsonnet"
 description = "Rust implementation of libjsonnet.so"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
 publish = false
 
 [dependencies]
-jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2" }
-jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
-jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
+jrsonnet-evaluator.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-stdlib.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 [lib]
modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet"
 description = "Rust jsonnet implementation"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -21,9 +21,9 @@
 legacy-this-file = ["jrsonnet-cli/legacy-this-file"]
 
 [dependencies]
-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-evaluator.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-cli.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 mimallocator = { version = "0.1.3", optional = true }
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-cli"
 description = "Utilities for building jrsonnet CLIs"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -14,11 +14,9 @@
 legacy-this-file = ["jrsonnet-stdlib/legacy-this-file"]
 
 [dependencies]
-jrsonnet-evaluator = { path = "../../crates/jrsonnet-evaluator", version = "0.4.2", features = [
-    "explaining-traces",
-] }
-jrsonnet-parser = { path = "../../crates/jrsonnet-parser", version = "0.4.2" }
+jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }
+jrsonnet-parser.workspace = true
+jrsonnet-stdlib.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
-jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
 
 clap = { version = "4.0", features = ["derive"] }
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-evaluator"
 description = "jsonnet interpreter"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -24,10 +24,10 @@
 nightly = []
 
 [dependencies]
-jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
-jrsonnet-types = { path = "../jrsonnet-types", version = "0.4.2" }
-jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
+jrsonnet-interner.workspace = true
+jrsonnet-parser.workspace = true
+jrsonnet-types.workspace = true
+jrsonnet-macros.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 pathdiff = "0.2.1"
modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -32,7 +32,7 @@
 		Destruct::Array { start, rest, end } => {
 			use jrsonnet_parser::DestructRest;
 
-			use crate::{throw, val::ArrValue};
+			use crate::val::ArrValue;
 
 			#[derive(Trace)]
 			struct DataThunk {
@@ -43,8 +43,8 @@
 			impl ThunkValue for DataThunk {
 				type Output = ArrValue;
 
-				fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-					let v = self.parent.evaluate(s)?;
+				fn get(self: Box<Self>) -> Result<Self::Output> {
+					let v = self.parent.evaluate()?;
 					let arr = match v {
 						Val::Arr(a) => a,
 						_ => throw!("expected array"),
@@ -79,9 +79,9 @@
 				impl ThunkValue for BaseThunk {
 					type Output = Val;
 
-					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-						let full = self.full.evaluate(s.clone())?;
-						Ok(full.get(s, self.index)?.expect("length is checked"))
+					fn get(self: Box<Self>) -> Result<Self::Output> {
+						let full = self.full.evaluate()?;
+						Ok(full.get(self.index)?.expect("length is checked"))
 					}
 				}
 				for (i, d) in start.iter().enumerate() {
@@ -108,8 +108,8 @@
 					impl ThunkValue for RestThunk {
 						type Output = Val;
 
-						fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-							let full = self.full.evaluate(s)?;
+						fn get(self: Box<Self>) -> Result<Self::Output> {
+							let full = self.full.evaluate()?;
 							let to = full.len() - self.end;
 							Ok(Val::Arr(full.slice(Some(self.start), Some(to), None)))
 						}
@@ -140,10 +140,10 @@
 				impl ThunkValue for EndThunk {
 					type Output = Val;
 
-					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-						let full = self.full.evaluate(s.clone())?;
+					fn get(self: Box<Self>) -> Result<Self::Output> {
+						let full = self.full.evaluate()?;
 						Ok(full
-							.get(s, full.len() - self.end + self.index)?
+							.get(full.len() - self.end + self.index)?
 							.expect("length is checked"))
 					}
 				}
@@ -163,7 +163,7 @@
 		}
 		#[cfg(feature = "exp-destruct")]
 		Destruct::Object { fields, rest } => {
-			use crate::{obj::ObjValue, throw};
+			use crate::obj::ObjValue;
 
 			#[derive(Trace)]
 			struct DataThunk {
@@ -174,8 +174,8 @@
 			impl ThunkValue for DataThunk {
 				type Output = ObjValue;
 
-				fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-					let v = self.parent.evaluate(s)?;
+				fn get(self: Box<Self>) -> Result<Self::Output> {
+					let v = self.parent.evaluate()?;
 					let obj = match v {
 						Val::Obj(o) => o,
 						_ => throw!("expected object"),
@@ -215,13 +215,13 @@
 				impl ThunkValue for FieldThunk {
 					type Output = Val;
 
-					fn get(self: Box<Self>, s: State) -> Result<Self::Output> {
-						let full = self.full.evaluate(s.clone())?;
-						if let Some(field) = full.get(s.clone(), self.field)? {
+					fn get(self: Box<Self>) -> Result<Self::Output> {
+						let full = self.full.evaluate()?;
+						if let Some(field) = full.get(self.field)? {
 							Ok(field)
 						} else {
 							let (fctx, expr) = self.default.as_ref().expect("shape is checked");
-							Ok(evaluate(s, fctx.clone().unwrap(), &expr)?)
+							Ok(evaluate(fctx.clone().unwrap(), &expr)?)
 						}
 					}
 				}
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -178,7 +178,10 @@
 			}
 			Val::Obj(obj) => {
 				let mut map = serializer.serialize_map(Some(obj.len()))?;
-				for (field, value) in obj.iter() {
+				for (field, value) in obj.iter(
+					#[cfg(feature = "exp-preserve-order")]
+					true,
+				) {
 					let mut serde_error = None;
 					// TODO: rewrite using try{} after stabilization
 					State::push_description(
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -368,8 +368,14 @@
 			.map_or(false, |v| v.is_visible())
 	}
 
-	pub fn iter(&self) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {
-		let fields = self.fields();
+	pub fn iter(
+		&self,
+		#[cfg(feature = "exp-preserve-order")] preserve_order: bool,
+	) -> impl Iterator<Item = (IStr, Result<Val>)> + '_ {
+		let fields = self.fields(
+			#[cfg(feature = "exp-preserve-order")]
+			preserve_order,
+		);
 		fields.into_iter().map(|field| {
 			(
 				field.clone(),
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -625,6 +625,7 @@
 pub fn format_arr(str: &str, mut values: &[Val]) -> Result<String> {
 	let codes = parse_codes(str)?;
 	let mut out = String::new();
+	let value_count = values.len();
 
 	for code in codes {
 		match code {
@@ -673,6 +674,13 @@
 		}
 	}
 
+	if !values.is_empty() {
+		throw!(
+			"too many values to format, expected {value_count}, got {}",
+			value_count + values.len()
+		)
+	}
+
 	Ok(out)
 }
 
modifiedcrates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-interner"
 description = "Jrsonnet string interning"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -255,9 +255,7 @@
 		let mut pool = pool.borrow_mut();
 		let entry = pool.raw_entry_mut().from_key(bytes);
 		match entry {
-			hashbrown::hash_map::RawEntryMut::Occupied(mut i) => {
-				IBytes(i.get_key_value().0.clone())
-			}
+			hashbrown::hash_map::RawEntryMut::Occupied(i) => IBytes(i.get_key_value().0.clone()),
 			hashbrown::hash_map::RawEntryMut::Vacant(e) => {
 				let (k, _) = e.insert(Inner::new_bytes(bytes), ());
 				IBytes(k.clone())
modifiedcrates/jrsonnet-macros/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-macros/Cargo.toml
+++ b/crates/jrsonnet-macros/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "jrsonnet-macros"
-version = "0.4.2"
+version.workspace = true
 edition = "2021"
 
 [lib]
modifiedcrates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-parser"
 description = "jsonnet language parser and AST"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -26,7 +26,7 @@
 serde = ["dep:serde"]
 
 [dependencies]
-jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
+jrsonnet-interner.workspace = true
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 static_assertions = "1.1"
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-stdlib"
 description = "jsonnet standard library packaged as crate"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"
@@ -17,9 +17,9 @@
 exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
 
 [dependencies]
-jrsonnet-evaluator = { path = "../jrsonnet-evaluator", version = "0.4.2" }
-jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
+jrsonnet-evaluator.workspace = true
+jrsonnet-macros.workspace = true
+jrsonnet-parser.workspace = true
 jrsonnet-gcmodule = "0.3.4"
 
 # Used for stdlib AST serialization
@@ -37,5 +37,5 @@
 serde_yaml_with_quirks = "0.8.24"
 
 [build-dependencies]
-jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
+jrsonnet-parser.workspace = true
 structdump = { version = "0.2.0", features = ["derive"] }
modifiedcrates/jrsonnet-types/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "jrsonnet-types"
 description = "Jrsonnet type system definition"
-version = "0.4.2"
+version.workspace = true
 authors = ["Yaroslav Bolyukin <iam@lach.pw>"]
 license = "MIT"
 edition = "2021"