difftreelog
style fix clippy warnings
in: master
8 files changed
crates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/arr/mod.rs
+++ b/crates/jrsonnet-evaluator/src/arr/mod.rs
@@ -1,7 +1,4 @@
-use std::{
- any::Any,
- num::{NonZeroU32, NonZeroUsize},
-};
+use std::{any::Any, num::NonZeroU32};
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::IBytes;
crates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -110,7 +110,11 @@
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 as i32), Some(to as i32), None)))
+ Ok(Val::Arr(full.slice(
+ Some(self.start as i32),
+ Some(to as i32),
+ None,
+ )))
}
}
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -2,7 +2,7 @@
cell::RefCell,
fmt::{self, Debug, Display},
mem::replace,
- num::{NonZeroU32, NonZeroUsize},
+ num::NonZeroU32,
rc::Rc,
};
crates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -218,8 +218,7 @@
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let attr = parse_macro_input!(attr as BuiltinAttrs);
- let item_fn = item.clone();
- let item_fn: ItemFn = parse_macro_input!(item_fn);
+ let item_fn = parse_macro_input!(item as ItemFn);
match builtin_inner(attr, item_fn) {
Ok(v) => v.into(),
crates/jrsonnet-stdlib/src/manifest/toml.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/manifest/toml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/toml.rs
@@ -4,7 +4,7 @@
bail,
manifest::{escape_string_json_buf, ManifestFormat},
val::ArrValue,
- IStr, ObjValue, Result, ResultExt, Val, State,
+ IStr, ObjValue, Result, ResultExt, State, Val,
};
pub struct TomlFormat<'s> {
crates/jrsonnet-stdlib/src/manifest/xml.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/manifest/xml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/xml.rs
@@ -1,9 +1,9 @@
use jrsonnet_evaluator::{
bail,
manifest::{ManifestFormat, ToStringFormat},
- typed::{ComplexValType, Either2, Either4, Typed, ValType},
- val::{ArrValue, IndexableVal},
- Either, ObjValue, Result, ResultExt, Val, State,
+ typed::{ComplexValType, Either2, Typed, ValType},
+ val::ArrValue,
+ Either, ObjValue, Result, ResultExt, State, Val,
};
pub struct XmlJsonmlFormat {
@@ -39,20 +39,20 @@
fn from_untyped(untyped: Val) -> Result<Self> {
let val = <Either![ArrValue, String]>::from_untyped(untyped)
- .with_description(|| format!("parsing JSONML value (an array or string)"))?;
+ .description("parsing JSONML value (an array or string)")?;
let arr = match val {
Either2::A(a) => a,
Either2::B(s) => return Ok(Self::String(s)),
};
- if arr.len() < 1 {
+ if arr.is_empty() {
bail!("JSONML value should have tag (array length should be >=1)");
};
let tag = String::from_untyped(
arr.get(0)
- .with_description(|| "getting JSONML tag")?
+ .description("getting JSONML tag")?
.expect("length checked"),
)
- .with_description(|| format!("parsing JSONML tag"))?;
+ .description("parsing JSONML tag")?;
let (has_attrs, attrs) = if arr.len() >= 2 {
let maybe_attrs = arr
@@ -71,7 +71,7 @@
tag,
attrs,
children: State::push_description(
- || format!("parsing children"),
+ || "parsing children".to_owned(),
|| {
Typed::from_untyped(Val::Arr(arr.slice(
Some(if has_attrs { 2 } else { 1 }),
@@ -100,7 +100,7 @@
} => {
let has_children = !children.is_empty();
buf.push('<');
- buf.push_str(&tag);
+ buf.push_str(tag);
attrs.run_assertions()?;
for (key, value) in attrs.iter(
// Not much sense to preserve order here
@@ -125,12 +125,12 @@
}
buf.push('>');
for child in children {
- manifest_jsonml(&child, buf, opts)?;
+ manifest_jsonml(child, buf, opts)?;
}
if has_children || opts.force_closing {
buf.push('<');
buf.push('/');
- buf.push_str(&tag);
+ buf.push_str(tag);
buf.push('>');
}
Ok(())
@@ -177,8 +177,8 @@
}
if !found {
// No match - no escapes required
- out.push_str(&str);
+ out.push_str(str);
return;
}
- out.push_str(&remaining);
+ out.push_str(remaining);
}
crates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -28,8 +28,7 @@
o: ObjValue,
f: IStr,
default: Option<Thunk<Val>>,
- #[default(true)]
- inc_hidden: bool,
+ #[default(true)] inc_hidden: bool,
) -> Result<Val> {
let do_default = move || {
let Some(default) = default else {
crates/jrsonnet-stdlib/src/objects.rsdiffbeforeafterboth1use jrsonnet_evaluator::{2 function::builtin,3 val::{ArrValue, Val},4 IStr, ObjValue, ObjValueBuilder,5};67#[builtin]8pub fn builtin_object_fields_ex(9 obj: ObjValue,10 hidden: bool,1112 #[default(false)]13 #[cfg(feature = "exp-preserve-order")]14 preserve_order: bool,15) -> Vec<Val> {16 let out = obj.fields_ex(17 hidden,18 #[cfg(feature = "exp-preserve-order")]19 preserve_order,20 );21 out.into_iter().map(Val::string).collect::<Vec<_>>()22}2324#[builtin]25pub fn builtin_object_fields(26 o: ObjValue,2728 #[default(false)]29 #[cfg(feature = "exp-preserve-order")]30 preserve_order: bool,31) -> Vec<Val> {32 builtin_object_fields_ex(33 o,34 false,35 #[cfg(feature = "exp-preserve-order")]36 preserve_order,37 )38}3940#[builtin]41pub fn builtin_object_fields_all(42 o: ObjValue,4344 #[default(false)]45 #[cfg(feature = "exp-preserve-order")]46 preserve_order: bool,47) -> Vec<Val> {48 builtin_object_fields_ex(49 o,50 true,51 #[cfg(feature = "exp-preserve-order")]52 preserve_order,53 )54}5556pub fn builtin_object_values_ex(57 o: ObjValue,58 include_hidden: bool,5960 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,61) -> ArrValue {62 o.values_ex(63 include_hidden,64 #[cfg(feature = "exp-preserve-order")]65 preserve_order,66 )67}68#[builtin]69pub fn builtin_object_values(70 o: ObjValue,7172 #[default(false)]73 #[cfg(feature = "exp-preserve-order")]74 preserve_order: bool,75) -> ArrValue {76 builtin_object_values_ex(77 o,78 false,79 #[cfg(feature = "exp-preserve-order")]80 preserve_order,81 )82}83#[builtin]84pub fn builtin_object_values_all(85 o: ObjValue,8687 #[default(false)]88 #[cfg(feature = "exp-preserve-order")]89 preserve_order: bool,90) -> ArrValue {91 builtin_object_values_ex(92 o,93 true,94 #[cfg(feature = "exp-preserve-order")]95 preserve_order,96 )97}9899pub fn builtin_object_keys_values_ex(100 o: ObjValue,101 include_hidden: bool,102103 #[cfg(feature = "exp-preserve-order")] preserve_order: bool,104) -> ArrValue {105 o.key_values_ex(106 include_hidden,107 #[cfg(feature = "exp-preserve-order")]108 preserve_order,109 )110}111#[builtin]112pub fn builtin_object_keys_values(113 o: ObjValue,114115 #[default(false)]116 #[cfg(feature = "exp-preserve-order")]117 preserve_order: bool,118) -> ArrValue {119 builtin_object_keys_values_ex(120 o,121 false,122 #[cfg(feature = "exp-preserve-order")]123 preserve_order,124 )125}126#[builtin]127pub fn builtin_object_keys_values_all(128 o: ObjValue,129130 #[default(false)]131 #[cfg(feature = "exp-preserve-order")]132 preserve_order: bool,133) -> ArrValue {134 builtin_object_keys_values_ex(135 o,136 true,137 #[cfg(feature = "exp-preserve-order")]138 preserve_order,139 )140}141142#[builtin]143pub fn builtin_object_has_ex(obj: ObjValue, fname: IStr, hidden: bool) -> bool {144 obj.has_field_ex(fname, hidden)145}146147#[builtin]148pub fn builtin_object_has(o: ObjValue, f: IStr) -> bool {149 o.has_field(f)150}151152#[builtin]153pub fn builtin_object_has_all(o: ObjValue, f: IStr) -> bool {154 o.has_field_include_hidden(f)155}156157#[builtin]158pub fn builtin_object_remove_key(159 obj: ObjValue,160 key: IStr,161162 // Standard implementation uses std.objectFields without such argument, we can't163 // assume order preservation should always be enabled/disabled164 #[default(false)]165 #[cfg(feature = "exp-preserve-order")]166 preserve_order: bool,167) -> ObjValue {168 let mut new_obj = ObjValueBuilder::with_capacity(obj.len() - 1);169 for (k, v) in obj.iter(170 #[cfg(feature = "exp-preserve-order")]171 preserve_order,172 ) {173 if k == key {174 continue;175 }176 new_obj.field(k).value(v.unwrap());177 }178179 new_obj.build()180}