Skip to content

Commit

Permalink
Fix build & advisory issues. (#521)
Browse files Browse the repository at this point in the history
* Update deny license versions, nightly toolchain
* Replace usages of `derivative` with `educe`.
* clippy & fmt
  • Loading branch information
jpschorr authored Dec 5, 2024
1 parent a7993de commit 13836d1
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion about.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ accepted = [
"ISC",
"Zlib",
"ICU",
"Unicode-DFS-2016"
"Unicode-DFS-2016",
"Unicode-3.0"
]
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion extension/partiql-extension-ion/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub struct IonValueIter<'a> {
inner: Box<dyn Iterator<Item = IonDecodeResult> + 'a>,
}

impl<'a> Iterator for IonValueIter<'a> {
impl Iterator for IonValueIter<'_> {
type Item = IonDecodeResult;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion partiql-ast-passes/src/name_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion partiql-eval/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub mod basic {
}
}

impl<'a, T> Bindings<T> for NestedBindings<'a, T>
impl<T> Bindings<T> for NestedBindings<'_, T>
where
T: Debug,
{
Expand Down
12 changes: 6 additions & 6 deletions partiql-eval/src/eval/evaluable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ impl AggregateFunction for Max {
}

fn finalize(&self, state: Option<Value>) -> Result<Value, EvaluationError> {
Ok(state.unwrap_or_else(|| Null))
Ok(state.unwrap_or(Null))
}
}

Expand All @@ -515,7 +515,7 @@ impl AggregateFunction for Min {
}

fn finalize(&self, state: Option<Value>) -> Result<Value, EvaluationError> {
Ok(state.unwrap_or_else(|| Null))
Ok(state.unwrap_or(Null))
}
}

Expand All @@ -532,7 +532,7 @@ impl AggregateFunction for Sum {
}

fn finalize(&self, state: Option<Value>) -> Result<Value, EvaluationError> {
Ok(state.unwrap_or_else(|| Null))
Ok(state.unwrap_or(Null))
}
}

Expand All @@ -559,7 +559,7 @@ impl AggregateFunction for Any {
}

fn finalize(&self, state: Option<Value>) -> Result<Value, EvaluationError> {
Ok(state.unwrap_or_else(|| Null))
Ok(state.unwrap_or(Null))
}
}

Expand All @@ -586,7 +586,7 @@ impl AggregateFunction for Every {
}

fn finalize(&self, state: Option<Value>) -> Result<Value, EvaluationError> {
Ok(state.unwrap_or_else(|| Null))
Ok(state.unwrap_or(Null))
}
}

Expand Down Expand Up @@ -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<'_>) {
Expand Down
4 changes: 2 additions & 2 deletions partiql-eval/src/eval/expr/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -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))
}
}

Expand Down
6 changes: 3 additions & 3 deletions partiql-eval/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub struct BasicContext<'a> {
pub errors: RefCell<Vec<EvaluationError>>,
}

