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")]61 preserve_order: bool,62) -> ArrValue {63 o.values_ex(64 include_hidden,65 #[cfg(feature = "exp-preserve-order")]66 preserve_order,67 )68}69#[builtin]70pub fn builtin_object_values(71 o: ObjValue,7273 #[default(false)]74 #[cfg(feature = "exp-preserve-order")]75 preserve_order: bool,76) -> ArrValue {77 builtin_object_values_ex(78 o,79 false,80 #[cfg(feature = "exp-preserve-order")]81 preserve_order,82 )83}84#[builtin]85pub fn builtin_object_values_all(86 o: ObjValue,8788 #[default(false)]89 #[cfg(feature = "exp-preserve-order")]90 preserve_order: bool,91) -> ArrValue {92 builtin_object_values_ex(93 o,94 true,95 #[cfg(feature = "exp-preserve-order")]96 preserve_order,97 )98}99100pub fn builtin_object_keys_values_ex(101 o: ObjValue,102 include_hidden: bool,103104 #[cfg(feature = "exp-preserve-order")]105 preserve_order: bool,106) -> ArrValue {107 o.key_values_ex(108 include_hidden,109 #[cfg(feature = "exp-preserve-order")]110 preserve_order,111 )112}113#[builtin]114pub fn builtin_object_keys_values(115 o: ObjValue,116117 #[default(false)]118 #[cfg(feature = "exp-preserve-order")]119 preserve_order: bool,120) -> ArrValue {121 builtin_object_keys_values_ex(122 o,123 false,124 #[cfg(feature = "exp-preserve-order")]125 preserve_order,126 )127}128#[builtin]129pub fn builtin_object_keys_values_all(130 o: ObjValue,131132 #[default(false)]133 #[cfg(feature = "exp-preserve-order")]134 preserve_order: bool,135) -> ArrValue {136 builtin_object_keys_values_ex(137 o,138 true,139 #[cfg(feature = "exp-preserve-order")]140 preserve_order,141 )142}143144#[builtin]145pub fn builtin_object_has_ex(obj: ObjValue, fname: IStr, hidden: bool) -> bool {146 obj.has_field_ex(fname, hidden)147}148149#[builtin]150pub fn builtin_object_has(o: ObjValue, f: IStr) -> bool {151 o.has_field(f)152}153154#[builtin]155pub fn builtin_object_has_all(o: ObjValue, f: IStr) -> bool {156 o.has_field_include_hidden(f)157}158159#[builtin]160pub fn builtin_object_remove_key(161 obj: ObjValue,162 key: IStr,163164 // Standard implementation uses std.objectFields without such argument, we can't165 // assume order preservation should always be enabled/disabled166 #[default(false)]167 #[cfg(feature = "exp-preserve-order")]168 preserve_order: bool,169) -> ObjValue {170 let mut new_obj = ObjValueBuilder::with_capacity(obj.len() - 1);171 for (k, v) in obj.iter(172 #[cfg(feature = "exp-preserve-order")]173 preserve_order,174 ) {175 if k == key {176 continue;177 }178 new_obj.field(k).value(v.unwrap());179 }180181 new_obj.build()182}