From 71174f6626cbf100a8428ddc334681e4edfb45e6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 20 Dec 2022 17:22:56 +0300 Subject: fix(tvix/eval): fix current clippy warnings It's been a while since the last time, so quite a lot of stuff has accumulated here. Change-Id: I0762827c197b30a917ff470fd8ae8f220f6ba247 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7597 Reviewed-by: grfn Autosubmit: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/builtins/mod.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'tvix/eval/src/builtins') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index e4e9c14df6b8..3c635eb364ca 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -414,7 +414,7 @@ mod pure_builtins { let mut res: BTreeMap> = BTreeMap::new(); for val in list.to_list()? { let key = vm.call_with(&f, [val.clone()])?.force(vm)?.to_str()?; - res.entry(key).or_insert_with(|| vec![]).push(val); + res.entry(key).or_insert_with(std::vec::Vec::new).push(val); } Ok(Value::attrs(NixAttrs::from_iter( res.into_iter() @@ -688,7 +688,7 @@ mod pure_builtins { // We already applied a from->to with an empty from // transformation. // Let's skip it so that we don't loop infinitely - if empty_string_replace && from.as_str().len() == 0 { + if empty_string_replace && from.as_str().is_empty() { continue; } @@ -698,7 +698,7 @@ mod pure_builtins { i += from.len(); // remember if we applied the empty from->to - empty_string_replace = from.as_str().len() == 0; + empty_string_replace = from.as_str().is_empty(); continue 'outer; } @@ -719,7 +719,7 @@ mod pure_builtins { let from = elem.0.to_str()?; let to = elem.1.to_str()?; - if from.as_str().len() == 0 { + if from.as_str().is_empty() { res += &to; break; } @@ -866,9 +866,7 @@ mod pure_builtins { let len = len as usize; let end = cmp::min(beg + len, x.as_str().len()); - Ok(Value::String( - x.as_str()[(beg as usize)..(end as usize)].into(), - )) + Ok(Value::String(x.as_str()[beg..end].into())) } #[builtin("tail")] @@ -1070,10 +1068,7 @@ pub fn global_builtins(source: SourceCode) -> GlobalsMapFunc { // We need to insert import into the builtins, but the // builtins passed to import must have import *in it*. - let import = Value::Builtin(crate::builtins::impure::builtins_import( - globals, - source.clone(), - )); + let import = Value::Builtin(crate::builtins::impure::builtins_import(globals, source)); map.insert("import", import); }; -- cgit 1.4.1