Skip to content

Commit

Permalink
chore: Update for Rust 1.72.0 (#1911)
Browse files Browse the repository at this point in the history
Rust 1.72.0 has introduced a bunch of new lints. Here we fix them all.

`let ... else` finally gets formatted.
  • Loading branch information
chubei committed Aug 24, 2023
1 parent 1cea473 commit 44f3e38
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 53 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"dozer-log-python",
"dozer-utils"
]
resolver = "2"

[patch.crates-io]
postgres = { git = "https://github.com/getdozer/rust-postgres" }
Expand Down
2 changes: 1 addition & 1 deletion dozer-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tonic-web = "0.4.0"
jsonwebtoken = "8.3.0"
tokio-stream = "0.1.12"
crossbeam = "0.8.2"
async-trait = "0.1.66"
async-trait = "0.1.73"
tracing-actix-web = "0.7.2"
tower = "0.4.13"
hyper = "0.14.24"
Expand Down
18 changes: 10 additions & 8 deletions dozer-ingestion/src/connectors/grpc/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ where
if let Ok(req) = result {
let Some(table_index) = table_names
.iter()
.position(|table| table.name == req.schema_name) else {
error!("schema name not found: {}", req.schema_name);
break;
};
.position(|table| table.name == req.schema_name)
else {
error!("schema name not found: {}", req.schema_name);
break;
};

seq_no = req.seq_no;
let res = adapter.handle_message(
Expand Down Expand Up @@ -142,10 +143,11 @@ where
if let Ok(req) = result {
let Some(table_index) = table_names
.iter()
.position(|table| table.name == req.schema_name) else {
error!("schema name not found: {}", req.schema_name);
break;
};
.position(|table| table.name == req.schema_name)
else {
error!("schema name not found: {}", req.schema_name);
break;
};

seq_no = req.seq_no;
let res = adapter.handle_message(
Expand Down
4 changes: 2 additions & 2 deletions dozer-ingestion/tests/test_suite/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub async fn run_test_suite_basic_insert_only<T: InsertOnlyConnectorTest>() {
}

// Filter out non-operation events.
let IngestionMessageKind::OperationEvent{ op: operation, .. } = message.kind else {
let IngestionMessageKind::OperationEvent { op: operation, .. } = message.kind else {
continue;
};

Expand Down Expand Up @@ -244,7 +244,7 @@ pub async fn run_test_suite_basic_cud<T: CudConnectorTest>() {
}

// Filter out non-operation events.
let IngestionMessageKind::OperationEvent{ op: operation, .. } = message.kind else {
let IngestionMessageKind::OperationEvent { op: operation, .. } = message.kind else {
continue;
};

Expand Down
24 changes: 20 additions & 4 deletions dozer-sql/src/pipeline/expression/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,23 @@ pub fn evaluate_gt(
}
}

define_comparison!(evaluate_eq, "=", |l, r| { l == r });
define_comparison!(evaluate_ne, "!=", |l, r| { l != r });
define_comparison!(evaluate_lte, "<=", |l, r| { l <= r });
define_comparison!(evaluate_gte, ">=", |l, r| { l >= r });
fn eq<T: PartialEq>(left: T, right: T) -> bool {
left == right
}

fn ne<T: PartialEq>(left: T, right: T) -> bool {
left != right
}

fn le<T: PartialOrd>(left: T, right: T) -> bool {
left <= right
}

fn ge<T: PartialOrd>(left: T, right: T) -> bool {
left >= right
}

define_comparison!(evaluate_eq, "=", eq);
define_comparison!(evaluate_ne, "!=", ne);
define_comparison!(evaluate_lte, "<=", le);
define_comparison!(evaluate_gte, ">=", ge);
10 changes: 5 additions & 5 deletions dozer-sql/src/pipeline/expression/mathematical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,11 +1777,11 @@ macro_rules! define_math_operator {
};
}

define_math_operator!(evaluate_add, "+", |a, b| { a + b }, 0);
define_math_operator!(evaluate_sub, "-", |a, b| { a - b }, 0);
define_math_operator!(evaluate_mul, "*", |a, b| { a * b }, 0);
define_math_operator!(evaluate_div, "/", |a, b| { a / b }, 1);
define_math_operator!(evaluate_mod, "%", |a, b| { a % b }, 0);
define_math_operator!(evaluate_add, "+", std::ops::Add::add, 0);
define_math_operator!(evaluate_sub, "-", std::ops::Sub::sub, 0);
define_math_operator!(evaluate_mul, "*", std::ops::Mul::mul, 0);
define_math_operator!(evaluate_div, "/", std::ops::Div::div, 1);
define_math_operator!(evaluate_mod, "%", std::ops::Rem::rem, 0);

pub fn evaluate_plus(
schema: &Schema,
Expand Down
6 changes: 1 addition & 5 deletions dozer-storage/src/lmdb_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ pub struct LmdbMap<K, V> {

impl<K, V> Clone for LmdbMap<K, V> {
fn clone(&self) -> Self {
Self {
db: self.db,
_key: std::marker::PhantomData,
_value: std::marker::PhantomData,
}
*self
}
}

Expand Down
6 changes: 1 addition & 5 deletions dozer-storage/src/lmdb_multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ pub struct LmdbMultimap<K, V> {

impl<K, V> Clone for LmdbMultimap<K, V> {
fn clone(&self) -> Self {
Self {
db: self.db,
_key: std::marker::PhantomData,
_value: std::marker::PhantomData,
}
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion dozer-storage/src/lmdb_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct LmdbOption<V>(LmdbMap<u8, V>);

impl<V> Clone for LmdbOption<V> {
fn clone(&self) -> Self {
Self(self.0)
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion dozer-storage/src/lmdb_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct LmdbSet<K>(LmdbMap<K, Vec<u8>>);

impl<K> Clone for LmdbSet<K> {
fn clone(&self) -> Self {
Self(self.0)
*self
}
}

Expand Down

0 comments on commit 44f3e38

Please sign in to comment.