difftreelog
fix experimental features build
in: master
3 files changed
cmds/jrsonnet/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -186,8 +186,12 @@
};
let tla = opts.tla.tla_opts()?;
- #[allow(unused_mut)]
- let mut val = apply_tla(s, &tla, val)?;
+ #[allow(
+ // It is not redundant/unused in exp-apply
+ unused_mut,
+ clippy::redundant_clone,
+ )]
+ let mut val = apply_tla(s.clone(), &tla, val)?;
#[cfg(feature = "exp-apply")]
for apply in opts.input.exp_apply {
crates/jrsonnet-stdlib/src/arrays.rsdiffbeforeafterboth71pub fn builtin_map_with_key(func: FuncVal, obj: ObjValue) -> Result<ObjValue> {71pub fn builtin_map_with_key(func: FuncVal, obj: ObjValue) -> Result<ObjValue> {72 let mut out = ObjValueBuilder::new();72 let mut out = ObjValueBuilder::new();73 for (k, v) in obj.iter() {73 for (k, v) in obj.iter(74 // Makes sense mapped object should be ordered the same way, should not break anything when the output is not ordered (the default).75 // The thrown error might be different, but jsonnet76 // does not specify the evaluation order.77 #[cfg(feature = "exp-preserve-order")]78 true,79 ) {74 let v = v?;80 let v = v?;75 out.field(k.clone())81 out.field(k.clone())crates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -147,7 +147,14 @@
if equals(&a, &b)? {
return Ok(true);
}
- let format = JsonFormat::std_to_json(" ".to_owned(), "\n", ": ");
+ // TODO: Use debug output format
+ let format = JsonFormat::std_to_json(
+ " ".to_owned(),
+ "\n",
+ ": ",
+ #[cfg(feature = "exp-preserve-order")]
+ true,
+ );
let a = a.manifest(&format).description("<a> manifestification")?;
let b = b.manifest(&format).description("<b> manifestification")?;
bail!("assertion failed: A != B\nA: {a}\nB: {b}")
@@ -161,8 +168,30 @@
let Some(target) = target.as_obj() else {
return Ok(Val::Obj(patch));
};
- let target_fields = target.fields().into_iter().collect::<BTreeSet<IStr>>();
- let patch_fields = patch.fields().into_iter().collect::<BTreeSet<IStr>>();
+ let target_fields = target
+ .fields(
+ // FIXME: Makes no sense to preserve order for BTreeSet, it would be better to use IndexSet here?
+ // But IndexSet won't allow fast ordered union...
+ // // Makes sense to preserve source ordering where possible.
+ // // May affect evaluation order, but it is not specified by jsonnet spec.
+ // #[cfg(feature = "exp-preserve-order")]
+ // true,
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ )
+ .into_iter()
+ .collect::<BTreeSet<IStr>>();
+ let patch_fields = patch
+ .fields(
+ // No need to look at the patch field order, I think?
+ // New fields (that will be appended at the end) will be alphabeticaly-ordered,
+ // but it is fine for jsonpatch, I don't think people write jsonpatch in jsonnet,
+ // when they can use mixins.
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ )
+ .into_iter()
+ .collect::<BTreeSet<IStr>>();
let mut out = ObjValueBuilder::new();
for field in target_fields.union(&patch_fields) {