From 59dbbcce3d0310b62fcdde9ed3666d76a52c57ea Mon Sep 17 00:00:00 2001 From: Josh Pschorr Date: Wed, 15 Jan 2025 15:15:17 -0800 Subject: [PATCH] Silence some spurious clippy warnings. (#538) --- partiql-conformance-test-generator/src/schema.rs | 12 ++++++++++++ partiql-conformance-tests/build.rs | 4 +++- partiql-eval/Cargo.toml | 12 ++++++++++++ partiql-eval/src/eval/mod.rs | 3 +++ partiql-value/src/lib.rs | 3 --- partiql/tests/common.rs | 6 ++++++ partiql/tests/comparisons.rs | 1 + partiql/tests/pretty.rs | 2 ++ 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/partiql-conformance-test-generator/src/schema.rs b/partiql-conformance-test-generator/src/schema.rs index d922fc20..e6d90db4 100644 --- a/partiql-conformance-test-generator/src/schema.rs +++ b/partiql-conformance-test-generator/src/schema.rs @@ -69,6 +69,8 @@ pub mod spec { } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub enum Assertion { SyntaxSuccess(SyntaxSuccessAssertion), SyntaxFail(SyntaxFailAssertion), @@ -138,21 +140,29 @@ pub mod spec { } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub struct SyntaxSuccessAssertion { pub result: String, } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub struct SyntaxFailAssertion { pub result: String, } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub struct StaticAnalysisFailAssertion { pub result: String, } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub struct EvaluationSuccessAssertion { pub result: String, pub output: Element, @@ -160,6 +170,8 @@ pub mod spec { } #[derive(Debug, Clone)] + // Assertions model the partiql-tests DSL; there are some spurious warnings before code generation. + #[allow(dead_code)] pub struct EvaluationFailAssertion { pub result: String, pub eval_mode: EvaluationModeList, diff --git a/partiql-conformance-tests/build.rs b/partiql-conformance-tests/build.rs index eeb37e89..2247f509 100644 --- a/partiql-conformance-tests/build.rs +++ b/partiql-conformance-tests/build.rs @@ -12,7 +12,9 @@ fn main() -> miette::Result<()> { .arg("fmt") .arg("--") .spawn() - .expect("cargo fmt of tests/ failed"); + .expect("cargo fmt of tests/ failed") + .wait() + .expect("cargo fmt of tests/ failed to exit"); Ok(()) } diff --git a/partiql-eval/Cargo.toml b/partiql-eval/Cargo.toml index 67d9a26d..853435a2 100644 --- a/partiql-eval/Cargo.toml +++ b/partiql-eval/Cargo.toml @@ -38,9 +38,21 @@ regex-syntax = "0.8" rustc-hash = "2" delegate = "0.13" +serde = { version = "1", features = ["derive"], optional = true } + [dev-dependencies] criterion = "0.5" + +[features] +default = [] +serde = [ + "dep:serde", + "rust_decimal/serde-with-str", + "partiql-logical/serde", + "partiql-value/serde", +] + [[bench]] name = "bench_eval" harness = false diff --git a/partiql-eval/src/eval/mod.rs b/partiql-eval/src/eval/mod.rs index 77a67a57..6d2a4462 100644 --- a/partiql-eval/src/eval/mod.rs +++ b/partiql-eval/src/eval/mod.rs @@ -25,6 +25,9 @@ use unicase::UniCase; use crate::eval::evaluable::{EvalType, Evaluable}; use crate::plan::EvaluationMode; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + pub(crate) mod eval_expr_wrapper; pub mod evaluable; pub mod expr; diff --git a/partiql-value/src/lib.rs b/partiql-value/src/lib.rs index 677a6f14..3abb3bf3 100644 --- a/partiql-value/src/lib.rs +++ b/partiql-value/src/lib.rs @@ -23,9 +23,6 @@ pub use sort::*; pub use tuple::*; pub use value::*; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; - #[cfg(test)] mod tests { use super::*; diff --git a/partiql/tests/common.rs b/partiql/tests/common.rs index b34b18f4..30a23147 100644 --- a/partiql/tests/common.rs +++ b/partiql/tests/common.rs @@ -56,12 +56,14 @@ impl From> for TestError<'_> { } } +#[allow(dead_code)] #[track_caller] #[inline] pub fn parse(statement: &str) -> ParserResult<'_> { partiql_parser::Parser::default().parse(statement) } +#[allow(dead_code)] #[track_caller] #[inline] pub fn lower( @@ -72,6 +74,7 @@ pub fn lower( planner.lower(parsed) } +#[allow(dead_code)] #[track_caller] #[inline] pub fn compile( @@ -83,6 +86,7 @@ pub fn compile( planner.compile(&logical) } +#[allow(dead_code)] #[track_caller] #[inline] pub fn evaluate(mut plan: EvalPlan, bindings: MapBindings) -> EvalResult { @@ -93,6 +97,7 @@ pub fn evaluate(mut plan: EvalPlan, bindings: MapBindings) -> EvalResult plan.execute_mut(&ctx) } +#[allow(dead_code)] #[track_caller] #[inline] pub fn eval_query_with_catalog<'a>( @@ -107,6 +112,7 @@ pub fn eval_query_with_catalog<'a>( Ok(evaluate(plan, bindings)?) } +#[allow(dead_code)] #[track_caller] #[inline] pub fn eval_query(statement: &str, mode: EvaluationMode) -> Result> { diff --git a/partiql/tests/comparisons.rs b/partiql/tests/comparisons.rs index 67716dd9..96fdac77 100644 --- a/partiql/tests/comparisons.rs +++ b/partiql/tests/comparisons.rs @@ -59,6 +59,7 @@ pub fn eval_op(op: &str) { fn op_values() -> [Value; 4] { [ Value::Integer(1), + #[allow(clippy::approx_constant)] Value::Real(3.14.into()), Value::Boolean(true), Value::String("foo".to_string().into()), diff --git a/partiql/tests/pretty.rs b/partiql/tests/pretty.rs index 86d30e3a..6b2d58c0 100644 --- a/partiql/tests/pretty.rs +++ b/partiql/tests/pretty.rs @@ -129,6 +129,8 @@ fn pretty_val() { tuple!(("n", 9)), tuple!(("n", 10)) ); + + #[allow(clippy::approx_constant)] let t_val = tuple!( ("foo", true), ("-foo", false),