fix(tvix/eval): address all current clippy lints

Change-Id: I758fc4f3b9078de7ca6228a75a4351c3e085c4cf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6272
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-25 18:39:27 +03:00 committed by tazjin
parent 39b01c3029
commit edee8eecdf
6 changed files with 10 additions and 13 deletions

View file

@ -43,11 +43,10 @@ fn pure_builtins() -> Vec<Builtin> {
Ok(Value::Bool(matches!(args[0], Value::Float(_)))) Ok(Value::Bool(matches!(args[0], Value::Float(_))))
}), }),
Builtin::new("isFunction", 1, |args| { Builtin::new("isFunction", 1, |args| {
Ok(Value::Bool(match args[0] { Ok(Value::Bool(matches!(
Value::Closure(_) => true, args[0],
Value::Builtin(_) => true, Value::Closure(_) | Value::Builtin(_)
_ => false, )))
}))
}), }),
Builtin::new("isInt", 1, |args| { Builtin::new("isInt", 1, |args| {
Ok(Value::Bool(matches!(args[0], Value::Integer(_)))) Ok(Value::Bool(matches!(args[0], Value::Integer(_))))

View file

@ -424,15 +424,14 @@ impl Compiler {
fn compile_has_attr(&mut self, node: ast::HasAttr) { fn compile_has_attr(&mut self, node: ast::HasAttr) {
// Put the attribute set on the stack. // Put the attribute set on the stack.
self.compile(node.expr().unwrap()); self.compile(node.expr().unwrap());
let mut count = 0;
// Push all path fragments with an operation for fetching the // Push all path fragments with an operation for fetching the
// next nested element, for all fragments except the last one. // next nested element, for all fragments except the last one.
for fragment in node.attrpath().unwrap().attrs() { for (count, fragment) in node.attrpath().unwrap().attrs().enumerate() {
if count > 0 { if count > 0 {
self.chunk().push_op(OpCode::OpAttrOrNotFound); self.chunk().push_op(OpCode::OpAttrOrNotFound);
} }
count += 1;
self.compile_attr(fragment); self.compile_attr(fragment);
} }
@ -950,7 +949,7 @@ impl Compiler {
self.scope_mut().locals.push(Local { self.scope_mut().locals.push(Local {
depth, depth,
name: name.into(), name,
node: Some(node), node: Some(node),
phantom: false, phantom: false,
used: false, used: false,

View file

@ -1,7 +1,5 @@
use std::path::PathBuf; use std::path::PathBuf;
use rnix;
use crate::{ use crate::{
builtins::global_builtins, builtins::global_builtins,
errors::{ErrorKind, EvalResult}, errors::{ErrorKind, EvalResult},

View file

@ -7,6 +7,7 @@ pub struct ConstantIdx(pub usize);
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct CodeIdx(pub usize); pub struct CodeIdx(pub usize);
#[allow(clippy::enum_variant_names)]
#[warn(variant_size_differences)] #[warn(variant_size_differences)]
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub enum OpCode { pub enum OpCode {

View file

@ -91,7 +91,7 @@ impl Display for NixAttrs {
} }
AttrsRep::Map(map) => { AttrsRep::Map(map) => {
for (name, value) in map.iter() { for (name, value) in map {
write!(f, "{} = {}; ", name.ident_str(), value)?; write!(f, "{} = {}; ", name.ident_str(), value)?;
} }
} }

View file

@ -58,7 +58,7 @@ impl Builtin {
} }
// Function is not yet ready to be called. // Function is not yet ready to be called.
return Ok(Value::Builtin(self)); Ok(Value::Builtin(self))
} }
} }