Skip to content

bump to Rust 2024 edition #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
# `Cargo.lock` version 4 requires 1.78.0
# datafusion 45.0.0 requires 1.81.0
msrv: ["1.81.0"]
# Rust 2024 Edition MSRV
msrv: ["1.85.0"]
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ resolver = "2"

[workspace.package]
version = "0.1.0"
edition = "2021"
rust-version = "1.81.0"
edition = "2024"
repository = "https://github.com/cmu-db/optd"

[workspace.dependencies]
Expand Down
1 change: 0 additions & 1 deletion optd-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "optd-core"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions optd-core/src/bridge/from_cir.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Converts optd's type representations (CIR) into DSL [`Value`]s (HIR).

use crate::cir::*;
use CoreData::*;
use Literal::*;
use Materializable::*;
use optd_dsl::analyzer::hir::{
self, CoreData, Literal, LogicalOp, Materializable, Operator, PhysicalOp, Value,
};
use std::sync::Arc;
use CoreData::*;
use Literal::*;
use Materializable::*;

/// Converts a [`PartialLogicalPlan`] into a [`Value`].
pub(crate) fn partial_logical_to_value(plan: &PartialLogicalPlan) -> Value {
Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/bridge/into_cir.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Converts HIR [`Value`]s into optd's type representations (CIR).

use crate::cir::*;
use optd_dsl::analyzer::hir::{self, CoreData, Literal, Materializable, Value};
use std::sync::Arc;
use Child::*;
use CoreData::*;
use Literal::*;
use Materializable::*;
use optd_dsl::analyzer::hir::{self, CoreData, Literal, Materializable, Value};
use std::sync::Arc;

/// Converts a [`Value`] into a [`PartialLogicalPlan`].
///
Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/engine/eval/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ pub(super) fn eval_binary_op(left: Value, op: &BinOp, right: Value) -> Value {

#[cfg(test)]
mod tests {
use optd_dsl::analyzer::hir::{BinOp, CoreData, Literal, Value};
use std::collections::HashMap;
use BinOp::*;
use CoreData::*;
use Literal::*;
use optd_dsl::analyzer::hir::{BinOp, CoreData, Literal, Value};
use std::collections::HashMap;

use super::eval_binary_op;

Expand Down
8 changes: 4 additions & 4 deletions optd-core/src/engine/eval/core.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{
operator::{evaluate_logical_operator, evaluate_physical_operator},
Engine, Evaluate, Generator,
operator::{evaluate_logical_operator, evaluate_physical_operator},
};
use crate::capture;
use crate::engine::utils::evaluate_sequence;
use crate::engine::Continuation;
use crate::engine::utils::evaluate_sequence;
use CoreData::*;
use optd_dsl::analyzer::hir::{CoreData, Expr, Value};
use std::sync::Arc;
use CoreData::*;

/// Evaluates a core expression by generating all possible evaluation paths.
///
Expand Down Expand Up @@ -160,8 +160,8 @@ where
#[cfg(test)]
mod tests {
use crate::engine::{
test_utils::{evaluate_and_collect, int, lit_expr, string, MockGenerator},
Engine,
test_utils::{MockGenerator, evaluate_and_collect, int, lit_expr, string},
};
use optd_dsl::analyzer::{
context::Context,
Expand Down
14 changes: 7 additions & 7 deletions optd-core/src/engine/eval/expr.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use super::{binary::eval_binary_op, unary::eval_unary_op, Evaluate};
use super::{Evaluate, binary::eval_binary_op, unary::eval_unary_op};
use crate::{
capture,
engine::{utils::evaluate_sequence, Continuation, Engine, Generator},
engine::{Continuation, Engine, Generator, utils::evaluate_sequence},
};
use CoreData::*;
use FunKind::*;
use optd_dsl::analyzer::hir::{
BinOp, CoreData, Expr, FunKind, Identifier, Literal, UnaryOp, Value,
};
use std::sync::Arc;
use CoreData::*;
use FunKind::*;

/// Evaluates an if-then-else expression.
///
Expand Down Expand Up @@ -325,11 +325,11 @@ where
#[cfg(test)]
mod tests {
use crate::engine::{
Engine,
test_utils::{
array_val, boolean, evaluate_and_collect, int, lit_expr, lit_val, ref_expr, string,
MockGenerator,
MockGenerator, array_val, boolean, evaluate_and_collect, int, lit_expr, lit_val,
ref_expr, string,
},
Engine,
};
use optd_dsl::analyzer::{
context::Context,
Expand Down
50 changes: 28 additions & 22 deletions optd-core/src/engine/eval/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use crate::{
capture,
engine::{Continuation, UnitFuture},
};
use Materializable::*;
use Pattern::*;
use optd_dsl::analyzer::{
context::Context,
hir::{
CoreData, Expr, LogicalOp, MatchArm, Materializable, Operator, Pattern, PhysicalOp, Value,
},
};
use std::sync::Arc;
use Materializable::*;
use Pattern::*;

/// A type representing a match result, which is a value and an optional context.
///
Expand Down Expand Up @@ -133,7 +133,7 @@ fn match_pattern<G>(
value: Value,
pattern: Pattern,
ctx: Context,
gen: G,
r#gen: G,
k: MatchContinuation,
) -> UnitFuture
where
Expand All @@ -154,23 +154,23 @@ where
}
// Complex patterns.
(Bind(ident, inner_pattern), _) => {
match_bind_pattern(value.clone(), ident, *inner_pattern, ctx, gen, k).await;
match_bind_pattern(value.clone(), ident, *inner_pattern, ctx, r#gen, k).await;
}
(ArrayDecomp(head_pat, tail_pat), CoreData::Array(arr)) => {
if arr.is_empty() {
k((value, None)).await;
return;
}

match_array_pattern(*head_pat, *tail_pat, arr, ctx, gen, k).await;
match_array_pattern(*head_pat, *tail_pat, arr, ctx, r#gen, k).await;
}
(Struct(pat_name, pat_fields), CoreData::Struct(val_name, val_fields)) => {
if pat_name != *val_name || pat_fields.len() != val_fields.len() {
k((value, None)).await;
return;
}

match_struct_pattern(pat_name, pat_fields, val_fields, ctx, gen, k).await;
match_struct_pattern(pat_name, pat_fields, val_fields, ctx, r#gen, k).await;
}
(Operator(op_pattern), CoreData::Logical(LogicalOp(Materialized(operator)))) => {
if op_pattern.tag != operator.tag
Expand All @@ -181,7 +181,8 @@ where
return;
}

match_materialized_operator(true, op_pattern, operator.clone(), ctx, gen, k).await;
match_materialized_operator(true, op_pattern, operator.clone(), ctx, r#gen, k)
.await;
}
(Operator(op_pattern), CoreData::Physical(PhysicalOp(Materialized(operator)))) => {
if op_pattern.tag != operator.tag
Expand All @@ -192,29 +193,32 @@ where
return;
}

match_materialized_operator(false, op_pattern, operator.clone(), ctx, gen, k).await;
match_materialized_operator(false, op_pattern, operator.clone(), ctx, r#gen, k)
.await;
}
// Unmaterialized operators.
(Operator(op_pattern), CoreData::Logical(LogicalOp(UnMaterialized(group_id)))) => {
gen.clone()
r#gen
.clone()
.yield_group(
*group_id,
Arc::new(move |expanded_value| {
Box::pin(capture!([op_pattern, ctx, gen, k], async move {
match_pattern(expanded_value, Operator(op_pattern), ctx, gen, k)
Box::pin(capture!([op_pattern, ctx, r#gen, k], async move {
match_pattern(expanded_value, Operator(op_pattern), ctx, r#gen, k)
.await;
}))
}),
)
.await;
}
(Operator(op_pattern), CoreData::Physical(PhysicalOp(UnMaterialized(goal)))) => {
gen.clone()
r#gen
.clone()
.yield_goal(
goal,
Arc::new(move |expanded_value| {
Box::pin(capture!([op_pattern, ctx, gen, k], async move {
match_pattern(expanded_value, Operator(op_pattern), ctx, gen, k)
Box::pin(capture!([op_pattern, ctx, r#gen, k], async move {
match_pattern(expanded_value, Operator(op_pattern), ctx, r#gen, k)
.await;
}))
}),
Expand Down Expand Up @@ -385,7 +389,7 @@ async fn match_materialized_operator<G>(
op_pattern: Operator<Pattern>,
operator: Operator<Value>,
ctx: Context,
gen: G,
r#gen: G,
k: MatchContinuation,
) where
G: Generator,
Expand All @@ -410,7 +414,7 @@ async fn match_materialized_operator<G>(
all_patterns,
all_values,
ctx.clone(),
gen,
r#gen,
Arc::new(move |results| {
Box::pin(capture!([ctx, operator, k], async move {
// Check if all components matched successfully.
Expand Down Expand Up @@ -541,13 +545,13 @@ where
#[cfg(test)]
mod tests {
use crate::engine::{
Engine,
test_utils::{
array_decomp_pattern, array_val, bind_pattern, create_logical_operator,
MockGenerator, array_decomp_pattern, array_val, bind_pattern, create_logical_operator,
create_physical_operator, evaluate_and_collect, int, lit_expr, lit_val,
literal_pattern, match_arm, operator_pattern, pattern_match_expr, ref_expr, string,
struct_pattern, struct_val, wildcard_pattern, MockGenerator,
struct_pattern, struct_val, wildcard_pattern,
},
Engine,
};
use optd_dsl::analyzer::{
context::Context,
Expand Down Expand Up @@ -1499,9 +1503,11 @@ mod tests {
for result in &results {
match &result.0 {
CoreData::Literal(Literal::String(s)) => {
assert!(expected_combinations
.map(|(expected, _)| expected)
.contains(&s.as_str()));
assert!(
expected_combinations
.map(|(expected, _)| expected)
.contains(&s.as_str())
);
}
_ => panic!("Expected string literal"),
}
Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/engine/eval/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{Continuation, Engine, Generator, UnitFuture};
use Expr::*;
use core::evaluate_core_expr;
use expr::{
evaluate_binary_expr, evaluate_function_call, evaluate_if_then_else, evaluate_let_binding,
evaluate_reference, evaluate_unary_expr,
};
use optd_dsl::analyzer::hir::{Expr, Value};
use r#match::evaluate_pattern_match;
use optd_dsl::analyzer::hir::{Expr, Value};
use std::sync::Arc;
use Expr::*;

mod binary;
mod core;
Expand Down
12 changes: 6 additions & 6 deletions optd-core/src/engine/eval/operator.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use super::{Engine, Generator};
use crate::capture;
use crate::engine::utils::evaluate_sequence;
use crate::engine::Continuation;
use crate::engine::utils::evaluate_sequence;
use CoreData::{Logical, Physical};
use Materializable::*;
use optd_dsl::analyzer::hir::{
CoreData, Expr, LogicalOp, Materializable, Operator, PhysicalOp, Value,
};
use std::sync::Arc;
use CoreData::{Logical, Physical};
use Materializable::*;

/// Specialized continuation type for operator values
type OperatorContinuation = Continuation<Operator<Value>>;
Expand Down Expand Up @@ -142,11 +142,11 @@ async fn evaluate_operator<G>(
#[cfg(test)]
mod tests {
use crate::engine::{
Engine,
test_utils::{
create_logical_operator, evaluate_and_collect, int, lit_expr, lit_val, string,
MockGenerator,
MockGenerator, create_logical_operator, evaluate_and_collect, int, lit_expr, lit_val,
string,
},
Engine,
};
use optd_dsl::analyzer::{
context::Context,
Expand Down
2 changes: 1 addition & 1 deletion optd-core/src/engine/eval/unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
//! - Numeric negation for integers and floating-point numbers
//! - Logical NOT for boolean values

use optd_dsl::analyzer::hir::{CoreData, Literal, UnaryOp, Value};
use CoreData::*;
use Literal::*;
use UnaryOp::*;
use optd_dsl::analyzer::hir::{CoreData, Literal, UnaryOp, Value};

/// Evaluates a unary operation on a value.
///
Expand Down
2 changes: 1 addition & 1 deletion optd-core/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::{
cir::{Cost, LogicalProperties, PartialLogicalPlan, PartialPhysicalPlan, PhysicalProperties},
};

use Expr::*;
use optd_dsl::analyzer::{
context::Context,
hir::{CoreData, Expr, Literal, Value},
};
use std::sync::Arc;
use utils::UnitFuture;
use Expr::*;

mod eval;
use eval::Evaluate;
Expand Down
2 changes: 1 addition & 1 deletion optd-core/src/engine/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::engine::{generator::Generator, Continuation, Engine, Evaluate};
use crate::engine::{Continuation, Engine, Evaluate, generator::Generator};
use optd_dsl::analyzer::hir::{
CoreData, Expr, Goal, GroupId, Literal, LogicalOp, MatchArm, Materializable, Operator, Pattern,
PhysicalOp, Value,
Expand Down
2 changes: 1 addition & 1 deletion optd-core/src/engine/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::eval::Evaluate;
use crate::capture;
use crate::engine::{generator::Generator, Engine};
use crate::engine::{Engine, generator::Generator};
use optd_dsl::analyzer::hir::{Expr, Value};
use std::{future::Future, pin::Pin, sync::Arc};

Expand Down
4 changes: 2 additions & 2 deletions optd-core/src/optimizer/egest.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{memo::Memoize, Optimizer};
use super::{Optimizer, memo::Memoize};
use crate::{
cir::{Child, Goal, Operator, OptimizedExpression, PhysicalPlan},
error::Error,
};
use Child::*;
use async_recursion::async_recursion;
use futures::future::try_join_all;
use std::sync::Arc;
use Child::*;

impl<M: Memoize> Optimizer<M> {
/// Egest a physical plan from the memo table based on the best available physical expressions.
Expand Down
Loading