chore(tvix): fix trivial clippy lints
Relates to b/321. Change-Id: I37284f89b186e469eb432e2bbedb37aa125a6ad4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9961 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
67999f0dcf
commit
b3b1f649d6
14 changed files with 35 additions and 36 deletions
|
@ -81,7 +81,7 @@ fn parse_module_args(args: TokenStream) -> Option<Type> {
|
|||
_ => panic!("arguments to `builtins`-attribute must be of the form `name = value`"),
|
||||
};
|
||||
|
||||
if name_value.path.get_ident().unwrap().to_string() != "state" {
|
||||
if *name_value.path.get_ident().unwrap() != "state" {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ pub fn builtins(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let mut captures_state = false;
|
||||
if let FnArg::Typed(PatType { pat, .. }) = &f.sig.inputs[0] {
|
||||
if let Pat::Ident(PatIdent { ident, .. }) = pat.as_ref() {
|
||||
if ident.to_string() == "state" {
|
||||
if *ident == "state" {
|
||||
if state_type.is_none() {
|
||||
panic!("builtin captures a `state` argument, but no state type was defined");
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use tvix_eval_builtin_macros::builtins;
|
|||
|
||||
#[builtins]
|
||||
mod builtins {
|
||||
use tvix_eval::generators::{self, Gen, GenCo};
|
||||
use tvix_eval::generators::{Gen, GenCo};
|
||||
use tvix_eval::{ErrorKind, Value};
|
||||
|
||||
/// Test docstring.
|
||||
|
@ -11,12 +11,12 @@ mod builtins {
|
|||
/// It has multiple lines!
|
||||
#[builtin("identity")]
|
||||
pub async fn builtin_identity(co: GenCo, x: Value) -> Result<Value, ErrorKind> {
|
||||
Ok(todo!())
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
#[builtin("tryEval")]
|
||||
pub async fn builtin_try_eval(co: GenCo, #[lazy] _x: Value) -> Result<Value, ErrorKind> {
|
||||
todo!()
|
||||
unimplemented!("builtin is never called")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ mod pure_builtins {
|
|||
|
||||
#[builtin("toJSON")]
|
||||
async fn builtin_to_json(co: GenCo, val: Value) -> Result<Value, ErrorKind> {
|
||||
match val.to_json(&co).await? {
|
||||
match val.into_json(&co).await? {
|
||||
Err(cek) => Ok(Value::Catchable(cek)),
|
||||
Ok(json_value) => {
|
||||
let json_str = serde_json::to_string(&json_value)?;
|
||||
|
@ -1007,7 +1007,7 @@ mod pure_builtins {
|
|||
#[builtin("toPath")]
|
||||
async fn builtin_to_path(co: GenCo, s: Value) -> Result<Value, ErrorKind> {
|
||||
match coerce_value_to_path(&co, s).await? {
|
||||
Err(cek) => return Ok(Value::Catchable(cek)),
|
||||
Err(cek) => Ok(Value::Catchable(cek)),
|
||||
Ok(path) => {
|
||||
let path: Value = crate::value::canon_path(path).into();
|
||||
Ok(path.coerce_to_string(co, CoercionKind::Weak).await?)
|
||||
|
|
|
@ -1004,7 +1004,7 @@ impl Compiler<'_> {
|
|||
// For each of the bindings, push the set on the stack and
|
||||
// attempt to select from it.
|
||||
let stack_idx = self.scope().stack_index(set_idx);
|
||||
for tracked_formal in (&entries).into_iter() {
|
||||
for tracked_formal in entries.iter() {
|
||||
self.push_op(OpCode::OpGetLocal(stack_idx), pattern);
|
||||
self.emit_literal_ident(&tracked_formal.pattern_entry().ident().unwrap());
|
||||
|
||||
|
@ -1067,7 +1067,7 @@ impl Compiler<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
for tracked_formal in (&entries).into_iter() {
|
||||
for tracked_formal in entries.iter() {
|
||||
if self.scope()[tracked_formal.local_idx()].needs_finaliser {
|
||||
let stack_idx = self.scope().stack_index(tracked_formal.local_idx());
|
||||
match tracked_formal {
|
||||
|
@ -1527,7 +1527,7 @@ pub fn prepare_globals(
|
|||
Rc::new_cyclic(Box::new(move |weak: &Weak<GlobalsMap>| {
|
||||
// First step is to construct the builtins themselves as
|
||||
// `NixAttrs`.
|
||||
let mut builtins: GlobalsMap = HashMap::from_iter(builtins.into_iter());
|
||||
let mut builtins: GlobalsMap = HashMap::from_iter(builtins);
|
||||
|
||||
// At this point, optionally insert `import` if enabled. To
|
||||
// "tie the knot" of `import` needing the full set of globals
|
||||
|
@ -1574,7 +1574,7 @@ pub fn prepare_globals(
|
|||
// in the global scope.
|
||||
globals.insert(
|
||||
"builtins",
|
||||
Value::attrs(NixAttrs::from_iter(builtins.clone().into_iter())),
|
||||
Value::attrs(NixAttrs::from_iter(builtins.clone())),
|
||||
);
|
||||
|
||||
// Finally, the builtins that should be globally available are
|
||||
|
|
|
@ -301,7 +301,7 @@ impl NixAttrs {
|
|||
|
||||
/// Same as iter(), but marks call sites which rely on the
|
||||
/// iteration being lexicographic.
|
||||
pub fn iter_sorted<'a>(&'a self) -> Iter<KeyValue<'a>> {
|
||||
pub fn iter_sorted(&self) -> Iter<KeyValue<'_>> {
|
||||
self.iter()
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ impl NixAttrs {
|
|||
// /another/ set with a __toString attr.
|
||||
let s = generators::request_string_coerce(co, result, kind).await;
|
||||
|
||||
return Some(s.ok()?);
|
||||
return s.ok();
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
@ -12,7 +12,7 @@ use serde_json::Value as Json; // name clash with *our* `Value`
|
|||
use serde_json::{Map, Number};
|
||||
|
||||
impl Value {
|
||||
pub(crate) async fn to_json(
|
||||
pub(crate) async fn into_json(
|
||||
self,
|
||||
co: &GenCo,
|
||||
) -> Result<Result<Json, CatchableErrorKind>, ErrorKind> {
|
||||
|
@ -86,8 +86,8 @@ impl Value {
|
|||
|
||||
/// Generator version of the above, which wraps responses in
|
||||
/// Value::Json.
|
||||
pub(crate) async fn to_json_generator(self, co: GenCo) -> Result<Value, ErrorKind> {
|
||||
match self.to_json(&co).await? {
|
||||
pub(crate) async fn into_json_generator(self, co: GenCo) -> Result<Value, ErrorKind> {
|
||||
match self.into_json(&co).await? {
|
||||
Err(cek) => Ok(Value::Catchable(cek)),
|
||||
Ok(json) => Ok(Value::Json(json)),
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ impl NixList {
|
|||
stack_slice.len(),
|
||||
);
|
||||
|
||||
NixList(Rc::new(Vector::from_iter(stack_slice.into_iter())))
|
||||
NixList(Rc::new(Vector::from_iter(stack_slice)))
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> vector::Iter<Value> {
|
||||
|
@ -76,7 +76,7 @@ impl NixList {
|
|||
|
||||
#[deprecated(note = "callers should avoid constructing from Vec")]
|
||||
pub fn from_vec(vs: Vec<Value>) -> Self {
|
||||
Self(Rc::new(Vector::from_iter(vs.into_iter())))
|
||||
Self(Rc::new(Vector::from_iter(vs)))
|
||||
}
|
||||
|
||||
/// Asynchronous sorting algorithm in which the comparator can make use of
|
||||
|
|
|
@ -97,7 +97,7 @@ where
|
|||
Value: From<V>,
|
||||
{
|
||||
fn from(v: Result<V, CatchableErrorKind>) -> Value {
|
||||
v.map_or_else(|cek| Value::Catchable(cek), |v| v.into())
|
||||
v.map_or_else(Value::Catchable, |v| v.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ impl Value {
|
|||
kind,
|
||||
}),
|
||||
|
||||
(c @ Value::Catchable(_), _) => return Ok(c),
|
||||
(c @ Value::Catchable(_), _) => Ok(c),
|
||||
|
||||
(Value::AttrNotFound, _)
|
||||
| (Value::Blueprint(_), _)
|
||||
|
@ -762,11 +762,10 @@ fn total_fmt_float<F: std::fmt::Write>(num: f64, mut f: F) -> std::fmt::Result {
|
|||
if !new_s.is_empty() {
|
||||
s = &mut new_s
|
||||
}
|
||||
}
|
||||
// else, if this is not scientific notation, and there's a
|
||||
// decimal point, make sure we really drop trailing zeroes.
|
||||
// In some cases, lexical_core doesn't.
|
||||
else if s.contains(&b'.') {
|
||||
} else if s.contains(&b'.') {
|
||||
// else, if this is not scientific notation, and there's a
|
||||
// decimal point, make sure we really drop trailing zeroes.
|
||||
// In some cases, lexical_core doesn't.
|
||||
for (i, c) in s.iter().enumerate() {
|
||||
// at `.``
|
||||
if c == &b'.' {
|
||||
|
|
|
@ -176,10 +176,10 @@ fn nix_escape_char(ch: char, next: Option<&char>) -> Option<&'static str> {
|
|||
/// parsed as identifiers. See also cppnix commit
|
||||
/// b72bc4a972fe568744d98b89d63adcd504cb586c.
|
||||
fn is_keyword(s: &str) -> bool {
|
||||
match s {
|
||||
"if" | "then" | "else" | "assert" | "with" | "let" | "in" | "rec" | "inherit" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
s,
|
||||
"if" | "then" | "else" | "assert" | "with" | "let" | "in" | "rec" | "inherit"
|
||||
)
|
||||
}
|
||||
|
||||
/// Return true if this string can be used as an identifier in Nix.
|
||||
|
|
|
@ -473,7 +473,7 @@ impl<'o> VM<'o> {
|
|||
VMRequest::ToJson(value) => {
|
||||
self.reenqueue_generator(name, span.clone(), generator);
|
||||
self.enqueue_generator("to_json", span, |co| {
|
||||
value.to_json_generator(co)
|
||||
value.into_json_generator(co)
|
||||
});
|
||||
return Ok(false);
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ impl<'o> VM<'o> {
|
|||
.pop()
|
||||
.expect("tvix bug: runtime stack empty after execution");
|
||||
Ok(RuntimeResult {
|
||||
value: value,
|
||||
value,
|
||||
warnings: self.warnings,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::{aterm, nixhash};
|
|||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error<I> {
|
||||
#[error("parsing error: {0}")]
|
||||
ParseError(NomError<I>),
|
||||
Parser(NomError<I>),
|
||||
#[error("premature EOF")]
|
||||
Incomplete,
|
||||
#[error("validation error: {0}")]
|
||||
|
@ -38,7 +38,7 @@ pub(crate) fn parse(i: &[u8]) -> Result<Derivation, Error<&[u8]>> {
|
|||
Ok(derivation)
|
||||
}
|
||||
Err(nom::Err::Incomplete(_)) => Err(Error::Incomplete),
|
||||
Err(nom::Err::Error(e) | nom::Err::Failure(e)) => Err(Error::ParseError(e)),
|
||||
Err(nom::Err::Error(e) | nom::Err::Failure(e)) => Err(Error::Parser(e)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::parse_error::ErrorKind;
|
||||
use crate::derivation::output::Output;
|
||||
use crate::derivation::parse_error::NomError;
|
||||
use crate::derivation::parser::Error::ParseError;
|
||||
use crate::derivation::parser::Error;
|
||||
use crate::derivation::Derivation;
|
||||
use crate::store_path::StorePath;
|
||||
use bstr::{BStr, BString};
|
||||
|
@ -116,7 +116,7 @@ fn from_aterm_bytes_duplicate_map_key() {
|
|||
let err = Derivation::from_aterm_bytes(&buf).expect_err("must fail");
|
||||
|
||||
match err {
|
||||
ParseError(NomError { input: _, code }) => {
|
||||
Error::Parser(NomError { input: _, code }) => {
|
||||
assert_eq!(code, ErrorKind::DuplicateMapKey("name".to_string()));
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -421,7 +421,7 @@ impl FileSystem for TvixStoreFs {
|
|||
let written = add_entry(fuse_backend_rs::api::filesystem::DirEntry {
|
||||
ino,
|
||||
offset: offset + i as u64 + 1,
|
||||
type_: ty as u32,
|
||||
type_: ty,
|
||||
name: store_path.to_string().as_bytes(),
|
||||
})?;
|
||||
// If the buffer is full, add_entry will return `Ok(0)`.
|
||||
|
|
Loading…
Reference in a new issue