impl<'a> BasicContext<'a> {
impl BasicContext<'_> {
#[must_use]
pub fn new(bindings: MapBindings<Value>, sys: SystemContext) -> Self {
BasicContext {
Expand Down Expand Up @@ -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<Value> {
&self.bindings
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions partiql-logical-planner/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) trait Function {
fn resolve(&self, name: &str, args: &[CallArgument]) -> Result<ValueExpr, CallLookupError>;
}

impl<'a> Function for FunctionEntry<'a> {
impl Function for FunctionEntry<'_> {
fn resolve(&self, name: &str, args: &[CallArgument]) -> Result<ValueExpr, CallLookupError> {
let oid = self.id();
match self.entry() {
Expand All @@ -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<ValueExpr, CallLookupError> {
let oid = self.oid;
let overloads = self.scfn;
Expand Down
2 changes: 1 addition & 1 deletion partiql-logical-planner/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ impl<'a> AstToLogical<'a> {
// so there is nothing done between the `enter_<x>` and `exit_<x>` calls.
// By convention, processing for them is done in the `enter_<x>` 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
Expand Down
2 changes: 1 addition & 1 deletion partiql-parser/src/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion partiql-parser/src/lexer/embedded_ion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions partiql-parser/src/lexer/partiql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -382,7 +382,7 @@ pub enum Token<'input> {
Zone,
}

impl<'input> Token<'input> {
impl Token<'_> {
pub fn is_keyword(&self) -> bool {
matches!(
self,
Expand Down Expand Up @@ -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"),
Expand Down
6 changes: 3 additions & 3 deletions partiql-parser/src/parse/parser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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<Regex> = Lazy::new(|| Regex::new(KNOWN_AGGREGATES).unwrap());

impl<'input, I> ParserState<'input, I>
impl<I> ParserState<'_, I>
where
I: NodeIdGenerator,
{
Expand All @@ -58,7 +58,7 @@ where
}
}

impl<'input, IdGen: NodeIdGenerator> ParserState<'input, IdGen> {
impl<IdGen: NodeIdGenerator> ParserState<'_, IdGen> {
/// Create a new [`AstNode`] from the inner data which it is to hold and a source location.
pub fn create_node<T, IntoLoc>(&mut self, node: T, location: IntoLoc) -> AstNode<T>
where
Expand Down
2 changes: 1 addition & 1 deletion partiql-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ thiserror = "1"

indexmap = "2.5"

derivative = "2.2"
educe = "0.6"

[dev-dependencies]
28 changes: 14 additions & 14 deletions partiql-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<PartiqlShape>,
}

Expand Down Expand Up @@ -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<StructConstraint>,
}

Expand Down Expand Up @@ -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<StructField>),
Fields(#[educe(Hash(method(indexset_hash)))] IndexSet<StructField>),
}

#[derive(Debug, Clone, Hash, Eq, PartialEq)]
Expand Down Expand Up @@ -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<PartiqlShape>,
Expand Down Expand Up @@ -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<PartiqlShape>,
Expand Down
2 changes: 1 addition & 1 deletion partiql-value/src/bag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl PartialOrd for Bag {
}
}

impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, Bag> {
impl<const NULLS_FIRST: bool> Ord for NullSortedValue<'_, NULLS_FIRST, Bag> {
fn cmp(&self, other: &Self) -> Ordering {
let wrap = NullSortedValue::<{ NULLS_FIRST }, List>;

Expand Down
4 changes: 2 additions & 2 deletions partiql-value/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const GROUP_NULLS: bool> NullableEq for EqualityValue<'_, GROUP_NULLS, Value> {
type Output = Value;

fn eq(&self, rhs: &Self) -> Self::Output {
Expand Down Expand Up @@ -905,7 +905,7 @@ where
}
}

impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, Value> {
impl<const NULLS_FIRST: bool> 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>;
Expand Down
2 changes: 1 addition & 1 deletion partiql-value/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl PartialOrd for List {
}
}

impl<'a, const NULLS_FIRST: bool> Ord for NullSortedValue<'a, NULLS_FIRST, List> {
impl<const NULLS_FIRST: bool> Ord for NullSortedValue<'_, NULLS_FIRST, List> {
fn cmp(&self, other: &Self) -> Ordering {
let wrap = NullSortedValue::<{ NULLS_FIRST }, _>;

Expand Down
2 changes: 1 addition & 1 deletion partiql-value/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
Loading

1 comment on commit 13836d1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PartiQL (rust) Benchmark

Benchmark suite Current: 13836d1 Previous: a7993de Ratio
arith_agg-avg 779362 ns/iter (± 4869) 778876 ns/iter (± 6563) 1.00
arith_agg-avg_distinct 868514 ns/iter (± 20412) 865101 ns/iter (± 10684) 1.00
arith_agg-count 827765 ns/iter (± 52033) 832969 ns/iter (± 21135) 0.99
arith_agg-count_distinct 859464 ns/iter (± 3769) 865241 ns/iter (± 3034) 0.99
arith_agg-min 831144 ns/iter (± 24332) 830045 ns/iter (± 2296) 1.00
arith_agg-min_distinct 865575 ns/iter (± 160042) 866901 ns/iter (± 1679) 1.00
arith_agg-max 835732 ns/iter (± 1378) 836447 ns/iter (± 4347) 1.00
arith_agg-max_distinct 872876 ns/iter (± 1396) 875477 ns/iter (± 2571) 1.00
arith_agg-sum 831858 ns/iter (± 1660) 837285 ns/iter (± 1921) 0.99
arith_agg-sum_distinct 866734 ns/iter (± 5909) 874275 ns/iter (± 5198) 0.99
arith_agg-avg-count-min-max-sum 988615 ns/iter (± 10610) 978145 ns/iter (± 19364) 1.01
arith_agg-avg-count-min-max-sum-group_by 1244835 ns/iter (± 12282) 1224127 ns/iter (± 8025) 1.02
arith_agg-avg-count-min-max-sum-group_by-group_as 1855176 ns/iter (± 7861) 1852330 ns/iter (± 7671) 1.00
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct 1220105 ns/iter (± 8355) 1261519 ns/iter (± 21633) 0.97
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by 1507054 ns/iter (± 43127) 1532962 ns/iter (± 39963) 0.98
arith_agg-avg_distinct-count_distinct-min_distinct-max_distinct-sum_distinct-group_by-group_as 2102096 ns/iter (± 17003) 2127338 ns/iter (± 13304) 0.99
parse-1 5954 ns/iter (± 205) 6213 ns/iter (± 18) 0.96
parse-15 49279 ns/iter (± 1112) 50489 ns/iter (± 358) 0.98
parse-30 96811 ns/iter (± 951) 98652 ns/iter (± 498) 0.98
compile-1 4313 ns/iter (± 18) 4247 ns/iter (± 15) 1.02
compile-15 31572 ns/iter (± 260) 32835 ns/iter (± 1533) 0.96
compile-30 64409 ns/iter (± 191) 67473 ns/iter (± 227) 0.95
plan-1 70716 ns/iter (± 1698) 70366 ns/iter (± 371) 1.00
plan-15 1102453 ns/iter (± 36687) 1091990 ns/iter (± 47002) 1.01
plan-30 2142597 ns/iter (± 46164) 2193890 ns/iter (± 10482) 0.98
eval-1 12147533 ns/iter (± 87548) 12862783 ns/iter (± 81581) 0.94
eval-15 76679910 ns/iter (± 3978698) 88439210 ns/iter (± 934873) 0.87
eval-30 146225132 ns/iter (± 1141375) 169215402 ns/iter (± 486929) 0.86
join 10119 ns/iter (± 269) 10009 ns/iter (± 274) 1.01
simple 2541 ns/iter (± 47) 2500 ns/iter (± 28) 1.02
simple-no 477 ns/iter (± 6) 457 ns/iter (± 2) 1.04
numbers 57 ns/iter (± 0) 57 ns/iter (± 0) 1
parse-simple 951 ns/iter (± 3) 858 ns/iter (± 29) 1.11
parse-ion 2765 ns/iter (± 7) 2563 ns/iter (± 11) 1.08
parse-group 8026 ns/iter (± 55) 7927 ns/iter (± 43) 1.01
parse-complex 20927 ns/iter (± 93) 20694 ns/iter (± 97) 1.01
parse-complex-fexpr 28651 ns/iter (± 137) 28148 ns/iter (± 109) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.