From 13836d15c2f86c1e0a7d949645eb0c16d8b9c295 Mon Sep 17 00:00:00 2001 From: Josh Pschorr Date: Thu, 5 Dec 2024 10:55:04 -0800 Subject: [PATCH] Fix build & advisory issues. (#521) * Update deny license versions, nightly toolchain * Replace usages of `derivative` with `educe`. * clippy & fmt --- .github/workflows/ci_build_test.yml | 4 +-- about.toml | 3 +- deny.toml | 2 +- extension/partiql-extension-ion/src/decode.rs | 2 +- partiql-ast-passes/src/name_resolver.rs | 2 +- partiql-eval/src/env.rs | 2 +- partiql-eval/src/eval/evaluable.rs | 12 ++++---- partiql-eval/src/eval/expr/path.rs | 4 +-- partiql-eval/src/eval/mod.rs | 6 ++-- partiql-logical-planner/src/functions.rs | 4 +-- partiql-logical-planner/src/lower.rs | 2 +- partiql-parser/src/lexer/comment.rs | 2 +- partiql-parser/src/lexer/embedded_ion.rs | 2 +- partiql-parser/src/lexer/partiql.rs | 6 ++-- partiql-parser/src/parse/parser_state.rs | 6 ++-- partiql-types/Cargo.toml | 2 +- partiql-types/src/lib.rs | 28 +++++++++---------- partiql-value/src/bag.rs | 2 +- partiql-value/src/lib.rs | 4 +-- partiql-value/src/list.rs | 2 +- partiql-value/src/pretty.rs | 2 +- partiql-value/src/tuple.rs | 2 +- partiql/tests/user_context.rs | 2 +- 23 files changed, 52 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci_build_test.yml b/.github/workflows/ci_build_test.yml index 0f91b3d7..ba727a4a 100644 --- a/.github/workflows/ci_build_test.yml +++ b/.github/workflows/ci_build_test.yml @@ -92,7 +92,7 @@ jobs: - name: Rust Toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-08-06 + toolchain: nightly-2024-10-17 - uses: actions/cache@v3 id: restore-build with: @@ -132,7 +132,7 @@ jobs: - name: Rust Toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-08-06 + toolchain: nightly-2024-10-17 - uses: actions/cache@v3 id: restore-build-and-conformance with: diff --git a/about.toml b/about.toml index 1a2ced1f..668fdc1d 100644 --- a/about.toml +++ b/about.toml @@ -21,5 +21,6 @@ accepted = [ "ISC", "Zlib", "ICU", - "Unicode-DFS-2016" + "Unicode-DFS-2016", + "Unicode-3.0" ] \ No newline at end of file diff --git a/deny.toml b/deny.toml index a9e2fa8e..93305089 100644 --- a/deny.toml +++ b/deny.toml @@ -48,7 +48,7 @@ allow = [ # If you change this list, please also change `about.toml` # see https://github.com/EmbarkStudios/cargo-about/issues/201 exceptions = [ - { allow = ["Unicode-DFS-2016"], name = "unicode-ident" }, + { allow = ["Unicode-DFS-2016", "Unicode-3.0"], name = "unicode-ident" }, ] # The confidence threshold for detecting a license from license text. diff --git a/extension/partiql-extension-ion/src/decode.rs b/extension/partiql-extension-ion/src/decode.rs index 9a2607a1..6b63f814 100644 --- a/extension/partiql-extension-ion/src/decode.rs +++ b/extension/partiql-extension-ion/src/decode.rs @@ -122,7 +122,7 @@ pub struct IonValueIter<'a> { inner: Box + 'a>, } -impl<'a> Iterator for IonValueIter<'a> { +impl Iterator for IonValueIter<'_> { type Item = IonDecodeResult; #[inline] diff --git a/partiql-ast-passes/src/name_resolver.rs b/partiql-ast-passes/src/name_resolver.rs index e08899ca..fba653a4 100644 --- a/partiql-ast-passes/src/name_resolver.rs +++ b/partiql-ast-passes/src/name_resolver.rs @@ -212,7 +212,7 @@ impl<'c> NameResolver<'c> { } } -impl<'ast, 'c> Visitor<'ast> for NameResolver<'c> { +impl<'ast> Visitor<'ast> for NameResolver<'_> { fn enter_ast_node(&mut self, id: NodeId) -> Traverse { self.id_path_to_root.push(id); if let Some(children) = self.id_child_stack.last_mut() { diff --git a/partiql-eval/src/env.rs b/partiql-eval/src/env.rs index c0680fae..2d7122c9 100644 --- a/partiql-eval/src/env.rs +++ b/partiql-eval/src/env.rs @@ -115,7 +115,7 @@ pub mod basic { } } - impl<'a, T> Bindings for NestedBindings<'a, T> + impl Bindings for NestedBindings<'_, T> where T: Debug, { diff --git a/partiql-eval/src/eval/evaluable.rs b/partiql-eval/src/eval/evaluable.rs index bb2d41bd..e49cae59 100644 --- a/partiql-eval/src/eval/evaluable.rs +++ b/partiql-eval/src/eval/evaluable.rs @@ -494,7 +494,7 @@ impl AggregateFunction for Max { } fn finalize(&self, state: Option) -> Result { - Ok(state.unwrap_or_else(|| Null)) + Ok(state.unwrap_or(Null)) } } @@ -515,7 +515,7 @@ impl AggregateFunction for Min { } fn finalize(&self, state: Option) -> Result { - Ok(state.unwrap_or_else(|| Null)) + Ok(state.unwrap_or(Null)) } } @@ -532,7 +532,7 @@ impl AggregateFunction for Sum { } fn finalize(&self, state: Option) -> Result { - Ok(state.unwrap_or_else(|| Null)) + Ok(state.unwrap_or(Null)) } } @@ -559,7 +559,7 @@ impl AggregateFunction for Any { } fn finalize(&self, state: Option) -> Result { - Ok(state.unwrap_or_else(|| Null)) + Ok(state.unwrap_or(Null)) } } @@ -586,7 +586,7 @@ impl AggregateFunction for Every { } fn finalize(&self, state: Option) -> Result { - Ok(state.unwrap_or_else(|| Null)) + Ok(state.unwrap_or(Null)) } } @@ -1278,7 +1278,7 @@ pub(crate) struct EvalSink { impl Evaluable for EvalSink { fn evaluate<'a, 'c>(&mut self, _ctx: &'c dyn EvalContext<'c>) -> Value { - self.input.take().unwrap_or_else(|| Missing) + self.input.take().unwrap_or(Missing) } fn update_input(&mut self, input: Value, _branch_num: u8, _ctx: &dyn EvalContext<'_>) { diff --git a/partiql-eval/src/eval/expr/path.rs b/partiql-eval/src/eval/expr/path.rs index 8e499cb1..cbfdc247 100644 --- a/partiql-eval/src/eval/expr/path.rs +++ b/partiql-eval/src/eval/expr/path.rs @@ -138,7 +138,7 @@ impl EvalExpr for EvalPath { .try_fold(owned, |v, path| path.take_val(v, bindings, ctx)) .map(Cow::Owned), } - .unwrap_or_else(|| Cow::Owned(Value::Missing)) + .unwrap_or(Cow::Owned(Value::Missing)) } } @@ -165,7 +165,7 @@ impl EvalExpr for EvalDynamicLookup { } }); - lookups.next().unwrap_or_else(|| Cow::Owned(Value::Missing)) + lookups.next().unwrap_or(Cow::Owned(Value::Missing)) } } diff --git a/partiql-eval/src/eval/mod.rs b/partiql-eval/src/eval/mod.rs index 5cfe7dce..77a67a57 100644 --- a/partiql-eval/src/eval/mod.rs +++ b/partiql-eval/src/eval/mod.rs @@ -170,7 +170,7 @@ pub struct BasicContext<'a> { pub errors: RefCell>, } -impl<'a> BasicContext<'a> { +impl BasicContext<'_> { #[must_use] pub fn new(bindings: MapBindings, sys: SystemContext) -> Self { BasicContext { @@ -228,7 +228,7 @@ impl<'a, 'c> NestedContext<'a, 'c> { } } -impl<'a, 'c> SessionContext<'a> for NestedContext<'a, 'c> { +impl<'a> SessionContext<'a> for NestedContext<'a, '_> { fn bindings(&self) -> &dyn Bindings { &self.bindings } @@ -241,7 +241,7 @@ impl<'a, 'c> SessionContext<'a> for NestedContext<'a, 'c> { } } -impl<'a, 'c> EvalContext<'a> for NestedContext<'a, 'c> { +impl<'a> EvalContext<'a> for NestedContext<'a, '_> { fn as_session(&'a self) -> &'a dyn SessionContext<'a> { self } diff --git a/partiql-logical-planner/src/functions.rs b/partiql-logical-planner/src/functions.rs index 1ab6705a..27b230fe 100644 --- a/partiql-logical-planner/src/functions.rs +++ b/partiql-logical-planner/src/functions.rs @@ -8,7 +8,7 @@ pub(crate) trait Function { fn resolve(&self, name: &str, args: &[CallArgument]) -> Result; } -impl<'a> Function for FunctionEntry<'a> { +impl Function for FunctionEntry<'_> { fn resolve(&self, name: &str, args: &[CallArgument]) -> Result { let oid = self.id(); match self.entry() { @@ -30,7 +30,7 @@ struct ScalarFnResolver<'a> { pub scfn: &'a ScalarFnCallSpecs, } -impl<'a> Function for ScalarFnResolver<'a> { +impl Function for ScalarFnResolver<'_> { fn resolve(&self, name: &str, args: &[CallArgument]) -> Result { let oid = self.oid; let overloads = self.scfn; diff --git a/partiql-logical-planner/src/lower.rs b/partiql-logical-planner/src/lower.rs index 912f1199..1860027b 100644 --- a/partiql-logical-planner/src/lower.rs +++ b/partiql-logical-planner/src/lower.rs @@ -609,7 +609,7 @@ impl<'a> AstToLogical<'a> { // so there is nothing done between the `enter_` and `exit_` calls. // By convention, processing for them is done in the `enter_` calls here. // -impl<'a, 'ast> Visitor<'ast> for AstToLogical<'a> { +impl<'ast> Visitor<'ast> for AstToLogical<'_> { fn enter_ast_node(&mut self, id: NodeId) -> Traverse { self.id_stack.push(id); Traverse::Continue diff --git a/partiql-parser/src/lexer/comment.rs b/partiql-parser/src/lexer/comment.rs index 782847e4..eff8bb44 100644 --- a/partiql-parser/src/lexer/comment.rs +++ b/partiql-parser/src/lexer/comment.rs @@ -122,7 +122,7 @@ impl<'input, 'tracker> CommentLexer<'input, 'tracker> { } } -impl<'input, 'tracker> Iterator for CommentLexer<'input, 'tracker> { +impl<'input> Iterator for CommentLexer<'input, '_> { type Item = CommentStringResult<'input>; #[inline(always)] diff --git a/partiql-parser/src/lexer/embedded_ion.rs b/partiql-parser/src/lexer/embedded_ion.rs index 66370052..f98359df 100644 --- a/partiql-parser/src/lexer/embedded_ion.rs +++ b/partiql-parser/src/lexer/embedded_ion.rs @@ -125,7 +125,7 @@ impl<'input, 'tracker> EmbeddedIonLexer<'input, 'tracker> { } } -impl<'input, 'tracker> Iterator for EmbeddedIonLexer<'input, 'tracker> { +impl<'input> Iterator for EmbeddedIonLexer<'input, '_> { type Item = EmbeddedIonStringResult<'input>; #[inline(always)] diff --git a/partiql-parser/src/lexer/partiql.rs b/partiql-parser/src/lexer/partiql.rs index da153e4a..c6b5c9f9 100644 --- a/partiql-parser/src/lexer/partiql.rs +++ b/partiql-parser/src/lexer/partiql.rs @@ -115,7 +115,7 @@ impl<'input, 'tracker> PartiqlLexer<'input, 'tracker> { } } -impl<'input, 'tracker> Iterator for PartiqlLexer<'input, 'tracker> { +impl<'input> Iterator for PartiqlLexer<'input, '_> { type Item = LexResult<'input>; #[inline(always)] @@ -382,7 +382,7 @@ pub enum Token<'input> { Zone, } -impl<'input> Token<'input> { +impl Token<'_> { pub fn is_keyword(&self) -> bool { matches!( self, @@ -449,7 +449,7 @@ impl<'input> Token<'input> { } } -impl<'input> fmt::Display for Token<'input> { +impl fmt::Display for Token<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Token::Newline => write!(f, "\\n"), diff --git a/partiql-parser/src/parse/parser_state.rs b/partiql-parser/src/parse/parser_state.rs index 7d37111c..a116b79a 100644 --- a/partiql-parser/src/parse/parser_state.rs +++ b/partiql-parser/src/parse/parser_state.rs @@ -32,7 +32,7 @@ pub(crate) struct ParserState<'input, Id: NodeIdGenerator> { aggregates_pat: &'static Regex, } -impl<'input> Default for ParserState<'input, AutoNodeIdGenerator> { +impl Default for ParserState<'_, AutoNodeIdGenerator> { fn default() -> Self { ParserState::with_id_gen(AutoNodeIdGenerator::default()) } @@ -44,7 +44,7 @@ const KNOWN_AGGREGATES: &str = "(?i:^count$)|(?i:^avg$)|(?i:^min$)|(?i:^max$)|(?i:^sum$)|(?i:^any$)|(?i:^some$)|(?i:^every$)"; static KNOWN_AGGREGATE_PATTERN: Lazy = Lazy::new(|| Regex::new(KNOWN_AGGREGATES).unwrap()); -impl<'input, I> ParserState<'input, I> +impl ParserState<'_, I> where I: NodeIdGenerator, { @@ -58,7 +58,7 @@ where } } -impl<'input, IdGen: NodeIdGenerator> ParserState<'input, IdGen> { +impl ParserState<'_, IdGen> { /// Create a new [`AstNode`] from the inner data which it is to hold and a source location. pub fn create_node(&mut self, node: T, location: IntoLoc) -> AstNode where diff --git a/partiql-types/Cargo.toml b/partiql-types/Cargo.toml index 72ed1144..c672bfc6 100644 --- a/partiql-types/Cargo.toml +++ b/partiql-types/Cargo.toml @@ -29,6 +29,6 @@ thiserror = "1" indexmap = "2.5" -derivative = "2.2" +educe = "0.6" [dev-dependencies] diff --git a/partiql-types/src/lib.rs b/partiql-types/src/lib.rs index 8437611d..fdd63008 100644 --- a/partiql-types/src/lib.rs +++ b/partiql-types/src/lib.rs @@ -1,7 +1,7 @@ #![deny(rust_2018_idioms)] #![deny(clippy::all)] -use derivative::Derivative; +use educe::Educe; use indexmap::IndexSet; use itertools::Itertools; use miette::Diagnostic; @@ -584,11 +584,11 @@ impl PartiqlShapeBuilder { } } -#[derive(Derivative, Eq, Debug, Clone)] -#[derivative(PartialEq, Hash)] +#[derive(Educe, Eq, Debug, Clone)] +#[educe(PartialEq, Hash)] #[allow(dead_code)] pub struct AnyOf { - #[derivative(Hash(hash_with = "indexset_hash"))] + #[educe(Hash(method(indexset_hash)))] types: IndexSet, } @@ -743,11 +743,11 @@ impl Display for Static { pub const TYPE_DYNAMIC: PartiqlShape = PartiqlShape::Dynamic; -#[derive(Derivative, Eq, Debug, Clone)] -#[derivative(PartialEq, Hash)] +#[derive(Educe, Eq, Debug, Clone)] +#[educe(PartialEq, Hash)] #[allow(dead_code)] pub struct StructType { - #[derivative(Hash(hash_with = "indexset_hash"))] + #[educe(Hash(method(indexset_hash)))] constraints: IndexSet, } @@ -827,15 +827,15 @@ impl Display for StructType { } } -#[derive(Derivative, Eq, Debug, Clone)] -#[derivative(PartialEq, Hash)] +#[derive(Educe, Eq, Debug, Clone)] +#[educe(PartialEq, Hash)] #[allow(dead_code)] #[non_exhaustive] pub enum StructConstraint { Open(bool), Ordered(bool), DuplicateAttrs(bool), - Fields(#[derivative(Hash(hash_with = "indexset_hash"))] IndexSet), + Fields(#[educe(Hash(method(indexset_hash)))] IndexSet), } #[derive(Debug, Clone, Hash, Eq, PartialEq)] @@ -901,8 +901,8 @@ impl From<(&str, PartiqlShape, bool)> for StructField { } } -#[derive(Derivative, Eq, Debug, Clone)] -#[derivative(PartialEq, Hash)] +#[derive(Educe, Eq, Debug, Clone)] +#[educe(PartialEq, Hash)] #[allow(dead_code)] pub struct BagType { element_type: Box, @@ -938,8 +938,8 @@ impl Display for BagType { } } -#[derive(Derivative, Eq, Debug, Clone)] -#[derivative(PartialEq, Hash)] +#[derive(Educe, Eq, Debug, Clone)] +#[educe(PartialEq, Hash)] #[allow(dead_code)] pub struct ArrayType { element_type: Box, diff --git a/partiql-value/src/bag.rs b/partiql-value/src/bag.rs index f2ffbcae..a846aa85 100644 --- a/partiql-value/src/bag.rs +++ b/partiql-value/src/bag.rs @@ -196,7 +196,7 @@ impl PartialOrd for Bag { } } -impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, Bag> { +impl Ord for NullSortedValue<'_, NULLS_FIRST, Bag> { fn cmp(&self, other: &Self) -> Ordering { let wrap = NullSortedValue::<{ NULLS_FIRST }, List>; diff --git a/partiql-value/src/lib.rs b/partiql-value/src/lib.rs index 938769c9..561c6d07 100644 --- a/partiql-value/src/lib.rs +++ b/partiql-value/src/lib.rs @@ -419,7 +419,7 @@ pub trait NullableOrd { #[derive(Eq, PartialEq)] pub struct EqualityValue<'a, const NULLS_EQUAL: bool, T>(pub &'a T); -impl<'a, const GROUP_NULLS: bool> NullableEq for EqualityValue<'a, GROUP_NULLS, Value> { +impl NullableEq for EqualityValue<'_, GROUP_NULLS, Value> { type Output = Value; fn eq(&self, rhs: &Self) -> Self::Output { @@ -905,7 +905,7 @@ where } } -impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, Value> { +impl Ord for NullSortedValue<'_, NULLS_FIRST, Value> { fn cmp(&self, other: &Self) -> Ordering { let wrap_list = NullSortedValue::<{ NULLS_FIRST }, List>; let wrap_tuple = NullSortedValue::<{ NULLS_FIRST }, Tuple>; diff --git a/partiql-value/src/list.rs b/partiql-value/src/list.rs index 249e19de..a7d66de9 100644 --- a/partiql-value/src/list.rs +++ b/partiql-value/src/list.rs @@ -193,7 +193,7 @@ impl PartialOrd for List { } } -impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, List> { +impl Ord for NullSortedValue<'_, NULLS_FIRST, List> { fn cmp(&self, other: &Self) -> Ordering { let wrap = NullSortedValue::<{ NULLS_FIRST }, _>; diff --git a/partiql-value/src/pretty.rs b/partiql-value/src/pretty.rs index 5767ca95..bf608ff5 100644 --- a/partiql-value/src/pretty.rs +++ b/partiql-value/src/pretty.rs @@ -101,7 +101,7 @@ impl PrettyDoc for Tuple { pub struct StructValuePair<'a>((&'a String, &'a Value)); -impl<'a> PrettyDoc for StructValuePair<'a> { +impl PrettyDoc for StructValuePair<'_> { fn pretty_doc<'b, D, A>(&'b self, arena: &'b D) -> DocBuilder<'b, D, A> where D: DocAllocator<'b, A>, diff --git a/partiql-value/src/tuple.rs b/partiql-value/src/tuple.rs index ef038cda..2c7edf9a 100644 --- a/partiql-value/src/tuple.rs +++ b/partiql-value/src/tuple.rs @@ -267,7 +267,7 @@ impl Debug for Tuple { } } -impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, Tuple> { +impl Ord for NullSortedValue<'_, NULLS_FIRST, Tuple> { fn cmp(&self, other: &Self) -> Ordering { let wrap = NullSortedValue::<{ NULLS_FIRST }, Value>; diff --git a/partiql/tests/user_context.rs b/partiql/tests/user_context.rs index 6a87dffa..6d99e6ec 100644 --- a/partiql/tests/user_context.rs +++ b/partiql/tests/user_context.rs @@ -110,7 +110,7 @@ struct TestDataGen<'a> { name: String, } -impl<'a> Iterator for TestDataGen<'a> { +impl Iterator for TestDataGen<'_> { type Item = Result; fn next(&mut self) -> Option {