Skip to content

Commit

Permalink
style: fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed May 17, 2024
1 parent 0b4fbcf commit 261130a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 28 deletions.
5 changes: 1 addition & 4 deletions crates/jrsonnet-evaluator/src/arr/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 5 additions & 1 deletion crates/jrsonnet-evaluator/src/evaluate/destructure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ pub fn destruct(
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,
)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-evaluator/src/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{
cell::RefCell,
fmt::{self, Debug, Display},
mem::replace,
num::{NonZeroU32, NonZeroUsize},
num::NonZeroU32,
rc::Rc,
};

Expand Down
3 changes: 1 addition & 2 deletions crates/jrsonnet-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ pub fn builtin(
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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-stdlib/src/manifest/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use jrsonnet_evaluator::{
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> {
Expand Down
26 changes: 13 additions & 13 deletions crates/jrsonnet-stdlib/src/manifest/xml.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -39,20 +39,20 @@ impl Typed for JSONMLValue {

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
Expand All @@ -71,7 +71,7 @@ impl Typed for JSONMLValue {
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 }),
Expand Down Expand Up @@ -100,7 +100,7 @@ fn manifest_jsonml(v: &JSONMLValue, buf: &mut String, opts: &XmlJsonmlFormat) ->
} => {
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
Expand All @@ -125,12 +125,12 @@ fn manifest_jsonml(v: &JSONMLValue, buf: &mut String, opts: &XmlJsonmlFormat) ->
}
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(())
Expand Down Expand Up @@ -177,8 +177,8 @@ fn escape_string_xml_buf(str: &str, out: &mut String) {
}
if !found {
// No match - no escapes required
out.push_str(&str);
out.push_str(str);
return;
}
out.push_str(&remaining);
out.push_str(remaining);
}
3 changes: 1 addition & 2 deletions crates/jrsonnet-stdlib/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub fn builtin_get(
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 {
Expand Down
6 changes: 2 additions & 4 deletions crates/jrsonnet-stdlib/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ pub fn builtin_object_values_ex(
o: ObjValue,
include_hidden: bool,

#[cfg(feature = "exp-preserve-order")]
preserve_order: bool,
#[cfg(feature = "exp-preserve-order")] preserve_order: bool,
) -> ArrValue {
o.values_ex(
include_hidden,
Expand Down Expand Up @@ -101,8 +100,7 @@ pub fn builtin_object_keys_values_ex(
o: ObjValue,
include_hidden: bool,

#[cfg(feature = "exp-preserve-order")]
preserve_order: bool,
#[cfg(feature = "exp-preserve-order")] preserve_order: bool,
) -> ArrValue {
o.key_values_ex(
include_hidden,
Expand Down

0 comments on commit 261130a

Please sign in to comment.