Skip to content

Commit 472aca6

Browse files
authored
bump to Rust 2024 edition (#46)
1 parent 0f6379f commit 472aca6

32 files changed

+110
-100
lines changed

.github/workflows/check.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ jobs:
9999
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
100100
strategy:
101101
matrix:
102-
# `Cargo.lock` version 4 requires 1.78.0
103-
# datafusion 45.0.0 requires 1.81.0
104-
msrv: ["1.81.0"]
102+
# Rust 2024 Edition MSRV
103+
msrv: ["1.85.0"]
105104
name: ubuntu / ${{ matrix.msrv }}
106105
steps:
107106
- uses: actions/checkout@v4

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ resolver = "2"
44

55
[workspace.package]
66
version = "0.1.0"
7-
edition = "2021"
8-
rust-version = "1.81.0"
7+
edition = "2024"
98
repository = "https://github.com/cmu-db/optd"
109

1110
[workspace.dependencies]

optd-core/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name = "optd-core"
33
version.workspace = true
44
edition.workspace = true
5-
rust-version.workspace = true
65
repository.workspace = true
76

87
[dependencies]

optd-core/src/bridge/from_cir.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! Converts optd's type representations (CIR) into DSL [`Value`]s (HIR).
22
33
use crate::cir::*;
4+
use CoreData::*;
5+
use Literal::*;
6+
use Materializable::*;
47
use optd_dsl::analyzer::hir::{
58
self, CoreData, Literal, LogicalOp, Materializable, Operator, PhysicalOp, Value,
69
};
710
use std::sync::Arc;
8-
use CoreData::*;
9-
use Literal::*;
10-
use Materializable::*;
1111

1212
/// Converts a [`PartialLogicalPlan`] into a [`Value`].
1313
pub(crate) fn partial_logical_to_value(plan: &PartialLogicalPlan) -> Value {

optd-core/src/bridge/into_cir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Converts HIR [`Value`]s into optd's type representations (CIR).
22
33
use crate::cir::*;
4-
use optd_dsl::analyzer::hir::{self, CoreData, Literal, Materializable, Value};
5-
use std::sync::Arc;
64
use Child::*;
75
use CoreData::*;
86
use Literal::*;
97
use Materializable::*;
8+
use optd_dsl::analyzer::hir::{self, CoreData, Literal, Materializable, Value};
9+
use std::sync::Arc;
1010

1111
/// Converts a [`Value`] into a [`PartialLogicalPlan`].
1212
///

optd-core/src/engine/eval/binary.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ pub(super) fn eval_binary_op(left: Value, op: &BinOp, right: Value) -> Value {
9292

9393
#[cfg(test)]
9494
mod tests {
95-
use optd_dsl::analyzer::hir::{BinOp, CoreData, Literal, Value};
96-
use std::collections::HashMap;
9795
use BinOp::*;
9896
use CoreData::*;
9997
use Literal::*;
98+
use optd_dsl::analyzer::hir::{BinOp, CoreData, Literal, Value};
99+
use std::collections::HashMap;
100100

101101
use super::eval_binary_op;
102102

optd-core/src/engine/eval/core.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use super::{
2-
operator::{evaluate_logical_operator, evaluate_physical_operator},
32
Engine, Evaluate, Generator,
3+
operator::{evaluate_logical_operator, evaluate_physical_operator},
44
};
55
use crate::capture;
6-
use crate::engine::utils::evaluate_sequence;
76
use crate::engine::Continuation;
7+
use crate::engine::utils::evaluate_sequence;
8+
use CoreData::*;
89
use optd_dsl::analyzer::hir::{CoreData, Expr, Value};
910
use std::sync::Arc;
10-
use CoreData::*;
1111

1212
/// Evaluates a core expression by generating all possible evaluation paths.
1313
///
@@ -160,8 +160,8 @@ where
160160
#[cfg(test)]
161161
mod tests {
162162
use crate::engine::{
163-
test_utils::{evaluate_and_collect, int, lit_expr, string, MockGenerator},
164163
Engine,
164+
test_utils::{MockGenerator, evaluate_and_collect, int, lit_expr, string},
165165
};
166166
use optd_dsl::analyzer::{
167167
context::Context,

optd-core/src/engine/eval/expr.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use super::{binary::eval_binary_op, unary::eval_unary_op, Evaluate};
1+
use super::{Evaluate, binary::eval_binary_op, unary::eval_unary_op};
22
use crate::{
33
capture,
4-
engine::{utils::evaluate_sequence, Continuation, Engine, Generator},
4+
engine::{Continuation, Engine, Generator, utils::evaluate_sequence},
55
};
6+
use CoreData::*;
7+
use FunKind::*;
68
use optd_dsl::analyzer::hir::{
79
BinOp, CoreData, Expr, FunKind, Identifier, Literal, UnaryOp, Value,
810
};
911
use std::sync::Arc;
10-
use CoreData::*;
11-
use FunKind::*;
1212

1313
/// Evaluates an if-then-else expression.
1414
///
@@ -325,11 +325,11 @@ where
325325
#[cfg(test)]
326326
mod tests {
327327
use crate::engine::{
328+
Engine,
328329
test_utils::{
329-
array_val, boolean, evaluate_and_collect, int, lit_expr, lit_val, ref_expr, string,
330-
MockGenerator,
330+
MockGenerator, array_val, boolean, evaluate_and_collect, int, lit_expr, lit_val,
331+
ref_expr, string,
331332
},
332-
Engine,
333333
};
334334
use optd_dsl::analyzer::{
335335
context::Context,

optd-core/src/engine/eval/match.rs

+28-22
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::{
33
capture,
44
engine::{Continuation, UnitFuture},
55
};
6+
use Materializable::*;
7+
use Pattern::*;
68
use optd_dsl::analyzer::{
79
context::Context,
810
hir::{
911
CoreData, Expr, LogicalOp, MatchArm, Materializable, Operator, Pattern, PhysicalOp, Value,
1012
},
1113
};
1214
use std::sync::Arc;
13-
use Materializable::*;
14-
use Pattern::*;
1515

1616
/// A type representing a match result, which is a value and an optional context.
1717
///
@@ -133,7 +133,7 @@ fn match_pattern<G>(
133133
value: Value,
134134
pattern: Pattern,
135135
ctx: Context,
136-
gen: G,
136+
r#gen: G,
137137
k: MatchContinuation,
138138
) -> UnitFuture
139139
where
@@ -154,23 +154,23 @@ where
154154
}
155155
// Complex patterns.
156156
(Bind(ident, inner_pattern), _) => {
157-
match_bind_pattern(value.clone(), ident, *inner_pattern, ctx, gen, k).await;
157+
match_bind_pattern(value.clone(), ident, *inner_pattern, ctx, r#gen, k).await;
158158
}
159159
(ArrayDecomp(head_pat, tail_pat), CoreData::Array(arr)) => {
160160
if arr.is_empty() {
161161
k((value, None)).await;
162162
return;
163163
}
164164

165-
match_array_pattern(*head_pat, *tail_pat, arr, ctx, gen, k).await;
165+
match_array_pattern(*head_pat, *tail_pat, arr, ctx, r#gen, k).await;
166166
}
167167
(Struct(pat_name, pat_fields), CoreData::Struct(val_name, val_fields)) => {
168168
if pat_name != *val_name || pat_fields.len() != val_fields.len() {
169169
k((value, None)).await;
170170
return;
171171
}
172172

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

184-
match_materialized_operator(true, op_pattern, operator.clone(), ctx, gen, k).await;
184+
match_materialized_operator(true, op_pattern, operator.clone(), ctx, r#gen, k)
185+
.await;
185186
}
186187
(Operator(op_pattern), CoreData::Physical(PhysicalOp(Materialized(operator)))) => {
187188
if op_pattern.tag != operator.tag
@@ -192,29 +193,32 @@ where
192193
return;
193194
}
194195

195-
match_materialized_operator(false, op_pattern, operator.clone(), ctx, gen, k).await;
196+
match_materialized_operator(false, op_pattern, operator.clone(), ctx, r#gen, k)
197+
.await;
196198
}
197199
// Unmaterialized operators.
198200
(Operator(op_pattern), CoreData::Logical(LogicalOp(UnMaterialized(group_id)))) => {
199-
gen.clone()
201+
r#gen
202+
.clone()
200203
.yield_group(
201204
*group_id,
202205
Arc::new(move |expanded_value| {
203-
Box::pin(capture!([op_pattern, ctx, gen, k], async move {
204-
match_pattern(expanded_value, Operator(op_pattern), ctx, gen, k)
206+
Box::pin(capture!([op_pattern, ctx, r#gen, k], async move {
207+
match_pattern(expanded_value, Operator(op_pattern), ctx, r#gen, k)
205208
.await;
206209
}))
207210
}),
208211
)
209212
.await;
210213
}
211214
(Operator(op_pattern), CoreData::Physical(PhysicalOp(UnMaterialized(goal)))) => {
212-
gen.clone()
215+
r#gen
216+
.clone()
213217
.yield_goal(
214218
goal,
215219
Arc::new(move |expanded_value| {
216-
Box::pin(capture!([op_pattern, ctx, gen, k], async move {
217-
match_pattern(expanded_value, Operator(op_pattern), ctx, gen, k)
220+
Box::pin(capture!([op_pattern, ctx, r#gen, k], async move {
221+
match_pattern(expanded_value, Operator(op_pattern), ctx, r#gen, k)
218222
.await;
219223
}))
220224
}),
@@ -385,7 +389,7 @@ async fn match_materialized_operator<G>(
385389
op_pattern: Operator<Pattern>,
386390
operator: Operator<Value>,
387391
ctx: Context,
388-
gen: G,
392+
r#gen: G,
389393
k: MatchContinuation,
390394
) where
391395
G: Generator,
@@ -410,7 +414,7 @@ async fn match_materialized_operator<G>(
410414
all_patterns,
411415
all_values,
412416
ctx.clone(),
413-
gen,
417+
r#gen,
414418
Arc::new(move |results| {
415419
Box::pin(capture!([ctx, operator, k], async move {
416420
// Check if all components matched successfully.
@@ -541,13 +545,13 @@ where
541545
#[cfg(test)]
542546
mod tests {
543547
use crate::engine::{
548+
Engine,
544549
test_utils::{
545-
array_decomp_pattern, array_val, bind_pattern, create_logical_operator,
550+
MockGenerator, array_decomp_pattern, array_val, bind_pattern, create_logical_operator,
546551
create_physical_operator, evaluate_and_collect, int, lit_expr, lit_val,
547552
literal_pattern, match_arm, operator_pattern, pattern_match_expr, ref_expr, string,
548-
struct_pattern, struct_val, wildcard_pattern, MockGenerator,
553+
struct_pattern, struct_val, wildcard_pattern,
549554
},
550-
Engine,
551555
};
552556
use optd_dsl::analyzer::{
553557
context::Context,
@@ -1499,9 +1503,11 @@ mod tests {
14991503
for result in &results {
15001504
match &result.0 {
15011505
CoreData::Literal(Literal::String(s)) => {
1502-
assert!(expected_combinations
1503-
.map(|(expected, _)| expected)
1504-
.contains(&s.as_str()));
1506+
assert!(
1507+
expected_combinations
1508+
.map(|(expected, _)| expected)
1509+
.contains(&s.as_str())
1510+
);
15051511
}
15061512
_ => panic!("Expected string literal"),
15071513
}

optd-core/src/engine/eval/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use super::{Continuation, Engine, Generator, UnitFuture};
2+
use Expr::*;
23
use core::evaluate_core_expr;
34
use expr::{
45
evaluate_binary_expr, evaluate_function_call, evaluate_if_then_else, evaluate_let_binding,
56
evaluate_reference, evaluate_unary_expr,
67
};
7-
use optd_dsl::analyzer::hir::{Expr, Value};
88
use r#match::evaluate_pattern_match;
9+
use optd_dsl::analyzer::hir::{Expr, Value};
910
use std::sync::Arc;
10-
use Expr::*;
1111

1212
mod binary;
1313
mod core;

optd-core/src/engine/eval/operator.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use super::{Engine, Generator};
22
use crate::capture;
3-
use crate::engine::utils::evaluate_sequence;
43
use crate::engine::Continuation;
4+
use crate::engine::utils::evaluate_sequence;
5+
use CoreData::{Logical, Physical};
6+
use Materializable::*;
57
use optd_dsl::analyzer::hir::{
68
CoreData, Expr, LogicalOp, Materializable, Operator, PhysicalOp, Value,
79
};
810
use std::sync::Arc;
9-
use CoreData::{Logical, Physical};
10-
use Materializable::*;
1111

1212
/// Specialized continuation type for operator values
1313
type OperatorContinuation = Continuation<Operator<Value>>;
@@ -142,11 +142,11 @@ async fn evaluate_operator<G>(
142142
#[cfg(test)]
143143
mod tests {
144144
use crate::engine::{
145+
Engine,
145146
test_utils::{
146-
create_logical_operator, evaluate_and_collect, int, lit_expr, lit_val, string,
147-
MockGenerator,
147+
MockGenerator, create_logical_operator, evaluate_and_collect, int, lit_expr, lit_val,
148+
string,
148149
},
149-
Engine,
150150
};
151151
use optd_dsl::analyzer::{
152152
context::Context,

optd-core/src/engine/eval/unary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
//! - Numeric negation for integers and floating-point numbers
66
//! - Logical NOT for boolean values
77
8-
use optd_dsl::analyzer::hir::{CoreData, Literal, UnaryOp, Value};
98
use CoreData::*;
109
use Literal::*;
1110
use UnaryOp::*;
11+
use optd_dsl::analyzer::hir::{CoreData, Literal, UnaryOp, Value};
1212

1313
/// Evaluates a unary operation on a value.
1414
///

optd-core/src/engine/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use crate::{
1212
cir::{Cost, LogicalProperties, PartialLogicalPlan, PartialPhysicalPlan, PhysicalProperties},
1313
};
1414

15+
use Expr::*;
1516
use optd_dsl::analyzer::{
1617
context::Context,
1718
hir::{CoreData, Expr, Literal, Value},
1819
};
1920
use std::sync::Arc;
2021
use utils::UnitFuture;
21-
use Expr::*;
2222

2323
mod eval;
2424
use eval::Evaluate;

optd-core/src/engine/test_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::engine::{generator::Generator, Continuation, Engine, Evaluate};
1+
use crate::engine::{Continuation, Engine, Evaluate, generator::Generator};
22
use optd_dsl::analyzer::hir::{
33
CoreData, Expr, Goal, GroupId, Literal, LogicalOp, MatchArm, Materializable, Operator, Pattern,
44
PhysicalOp, Value,

optd-core/src/engine/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::eval::Evaluate;
22
use crate::capture;
3-
use crate::engine::{generator::Generator, Engine};
3+
use crate::engine::{Engine, generator::Generator};
44
use optd_dsl::analyzer::hir::{Expr, Value};
55
use std::{future::Future, pin::Pin, sync::Arc};
66

optd-core/src/optimizer/egest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use super::{memo::Memoize, Optimizer};
1+
use super::{Optimizer, memo::Memoize};
22
use crate::{
33
cir::{Child, Goal, Operator, OptimizedExpression, PhysicalPlan},
44
error::Error,
55
};
6+
use Child::*;
67
use async_recursion::async_recursion;
78
use futures::future::try_join_all;
89
use std::sync::Arc;
9-
use Child::*;
1010

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

0 commit comments

Comments
 (0)