From 41245d715f88df4e0e037bb41317a9acde90bda7 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 13:02:13 -0600 Subject: [PATCH 1/7] Run cargo fix --workspace --edition && cargo fmt --- crates/bench/src/schemas.rs | 36 ++++++------ crates/bindings-macro/src/util.rs | 6 +- crates/bindings-sys/src/lib.rs | 18 +++--- crates/bindings/src/http.rs | 2 +- crates/bindings/src/lib.rs | 4 +- crates/bindings/src/logger.rs | 4 +- crates/bindings/src/query_builder/expr.rs | 2 +- crates/bindings/src/rt.rs | 10 ++-- crates/bindings/src/table.rs | 4 +- crates/cli/src/tasks/csharp.rs | 2 +- .../examples/regen-csharp-moduledef.rs | 2 +- .../examples/regen-typescript-moduledef.rs | 2 +- crates/codegen/src/util.rs | 2 +- crates/codegen/tests/codegen.rs | 2 +- crates/commitlog/src/commitlog.rs | 2 +- crates/commitlog/src/lib.rs | 11 ++-- crates/commitlog/src/stream/writer.rs | 15 +++-- crates/core/src/db/relational_db.rs | 2 +- crates/core/src/db/update.rs | 2 +- crates/core/src/host/host_controller.rs | 2 +- crates/core/src/host/instance_env.rs | 2 +- crates/core/src/host/module_host.rs | 21 +++---- crates/core/src/host/scheduler.rs | 31 +++++----- crates/core/src/host/v8/builtins/mod.rs | 2 +- crates/core/src/host/v8/from_value.rs | 4 +- crates/core/src/host/v8/syscall/v1.rs | 2 +- crates/core/src/host/v8/to_value.rs | 2 +- crates/core/src/sql/ast.rs | 4 +- crates/core/src/sql/compiler.rs | 9 +-- crates/core/src/subscription/mod.rs | 24 +++++--- .../subscription/module_subscription_actor.rs | 38 +++++++----- .../module_subscription_manager.rs | 6 +- crates/core/src/subscription/subscription.rs | 2 +- crates/core/src/util/jobs.rs | 2 +- crates/data-structures/src/error_stream.rs | 4 +- crates/data-structures/src/slim_slice.rs | 58 +++++++++++-------- .../locking_tx_datastore/committed_state.rs | 4 +- .../src/locking_tx_datastore/delete_table.rs | 2 +- .../src/locking_tx_datastore/mut_tx.rs | 17 +++--- crates/datastore/src/system_tables.rs | 2 +- crates/durability/src/imp/local.rs | 9 ++- crates/fs-utils/src/compression.rs | 2 +- crates/lib/tests/serde.rs | 2 +- crates/metrics/src/typed_prometheus.rs | 6 +- crates/paths/src/lib.rs | 6 +- crates/pg/src/pg_server.rs | 11 ++-- crates/primitives/src/col_list.rs | 4 +- crates/sats/src/de.rs | 14 ++--- crates/sats/src/de/impls.rs | 2 +- crates/sats/src/de/serde.rs | 9 +-- crates/sats/src/product_value.rs | 4 +- crates/sats/src/ser/impls.rs | 2 +- crates/sats/src/typespace.rs | 4 +- crates/schema/src/schema.rs | 2 +- crates/snapshot/src/lib.rs | 6 +- crates/snapshot/src/remote.rs | 2 +- crates/standalone/src/main.rs | 2 +- crates/subscription/src/lib.rs | 4 +- crates/table/src/page.rs | 2 +- crates/table/src/read_column.rs | 4 +- crates/table/src/util.rs | 4 +- modules/keynote-benchmarks/src/lib.rs | 4 +- sdks/rust/src/client_cache.rs | 2 +- sdks/rust/src/subscription.rs | 11 ++-- sdks/rust/src/websocket.rs | 2 +- .../connect_disconnect_client/src/main.rs | 22 ++++--- sdks/rust/tests/test-client/src/main.rs | 2 +- 67 files changed, 283 insertions(+), 227 deletions(-) diff --git a/crates/bench/src/schemas.rs b/crates/bench/src/schemas.rs index b97d423d4ad..2329f52f8cd 100644 --- a/crates/bench/src/schemas.rs +++ b/crates/bench/src/schemas.rs @@ -170,7 +170,7 @@ pub fn table_name(style: IndexStrategy) -> String { #[derive(Clone)] pub struct XorShiftLite(pub u64); impl XorShiftLite { - fn gen(&mut self) -> u64 { + fn r#gen(&mut self) -> u64 { let old = self.0; self.0 ^= self.0 << 13; self.0 ^= self.0 >> 7; @@ -188,36 +188,36 @@ pub trait RandomTable { /// Then in the filter benchmarks, `mean_result_count = table_size / buckets`. /// /// Currently the same number of buckets is used for all attributes. - fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self; + fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self; } impl RandomTable for u32_u64_str { - fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { - let name = nth_name(rng.gen() % buckets).into(); - let age = rng.gen() % buckets; + fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { + let name = nth_name(rng.r#gen() % buckets).into(); + let age = rng.r#gen() % buckets; u32_u64_str { id, name, age } } } impl RandomTable for u32_u64_u64 { - fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { - let x = rng.gen() % buckets; - let y = rng.gen() % buckets; + fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { + let x = rng.r#gen() % buckets; + let y = rng.r#gen() % buckets; u32_u64_u64 { id, x, y } } } impl RandomTable for u64_u64_u32 { - fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { - let x = rng.gen() % buckets; - let y = rng.gen() % buckets; + fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self { + let x = rng.r#gen() % buckets; + let y = rng.r#gen() % buckets; u64_u64_u32 { x, y, id } } } pub fn create_sequential(seed: u64, count: u32, buckets: u64) -> Vec { let mut rng = XorShiftLite(seed); - (0..count).map(|id| T::gen(id, &mut rng, buckets)).collect() + (0..count).map(|id| T::r#gen(id, &mut rng, buckets)).collect() } /// Create a table whose first `identical` rows are identical except for their `id` column. @@ -236,13 +236,13 @@ pub fn create_partly_identical(seed: u64, identical: u64, total: for _ in 0..identical { // clone to preserve rng state let mut rng_ = rng.clone(); - result.push(T::gen(id as u32, &mut rng_, buckets)); + result.push(T::r#gen(id as u32, &mut rng_, buckets)); id += 1; } // advance rng - drop(T::gen(id as u32, &mut rng, buckets)); + drop(T::r#gen(id as u32, &mut rng, buckets)); for _ in identical..total { - result.push(T::gen(id as u32, &mut rng, buckets)); + result.push(T::r#gen(id as u32, &mut rng, buckets)); id += 1; } result @@ -253,8 +253,8 @@ pub fn create_random(seed: u64, count: u32, buckets: u64) -> Vec let mut rng = XorShiftLite(seed); (0..count) .map(|_| { - let id = (rng.gen() % (u32::MAX as u64)) as u32; - T::gen(id, &mut rng, buckets) + let id = (rng.r#gen() % (u32::MAX as u64)) as u32; + T::r#gen(id, &mut rng, buckets) }) .collect() } @@ -361,7 +361,7 @@ mod tests { } // sample some earlier names to make sure we haven't overlapped for _ in 0..30 { - let prev = rng.gen() % n; + let prev = rng.r#gen() % n; assert!( name != nth_name(prev), "names should not repeat, but {}->{} and {}->{}", diff --git a/crates/bindings-macro/src/util.rs b/crates/bindings-macro/src/util.rs index 41c9dad016d..061e4b105f3 100644 --- a/crates/bindings-macro/src/util.rs +++ b/crates/bindings-macro/src/util.rs @@ -90,18 +90,18 @@ macro_rules! match_meta { (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:block $($rest:tt)* }) => { match_meta!(@case $acc, $comparisons, $meta, _, $sym, $body, { $($rest)* }) }; - (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:expr, $($rest:tt)* }) => { + (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:expr_2021, $($rest:tt)* }) => { match_meta!(@case $acc, $comparisons, $meta, _, $sym, $body, { $($rest)* }) }; - (@match ($($acc:tt)*), ($($comparisons:expr),*), $meta:ident {}) => { + (@match ($($acc:tt)*), ($($comparisons:expr_2021),*), $meta:ident {}) => { match () { $($acc)* _ => return Err($meta.error($crate::util::one_of(&[$($comparisons),*]))), } }; - (@case ($($acc:tt)*), ($($comparisons:expr),*), $meta:ident, $binding:tt, $sym:path, $body:expr, { $($rest:tt)* }) => { + (@case ($($acc:tt)*), ($($comparisons:expr_2021),*), $meta:ident, $binding:tt, $sym:path, $body:expr_2021, { $($rest:tt)* }) => { match_meta!(@match ( $($acc)* _ if $meta.path == $sym => $body, diff --git a/crates/bindings-sys/src/lib.rs b/crates/bindings-sys/src/lib.rs index 751b6ba8cb0..1ee1b486455 100644 --- a/crates/bindings-sys/src/lib.rs +++ b/crates/bindings-sys/src/lib.rs @@ -19,7 +19,7 @@ pub mod raw { // with a module identifier with a minor version 1 above the previous highest minor version. // For breaking changes, all functions should be moved into one new `spacetime_X.0` block. #[link(wasm_import_module = "spacetime_10.0")] - extern "C" { + unsafe extern "C" { /// Queries the `table_id` associated with the given (table) `name` /// where `name` is the UTF-8 slice in WASM memory at `name_ptr[..name_len]`. /// @@ -593,7 +593,7 @@ pub mod raw { // See comment on previous `extern "C"` block re: ABI version. #[link(wasm_import_module = "spacetime_10.1")] - extern "C" { + unsafe extern "C" { /// Read the remaining length of a [`BytesSource`] and write it to `out`. /// /// Note that the host automatically frees byte sources which are exhausted. @@ -622,7 +622,7 @@ pub mod raw { // See comment on previous `extern "C"` block re: ABI version. #[link(wasm_import_module = "spacetime_10.2")] - extern "C" { + unsafe extern "C" { /// Finds the JWT payload associated with `connection_id`. /// A `[ByteSourceId]` for the payload will be written to `target_ptr`. /// If nothing is found for the connection, `[ByteSourceId::INVALID]` (zero) is written to `target_ptr`. @@ -647,7 +647,7 @@ pub mod raw { #[cfg(feature = "unstable")] #[link(wasm_import_module = "spacetime_10.3")] - extern "C" { + unsafe extern "C" { /// Suspends execution of this WASM instance until approximately `wake_at_micros_since_unix_epoch`. /// /// Returns immediately if `wake_at_micros_since_unix_epoch` is in the past. @@ -949,10 +949,12 @@ fn cvt(x: u16) -> Result<()> { /// before writing a safe and valid `T` to it. #[inline] unsafe fn call(f: impl FnOnce(*mut T) -> u16) -> Result { - let mut out = MaybeUninit::uninit(); - let f_code = f(out.as_mut_ptr()); - cvt(f_code)?; - Ok(out.assume_init()) + unsafe { + let mut out = MaybeUninit::uninit(); + let f_code = f(out.as_mut_ptr()); + cvt(f_code)?; + Ok(out.assume_init()) + } } /// Runs the given function `f`. diff --git a/crates/bindings/src/http.rs b/crates/bindings/src/http.rs index 68870192cfe..4c52620b1b8 100644 --- a/crates/bindings/src/http.rs +++ b/crates/bindings/src/http.rs @@ -248,7 +248,7 @@ impl Default for Body { } macro_rules! impl_body_from_bytes { - ($bytes:ident : $t:ty => $conv:expr) => { + ($bytes:ident : $t:ty => $conv:expr_2021) => { impl From<$t> for Body { fn from($bytes: $t) -> Body { Body::from_bytes($conv) diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index e1089ce5451..1423ee783cb 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1551,10 +1551,10 @@ macro_rules! __volatile_nonatomic_schedule_immediate_impl { ([$($cur:tt)*] [$next:tt $($rest:tt)*]) => { $crate::__volatile_nonatomic_schedule_immediate_impl!([$($cur)* $next] [$($rest)*]) }; - (@process_args $repeater:path, ($($args:expr),* $(,)?)) => { + (@process_args $repeater:path, ($($args:expr_2021),* $(,)?)) => { $crate::__volatile_nonatomic_schedule_immediate_impl!(@call $repeater, ($($args),*)) }; - (@call $repeater:path, ($($args:expr),*)) => { + (@call $repeater:path, ($($args:expr_2021),*)) => { if false { let _ = $repeater(&$crate::ReducerContext::__dummy(), $($args,)*); } else { diff --git a/crates/bindings/src/logger.rs b/crates/bindings/src/logger.rs index 58416e55981..8d2203320b5 100644 --- a/crates/bindings/src/logger.rs +++ b/crates/bindings/src/logger.rs @@ -5,7 +5,7 @@ use std::sync::Mutex; use std::{fmt, panic}; /// Registers the panic hook to our own. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __preinit__00_panic_hook() { panic::set_hook(Box::new(panic_hook)); } @@ -77,7 +77,7 @@ static LOGGER: Logger = Logger { /// Registers our logger unless already set. /// The maximum level is `Trace`. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __preinit__15_init_log() { // if the user wants to set their own logger, that's fine if log::set_logger(&LOGGER).is_ok() { diff --git a/crates/bindings/src/query_builder/expr.rs b/crates/bindings/src/query_builder/expr.rs index 9591621dff8..8f6710821cd 100644 --- a/crates/bindings/src/query_builder/expr.rs +++ b/crates/bindings/src/query_builder/expr.rs @@ -71,7 +71,7 @@ impl LiteralValue { } macro_rules! impl_rhs { - ($ty:ty, $formatter:expr) => { + ($ty:ty, $formatter:expr_2021) => { impl RHS for $ty { fn to_expr(self) -> Operand { Operand::Literal(LiteralValue($formatter(self))) diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 31beb6d3a28..11f4eff74a0 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -862,7 +862,7 @@ static ANONYMOUS_VIEWS: OnceLock> = OnceLock::new(); /// to define and, to a limited extent, alter the schema at initialization time, /// including when modules are updated (re-publishing). /// After initialization, the module cannot alter the schema. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __describe_module__(description: BytesSink) { // Collect the `module`. let mut module = ModuleBuilder::default(); @@ -918,7 +918,7 @@ extern "C" fn __describe_module__(description: BytesSink) { /// it is expected that `HOST_CALL_FAILURE` is returned. /// Otherwise, `0` should be returned, i.e., the reducer completed successfully. /// Note that in the future, more failure codes could be supported. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __call_reducer__( id: usize, sender_0: u64, @@ -1015,7 +1015,7 @@ fn convert_err_to_errno(res: Result<(), Box>, out: BytesSink) -> i16 { /// /// Procedures always return the error 0. All other return values are reserved. #[cfg(feature = "unstable")] -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __call_procedure__( id: usize, sender_0: u64, @@ -1074,7 +1074,7 @@ extern "C" fn __call_procedure__( /// /// The current abi is identified by a return code of 2. /// The previous abi, which we still support, is identified by a return code of 0. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __call_view_anon__(id: usize, args: BytesSource, sink: BytesSink) -> i16 { let views = ANONYMOUS_VIEWS.get().unwrap(); write_to_sink( @@ -1102,7 +1102,7 @@ extern "C" fn __call_view_anon__(id: usize, args: BytesSource, sink: BytesSink) /// /// The current abi is identified by a return code of 2. /// The previous abi, which we still support, is identified by a return code of 0. -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn __call_view__( id: usize, sender_0: u64, diff --git a/crates/bindings/src/table.rs b/crates/bindings/src/table.rs index 0dd7a6edc17..012397c9914 100644 --- a/crates/bindings/src/table.rs +++ b/crates/bindings/src/table.rs @@ -597,7 +597,7 @@ impl RangedIndex { /// > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RangedIndex::::filter` /// > ``` /// - pub fn filter(&self, b: B) -> impl Iterator + pub fn filter(&self, b: B) -> impl Iterator + use where B: IndexScanRangeBounds, { @@ -715,7 +715,7 @@ impl RangedIndexReadOnly #[doc(hidden)] pub const __NEW: Self = Self { _marker: PhantomData }; - pub fn filter(&self, b: B) -> impl Iterator + pub fn filter(&self, b: B) -> impl Iterator + use where B: IndexScanRangeBounds, { diff --git a/crates/cli/src/tasks/csharp.rs b/crates/cli/src/tasks/csharp.rs index 5df8b730448..04127c3391a 100644 --- a/crates/cli/src/tasks/csharp.rs +++ b/crates/cli/src/tasks/csharp.rs @@ -12,7 +12,7 @@ pub(crate) fn build_csharp(project_path: &Path, build_debug: bool) -> anyhow::Re // All `dotnet` commands must execute in the project directory, otherwise // global.json won't have any effect and wrong .NET SDK might be picked. macro_rules! dotnet { - ($($arg:expr),*) => { + ($($arg:expr_2021),*) => { duct::cmd!("dotnet", $($arg),*).dir(project_path) }; } diff --git a/crates/codegen/examples/regen-csharp-moduledef.rs b/crates/codegen/examples/regen-csharp-moduledef.rs index 74db4b9de90..6f782a11603 100644 --- a/crates/codegen/examples/regen-csharp-moduledef.rs +++ b/crates/codegen/examples/regen-csharp-moduledef.rs @@ -10,7 +10,7 @@ use std::path::Path; use std::sync::OnceLock; macro_rules! regex_replace { - ($value:expr, $re:expr, $replace:expr) => {{ + ($value:expr_2021, $re:expr_2021, $replace:expr_2021) => {{ static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new($re).unwrap()) .replace_all($value, $replace) diff --git a/crates/codegen/examples/regen-typescript-moduledef.rs b/crates/codegen/examples/regen-typescript-moduledef.rs index 47ecb692863..42508fb53c4 100644 --- a/crates/codegen/examples/regen-typescript-moduledef.rs +++ b/crates/codegen/examples/regen-typescript-moduledef.rs @@ -13,7 +13,7 @@ use std::path::Path; use std::sync::OnceLock; macro_rules! regex_replace { - ($value:expr, $re:expr, $replace:expr) => {{ + ($value:expr_2021, $re:expr_2021, $replace:expr_2021) => {{ static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new($re).unwrap()) .replace_all($value, $replace) diff --git a/crates/codegen/src/util.rs b/crates/codegen/src/util.rs index 6ff3d11b408..7c6380f193f 100644 --- a/crates/codegen/src/util.rs +++ b/crates/codegen/src/util.rs @@ -143,7 +143,7 @@ pub(super) fn iter_unique_cols<'a>( constraints[&ColList::from(field.col_pos)] .has_unique() .then(|| { - let res @ (_, ref ty) = &product_def.elements[field.col_pos.idx()]; + let res @ (_, ty) = &product_def.elements[field.col_pos.idx()]; is_type_filterable(typespace, ty).then_some(res) }) .flatten() diff --git a/crates/codegen/tests/codegen.rs b/crates/codegen/tests/codegen.rs index f9912ca44cc..907db0bc735 100644 --- a/crates/codegen/tests/codegen.rs +++ b/crates/codegen/tests/codegen.rs @@ -11,7 +11,7 @@ fn compiled_module() -> &'static ModuleDef { } macro_rules! declare_tests { - ($($name:ident => $lang:expr,)*) => ($( + ($($name:ident => $lang:expr_2021,)*) => ($( #[test] fn $name() { let module = compiled_module(); diff --git a/crates/commitlog/src/commitlog.rs b/crates/commitlog/src/commitlog.rs index 03c590e4950..cbf97d96367 100644 --- a/crates/commitlog/src/commitlog.rs +++ b/crates/commitlog/src/commitlog.rs @@ -311,7 +311,7 @@ impl Generic { &self, offset: u64, decoder: &'a D, - ) -> impl Iterator, D::Error>> + 'a + ) -> impl Iterator, D::Error>> + 'a + use<'a, D, R, T> where D: Decoder, D::Error: From, diff --git a/crates/commitlog/src/lib.rs b/crates/commitlog/src/lib.rs index a3fb912d827..a95dd97b87f 100644 --- a/crates/commitlog/src/lib.rs +++ b/crates/commitlog/src/lib.rs @@ -307,7 +307,7 @@ impl Commitlog { /// This means that, when this iterator yields an `Err` value, the consumer /// may want to check if the iterator is exhausted (by calling `next()`) /// before treating the `Err` value as an application error. - pub fn commits(&self) -> impl Iterator> { + pub fn commits(&self) -> impl Iterator> + use { self.commits_from(0) } @@ -320,7 +320,7 @@ impl Commitlog { /// Note that the first [`StoredCommit`] yielded is the first commit /// containing the given transaction offset, i.e. its `min_tx_offset` may be /// smaller than `offset`. - pub fn commits_from(&self, offset: u64) -> impl Iterator> { + pub fn commits_from(&self, offset: u64) -> impl Iterator> + use { self.inner.read().unwrap().commits_from(offset) } @@ -459,7 +459,10 @@ impl Commitlog { /// This means that, when this iterator yields an `Err` value, the consumer /// may want to check if the iterator is exhausted (by calling `next()`) /// before treating the `Err` value as an application error. - pub fn transactions<'a, D>(&self, de: &'a D) -> impl Iterator, D::Error>> + 'a + pub fn transactions<'a, D>( + &self, + de: &'a D, + ) -> impl Iterator, D::Error>> + 'a + use<'a, D, T> where D: Decoder, D::Error: From, @@ -478,7 +481,7 @@ impl Commitlog { &self, offset: u64, de: &'a D, - ) -> impl Iterator, D::Error>> + 'a + ) -> impl Iterator, D::Error>> + 'a + use<'a, D, T> where D: Decoder, D::Error: From, diff --git a/crates/commitlog/src/stream/writer.rs b/crates/commitlog/src/stream/writer.rs index 83f37a9f1d6..b2f2b0c279a 100644 --- a/crates/commitlog/src/stream/writer.rs +++ b/crates/commitlog/src/stream/writer.rs @@ -228,13 +228,16 @@ where segment, offset_index: index, } - } else if let Some(current_segment) = self.current_segment.take() { - current_segment } else { - return Err(io::Error::new( - io::ErrorKind::InvalidData, - "no current segment, expected segment header", - )); + match self.current_segment.take() { + Some(current_segment) => current_segment, + _ => { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "no current segment, expected segment header", + )); + } + } }; // What follows is commits to be written to `current_segment`, diff --git a/crates/core/src/db/relational_db.rs b/crates/core/src/db/relational_db.rs index c84f24e42d0..c89a0c81226 100644 --- a/crates/core/src/db/relational_db.rs +++ b/crates/core/src/db/relational_db.rs @@ -1435,7 +1435,7 @@ impl RelationalDB { TableId, Bound, Bound, - impl Iterator>, + impl Iterator> + use<'a>, ), DBError, > { diff --git a/crates/core/src/db/update.rs b/crates/core/src/db/update.rs index fa5e5b64f10..5b3060497b6 100644 --- a/crates/core/src/db/update.rs +++ b/crates/core/src/db/update.rs @@ -80,7 +80,7 @@ fn manual_migrate_database( /// Logs with `info` level to `$logger` as well as via the `log` crate. macro_rules! log { - ($logger:expr, $($tokens:tt)*) => { + ($logger:expr_2021, $($tokens:tt)*) => { $logger.info(&format!($($tokens)*)); log::info!($($tokens)*); }; diff --git a/crates/core/src/host/host_controller.rs b/crates/core/src/host/host_controller.rs index 4bf60054c28..3d1e5118103 100644 --- a/crates/core/src/host/host_controller.rs +++ b/crates/core/src/host/host_controller.rs @@ -572,7 +572,7 @@ impl HostController { /// On-panic callback passed to [`ModuleHost`]s created by this controller. /// /// Removes the module with the given `replica_id` from this controller. - fn unregister_fn(&self, replica_id: u64) -> impl Fn() + Send + Sync + 'static { + fn unregister_fn(&self, replica_id: u64) -> impl Fn() + Send + Sync + 'static + use<> { let hosts = Arc::downgrade(&self.hosts); move || { if let Some(hosts) = hosts.upgrade() { diff --git a/crates/core/src/host/instance_env.rs b/crates/core/src/host/instance_env.rs index 933834432c0..ff22df9b973 100644 --- a/crates/core/src/host/instance_env.rs +++ b/crates/core/src/host/instance_env.rs @@ -718,7 +718,7 @@ impl InstanceEnv { &mut self, request: st_http::Request, body: bytes::Bytes, - ) -> Result>, NodesError> { + ) -> Result> + use<>, NodesError> { if self.in_tx() { // If we're holding a transaction open, refuse to perform this blocking operation. return Err(NodesError::WouldBlockTransaction(super::AbiCall::ProcedureHttpRequest)); diff --git a/crates/core/src/host/module_host.rs b/crates/core/src/host/module_host.rs index 87b1be33a1b..6f9da4fd81b 100644 --- a/crates/core/src/host/module_host.rs +++ b/crates/core/src/host/module_host.rs @@ -776,15 +776,16 @@ impl ModuleInstanceManager { } } async fn get_instance(&mut self) -> Instance { - if let Some(inst) = self.instances.pop_back() { - inst - } else { - let start_time = std::time::Instant::now(); - // TODO: should we be calling `create_instance` on the `SingleCoreExecutor` rather than the calling thread? - let res = self.module.create_instance().await; - let elapsed_time = start_time.elapsed(); - self.create_instance_time_metric.observe(elapsed_time); - res + match self.instances.pop_back() { + Some(inst) => inst, + _ => { + let start_time = std::time::Instant::now(); + // TODO: should we be calling `create_instance` on the `SingleCoreExecutor` rather than the calling thread? + let res = self.module.create_instance().await; + let elapsed_time = start_time.elapsed(); + self.create_instance_time_metric.observe(elapsed_time); + res + } } } @@ -1070,7 +1071,7 @@ impl ModuleHost { Ok(res) } - fn start_call_timer(&self, label: &str) -> ScopeGuard<(), impl FnOnce(())> { + fn start_call_timer(&self, label: &str) -> ScopeGuard<(), impl FnOnce(()) + use<>> { // Record the time until our function starts running. let queue_timer = WORKER_METRICS .reducer_wait_time diff --git a/crates/core/src/host/scheduler.rs b/crates/core/src/host/scheduler.rs index 7fd205aa34b..275ffb11728 100644 --- a/crates/core/src/host/scheduler.rs +++ b/crates/core/src/host/scheduler.rs @@ -373,21 +373,24 @@ impl SchedulerActor { match get_schedule_row_mut(&tx, &db, id) { Ok(schedule_row) => { - if let Ok(schedule_at) = read_schedule_at(&schedule_row, id.at_column) { - // If the schedule is an interval, we handle it as a repeated schedule - if let ScheduleAt::Interval(_) = schedule_at { - return Some(schedule_at); + match read_schedule_at(&schedule_row, id.at_column) { + Ok(schedule_at) => { + // If the schedule is an interval, we handle it as a repeated schedule + if let ScheduleAt::Interval(_) = schedule_at { + return Some(schedule_at); + } + let row_ptr = schedule_row.pointer(); + db.delete(&mut tx, id.table_id, [row_ptr]); + + commit_and_broadcast_deletion_event(tx, module_host); + } + _ => { + log::debug!( + "Failed to read 'scheduled_at' from row: table_id {}, schedule_id {}", + id.table_id, + id.schedule_id + ); } - let row_ptr = schedule_row.pointer(); - db.delete(&mut tx, id.table_id, [row_ptr]); - - commit_and_broadcast_deletion_event(tx, module_host); - } else { - log::debug!( - "Failed to read 'scheduled_at' from row: table_id {}, schedule_id {}", - id.table_id, - id.schedule_id - ); } } Err(_) => { diff --git a/crates/core/src/host/v8/builtins/mod.rs b/crates/core/src/host/v8/builtins/mod.rs index d790415f388..b097fb81450 100644 --- a/crates/core/src/host/v8/builtins/mod.rs +++ b/crates/core/src/host/v8/builtins/mod.rs @@ -31,7 +31,7 @@ fn eval_builtin( } macro_rules! create_synthetic_module { - ($scope:expr, $module_name:expr $(, $fun:ident)* $(,)?) => {{ + ($scope:expr_2021, $module_name:expr_2021 $(, $fun:ident)* $(,)?) => {{ let export_names = &[$(str_from_ident!($fun).string($scope)),*]; let eval_steps = |context, module| { v8::callback_scope!(unsafe scope, context); diff --git a/crates/core/src/host/v8/from_value.rs b/crates/core/src/host/v8/from_value.rs index 95c6f811062..1a9522a81b5 100644 --- a/crates/core/src/host/v8/from_value.rs +++ b/crates/core/src/host/v8/from_value.rs @@ -11,7 +11,7 @@ pub(super) trait FromValue: Sized { /// Provides a [`FromValue`] implementation. macro_rules! impl_from_value { - ($ty:ty, ($val:ident, $scope:ident) => $logic:expr) => { + ($ty:ty, ($val:ident, $scope:ident) => $logic:expr_2021) => { impl FromValue for $ty { fn from_value<'scope>($val: Local<'_, Value>, $scope: &PinScope<'scope, '_>) -> ValueResult<'scope, Self> { $logic @@ -35,7 +35,7 @@ where /// Tries to cast `Value` into `T` or raises a JS exception as a returned `Err` value. macro_rules! cast { - ($scope:expr, $val:expr, $js_ty:ty, $expected:literal $(, $args:expr)* $(,)?) => {{ + ($scope:expr_2021, $val:expr_2021, $js_ty:ty, $expected:literal $(, $args:expr_2021)* $(,)?) => {{ $crate::host::v8::from_value::try_cast::<$js_ty>($scope, $val, |got| format!(concat!("Expected ", $expected, ", got {__got}"), $($args,)* __got = got)) }}; } diff --git a/crates/core/src/host/v8/syscall/v1.rs b/crates/core/src/host/v8/syscall/v1.rs index 588fd16a86e..6c21f573bac 100644 --- a/crates/core/src/host/v8/syscall/v1.rs +++ b/crates/core/src/host/v8/syscall/v1.rs @@ -31,7 +31,7 @@ use v8::{ }; macro_rules! create_synthetic_module { - ($scope:expr, $module_name:expr $(, ($wrapper:ident, $abi_call:expr, $fun:ident))* $(,)?) => {{ + ($scope:expr_2021, $module_name:expr_2021 $(, ($wrapper:ident, $abi_call:expr_2021, $fun:ident))* $(,)?) => {{ let export_names = &[$(str_from_ident!($fun).string($scope)),*]; let eval_steps = |context, module| { callback_scope!(unsafe scope, context); diff --git a/crates/core/src/host/v8/to_value.rs b/crates/core/src/host/v8/to_value.rs index 53ba5401f30..094ef2d541c 100644 --- a/crates/core/src/host/v8/to_value.rs +++ b/crates/core/src/host/v8/to_value.rs @@ -11,7 +11,7 @@ pub(super) trait ToValue { /// Provides a [`ToValue`] implementation. macro_rules! impl_to_value { - ($ty:ty, ($val:ident, $scope:ident) => $logic:expr) => { + ($ty:ty, ($val:ident, $scope:ident) => $logic:expr_2021) => { impl ToValue for $ty { fn to_value<'scope>(&self, $scope: &PinScope<'scope, '_>) -> Local<'scope, Value> { let $val = *self; diff --git a/crates/core/src/sql/ast.rs b/crates/core/src/sql/ast.rs index 26c52d9b126..6d8414eb66e 100644 --- a/crates/core/src/sql/ast.rs +++ b/crates/core/src/sql/ast.rs @@ -66,7 +66,7 @@ impl Unsupported for sqlparser::ast::GroupByExpr { } macro_rules! unsupported { - ($name:literal,$a:expr)=>{{ + ($name:literal,$a:expr_2021)=>{{ let name = stringify!($name); let it = stringify!($a); if $a.unsupported() { @@ -76,7 +76,7 @@ macro_rules! unsupported { }); } }}; - ($name:literal,$($a:expr),+$(,)?)=> {{ + ($name:literal,$($a:expr_2021),+$(,)?)=> {{ $(unsupported!($name,$a);)+ }}; } diff --git a/crates/core/src/sql/compiler.rs b/crates/core/src/sql/compiler.rs index eb17de1e8a4..f801f64d177 100644 --- a/crates/core/src/sql/compiler.rs +++ b/crates/core/src/sql/compiler.rs @@ -74,16 +74,17 @@ fn compile_select(table: From, project: Box<[Column]>, selection: Option not_found.push(field), Err(err) => return Err(err), }, - Column::QualifiedWildcard { table: name } => { - if let Some(t) = table.iter_tables().find(|x| *x.table_name == name) { + Column::QualifiedWildcard { table: name } => match table.iter_tables().find(|x| *x.table_name == name) { + Some(t) => { for c in t.columns().iter() { col_ids.push(FieldName::new(t.table_id, c.col_pos).into()); } qualified_wildcards.push(t.table_id); - } else { + } + _ => { return Err(PlanError::TableNotFoundQualified { expect: name }); } - } + }, Column::Wildcard => {} } } diff --git a/crates/core/src/subscription/mod.rs b/crates/core/src/subscription/mod.rs index f893de157cc..68d1e947531 100644 --- a/crates/core/src/subscription/mod.rs +++ b/crates/core/src/subscription/mod.rs @@ -262,13 +262,23 @@ where let start_time = std::time::Instant::now(); let result = if plan.returns_view_table() { - if let Some(schema) = plan.return_table() { - let pipelined_plan = PipelinedProject::from(plan.clone()); - let view_plan = ViewProject::new(pipelined_plan, schema.num_cols(), schema.num_private_cols()); - collect_table_update_for_view(&[view_plan], table_id, (&**table_name).into(), tx, update_type)? - } else { - let pipelined_plan = PipelinedProject::from(plan.clone()); - collect_table_update(&[pipelined_plan], table_id, (&**table_name).into(), tx, update_type)? + match plan.return_table() { + Some(schema) => { + let pipelined_plan = PipelinedProject::from(plan.clone()); + let view_plan = + ViewProject::new(pipelined_plan, schema.num_cols(), schema.num_private_cols()); + collect_table_update_for_view( + &[view_plan], + table_id, + (&**table_name).into(), + tx, + update_type, + )? + } + _ => { + let pipelined_plan = PipelinedProject::from(plan.clone()); + collect_table_update(&[pipelined_plan], table_id, (&**table_name).into(), tx, update_type)? + } } } else { let pipelined_plan = PipelinedProject::from(plan.clone()); diff --git a/crates/core/src/subscription/module_subscription_actor.rs b/crates/core/src/subscription/module_subscription_actor.rs index 8238ba29288..b471bba25b0 100644 --- a/crates/core/src/subscription/module_subscription_actor.rs +++ b/crates/core/src/subscription/module_subscription_actor.rs @@ -202,7 +202,7 @@ type FullSubscriptionUpdate = FormatSwitch, ws:: /// A utility for sending an error message to a client and returning early macro_rules! return_on_err { - ($expr:expr, $handler:expr, $metrics:expr) => { + ($expr:expr_2021, $handler:expr_2021, $metrics:expr_2021) => { match $expr { Ok(val) => val, Err(e) => { @@ -216,7 +216,7 @@ macro_rules! return_on_err { /// A utility for sending an error message to a client and returning early macro_rules! return_on_err_with_sql { - ($expr:expr, $sql:expr, $handler:expr) => { + ($expr:expr_2021, $sql:expr_2021, $handler:expr_2021) => { match $expr.map_err(|err| DBError::WithSql { sql: $sql.into(), error: Box::new(DBError::Other(err.into())), @@ -728,20 +728,26 @@ impl ModuleSubscriptions { let mut new_queries = 0; for (sql, hash, hash_with_param) in query_hashes { - if let Some(unit) = guard.query(&hash) { - plans.push(unit); - } else if let Some(unit) = guard.query(&hash_with_param) { - plans.push(unit); - } else { - plans.push(Arc::new( - compile_query_with_hashes(&auth, &*mut_tx, sql, hash, hash_with_param).map_err(|err| { - DBError::WithSql { - error: Box::new(DBError::Other(err.into())), - sql: sql.into(), - } - })?, - )); - new_queries += 1; + match guard.query(&hash) { + Some(unit) => { + plans.push(unit); + } + _ => match guard.query(&hash_with_param) { + Some(unit) => { + plans.push(unit); + } + _ => { + plans.push(Arc::new( + compile_query_with_hashes(&auth, &*mut_tx, sql, hash, hash_with_param).map_err(|err| { + DBError::WithSql { + error: Box::new(DBError::Other(err.into())), + sql: sql.into(), + } + })?, + )); + new_queries += 1; + } + }, } } diff --git a/crates/core/src/subscription/module_subscription_manager.rs b/crates/core/src/subscription/module_subscription_manager.rs index 05ce5a2bc28..c242d79b305 100644 --- a/crates/core/src/subscription/module_subscription_manager.rs +++ b/crates/core/src/subscription/module_subscription_manager.rs @@ -88,7 +88,7 @@ impl Plan { } /// Returns the index ids from which this subscription reads - pub fn index_ids(&self) -> impl Iterator { + pub fn index_ids(&self) -> impl Iterator + use<> { self.plans .iter() .flat_map(|plan| plan.index_ids()) @@ -106,7 +106,7 @@ impl Plan { } /// Return the search arguments for this query - fn search_args(&self) -> impl Iterator { + fn search_args(&self) -> impl Iterator + use<> { let mut args = HashSet::new(); for arg in self .plans @@ -218,7 +218,7 @@ impl QueryState { } /// Return the search arguments for this query - fn search_args(&self) -> impl Iterator { + fn search_args(&self) -> impl Iterator + use<> { self.query.search_args() } } diff --git a/crates/core/src/subscription/subscription.rs b/crates/core/src/subscription/subscription.rs index 975fa2527fc..e658a7a2602 100644 --- a/crates/core/src/subscription/subscription.rs +++ b/crates/core/src/subscription/subscription.rs @@ -895,7 +895,7 @@ mod tests { assert_eq!(virtual_plan.head(), expr.head()); assert_eq!(virtual_plan.query.len(), 1); let incr_join = &virtual_plan.query[0]; - let Query::JoinInner(ref incr_join) = incr_join else { + let Query::JoinInner(incr_join) = incr_join else { panic!("expected an inner semijoin, but got {incr_join:#?}"); }; assert!(incr_join.rhs.source.is_mem_table()); diff --git a/crates/core/src/util/jobs.rs b/crates/core/src/util/jobs.rs index 3ca0e787b36..8dece77b3b2 100644 --- a/crates/core/src/util/jobs.rs +++ b/crates/core/src/util/jobs.rs @@ -235,7 +235,7 @@ impl PinnedCoresExecutorManager { // likely to be repinned, while younger ones are liable to bounce around. // Our use of `swap_remove` above makes this not entirely predictable, however. core_info.jobs.push(stolen); - let (ref mut stolen_core_id, migrate_tx) = self.database_executor_move.get_mut(&stolen).unwrap(); + let (stolen_core_id, migrate_tx) = self.database_executor_move.get_mut(&stolen).unwrap(); *stolen_core_id = freed_core_id; migrate_tx.send_replace(core_info.tokio_runtime.handle().clone()); } diff --git a/crates/data-structures/src/error_stream.rs b/crates/data-structures/src/error_stream.rs index 62fb55e37c9..0e0651308c6 100644 --- a/crates/data-structures/src/error_stream.rs +++ b/crates/data-structures/src/error_stream.rs @@ -459,7 +459,7 @@ impl>>> CollectAllErrors for I /// ``` #[macro_export] macro_rules! expect_error_matching ( - ($result:expr, $expected:pat => $cond:expr) => { + ($result:expr_2021, $expected:pat => $cond:expr_2021) => { let result: &::std::result::Result< _, $crate::error_stream::ErrorStream<_> @@ -480,7 +480,7 @@ macro_rules! expect_error_matching ( } } }; - ($result:expr, $expected:pat) => { + ($result:expr_2021, $expected:pat) => { let result: &::std::result::Result< _, $crate::error_stream::ErrorStream<_> diff --git a/crates/data-structures/src/slim_slice.rs b/crates/data-structures/src/slim_slice.rs index 38fbebef2e7..3276e5b0fa1 100644 --- a/crates/data-structures/src/slim_slice.rs +++ b/crates/data-structures/src/slim_slice.rs @@ -116,7 +116,7 @@ pub fn try_into>>(x: A) -> Result { + ($thing:expr_2021) => { let Ok(_) = u32::try_from($thing.len()) else { return Err(LenTooLong { len: $thing.len(), @@ -256,10 +256,12 @@ impl SlimRawSlice { /// The caller must ensure that `ptr != NULL`. #[inline] const unsafe fn from_len_ptr(len: usize, ptr: *mut T) -> Self { - // SAFETY: caller ensured that `!ptr.is_null()`. - let ptr = NonNull::new_unchecked(ptr); - let len = len as u32; - Self { ptr, len } + unsafe { + // SAFETY: caller ensured that `!ptr.is_null()`. + let ptr = NonNull::new_unchecked(ptr); + let len = len as u32; + Self { ptr, len } + } } } @@ -319,13 +321,15 @@ mod slim_slice_box { #[inline] // Clippy doesn't seem to consider unsafe code here. pub unsafe fn from_boxed_unchecked(boxed: Box<[T]>) -> Self { - let len = boxed.len(); - let ptr = Box::into_raw(boxed) as *mut T; - // SAFETY: `Box`'s ptr was a `NonNull` already. - // and our caller has promised that `boxed.len() <= u32::MAX`. - let raw = SlimRawSlice::from_len_ptr(len, ptr); - let owned = PhantomData; - Self { raw, owned } + unsafe { + let len = boxed.len(); + let ptr = Box::into_raw(boxed) as *mut T; + // SAFETY: `Box`'s ptr was a `NonNull` already. + // and our caller has promised that `boxed.len() <= u32::MAX`. + let raw = SlimRawSlice::from_len_ptr(len, ptr); + let owned = PhantomData; + Self { raw, owned } + } } /// Returns a limited shared slice to this boxed slice. @@ -885,13 +889,15 @@ mod slim_slice { /// /// SAFETY: `slice.len() <= u32::MAX` must hold. pub(super) const unsafe fn from_slice_unchecked(slice: &'a [T]) -> Self { - let len = slice.len(); - let ptr = slice.as_ptr().cast_mut(); - // SAFETY: `&mut [T]` implies that the pointer is non-null. - let raw = SlimRawSlice::from_len_ptr(len, ptr); - // SAFETY: Our length invariant is satisfied by the caller. - let covariant = PhantomData; - Self { raw, covariant } + unsafe { + let len = slice.len(); + let ptr = slice.as_ptr().cast_mut(); + // SAFETY: `&mut [T]` implies that the pointer is non-null. + let raw = SlimRawSlice::from_len_ptr(len, ptr); + // SAFETY: Our length invariant is satisfied by the caller. + let covariant = PhantomData; + Self { raw, covariant } + } } } @@ -1067,12 +1073,14 @@ impl<'a, T> SlimSliceMut<'a, T> { /// SAFETY: `slice.len() <= u32::MAX` must hold. #[inline] unsafe fn from_slice_unchecked(slice: &'a mut [T]) -> Self { - // SAFETY: `&mut [T]` implies that the pointer is non-null. - let raw = SlimRawSlice::from_len_ptr(slice.len(), slice.as_mut_ptr()); - // SAFETY: Our invariants are satisfied by the caller - // and that `&mut [T]` implies exclusive access to the data. - let invariant = PhantomData; - Self { raw, invariant } + unsafe { + // SAFETY: `&mut [T]` implies that the pointer is non-null. + let raw = SlimRawSlice::from_len_ptr(slice.len(), slice.as_mut_ptr()); + // SAFETY: Our invariants are satisfied by the caller + // and that `&mut [T]` implies exclusive access to the data. + let invariant = PhantomData; + Self { raw, invariant } + } } } diff --git a/crates/datastore/src/locking_tx_datastore/committed_state.rs b/crates/datastore/src/locking_tx_datastore/committed_state.rs index d3b98399bff..2a50f2a91ad 100644 --- a/crates/datastore/src/locking_tx_datastore/committed_state.rs +++ b/crates/datastore/src/locking_tx_datastore/committed_state.rs @@ -90,7 +90,7 @@ pub struct CommittedState { impl CommittedState { /// Returns the views that perform a full scan of this table - pub(super) fn views_for_table_scan(&self, table_id: &TableId) -> impl Iterator { + pub(super) fn views_for_table_scan(&self, table_id: &TableId) -> impl Iterator + use<'_> { self.read_sets.views_for_table_scan(table_id) } @@ -99,7 +99,7 @@ impl CommittedState { &'a self, table_id: &TableId, row_ref: RowRef<'a>, - ) -> impl Iterator { + ) -> impl Iterator + use<'a> { self.read_sets.views_for_index_seek(table_id, row_ref) } } diff --git a/crates/datastore/src/locking_tx_datastore/delete_table.rs b/crates/datastore/src/locking_tx_datastore/delete_table.rs index 517e525afbc..74b6eb66041 100644 --- a/crates/datastore/src/locking_tx_datastore/delete_table.rs +++ b/crates/datastore/src/locking_tx_datastore/delete_table.rs @@ -195,7 +195,7 @@ mod test { self.check_state(); dt } - fn iter(&self) -> impl Iterator { + fn iter(&self) -> impl Iterator + use<> { let dt = self.dt.iter().collect::>(); let bs = self.bs.iter().copied().collect::>(); assert_eq!(dt, bs); diff --git a/crates/datastore/src/locking_tx_datastore/mut_tx.rs b/crates/datastore/src/locking_tx_datastore/mut_tx.rs index 3c31964a8cd..16872c2879c 100644 --- a/crates/datastore/src/locking_tx_datastore/mut_tx.rs +++ b/crates/datastore/src/locking_tx_datastore/mut_tx.rs @@ -94,7 +94,7 @@ impl MemoryUsage for ViewReadSets { impl ViewReadSets { /// Returns the views that perform a full scan of this table - pub fn views_for_table_scan(&self, table_id: &TableId) -> impl Iterator { + pub fn views_for_table_scan(&self, table_id: &TableId) -> impl Iterator + use<'_> { self.tables .get(table_id) .into_iter() @@ -132,7 +132,7 @@ impl ViewReadSets { &'a self, table_id: &TableId, row_ptr: RowRef<'a>, - ) -> impl Iterator { + ) -> impl Iterator + use<'a> { self.tables .get(table_id) .into_iter() @@ -2337,7 +2337,7 @@ impl MutTxId { identity: identity.into(), connection_id: connection_id.into(), }; - if let Some(ptr) = self + match self .iter_by_col_eq( ST_CLIENT_ID, // TODO(perf, minor, centril): consider a `const_col_list([x, ..])` @@ -2348,9 +2348,10 @@ impl MutTxId { .next() .map(|row| row.pointer()) { - self.delete(ST_CLIENT_ID, ptr).map(drop)? - } else { - log::error!("[{database_identity}]: delete_st_client: attempting to delete client ({identity}, {connection_id}), but no st_client row for that client is resident"); + Some(ptr) => self.delete(ST_CLIENT_ID, ptr).map(drop)?, + _ => { + log::error!("[{database_identity}]: delete_st_client: attempting to delete client ({identity}, {connection_id}), but no st_client row for that client is resident"); + } } self.delete_st_client_credentials(database_identity, connection_id) } @@ -2686,7 +2687,7 @@ impl MutTxId { // This macros can be thought of as a `throw $e` within `'error`. // TODO(centril): Get rid of this once we have stable `try` blocks or polonius. macro_rules! throw { - ($e:expr) => { + ($e:expr_2021) => { break 'error $e.into() }; } @@ -2725,7 +2726,7 @@ impl MutTxId { commit_table.check_unique_constraints( tx_row_ref, // Don't check this index since we'll do a 1-1 old/new replacement. - |ixs| ixs.filter(|(&id, _)| id != index_id), + |ixs| ixs.filter(|&(&id, _)| id != index_id), is_deleted, ) } { diff --git a/crates/datastore/src/system_tables.rs b/crates/datastore/src/system_tables.rs index 107dfb5b1b2..97cf83ba7b7 100644 --- a/crates/datastore/src/system_tables.rs +++ b/crates/datastore/src/system_tables.rs @@ -186,7 +186,7 @@ pub(crate) const ST_VIEW_SUB_IDX: usize = 14; pub(crate) const ST_VIEW_ARG_IDX: usize = 15; macro_rules! st_fields_enum { - ($(#[$attr:meta])* enum $ty_name:ident { $($name:expr, $var:ident = $discr:expr,)* }) => { + ($(#[$attr:meta])* enum $ty_name:ident { $($name:expr_2021, $var:ident = $discr:expr_2021,)* }) => { #[derive(Copy, Clone, Debug)] $(#[$attr])* pub enum $ty_name { diff --git a/crates/durability/src/imp/local.rs b/crates/durability/src/imp/local.rs index c6eb3ff693c..016281d160c 100644 --- a/crates/durability/src/imp/local.rs +++ b/crates/durability/src/imp/local.rs @@ -135,7 +135,7 @@ impl Local { } /// Obtain an iterator over the [`Commit`]s in the underlying log. - pub fn commits_from(&self, offset: TxOffset) -> impl Iterator> { + pub fn commits_from(&self, offset: TxOffset) -> impl Iterator> + use { self.clog.commits_from(offset).map_ok(Commit::from) } @@ -197,8 +197,11 @@ impl PersisterTask { // require `spawn_blocking`. if self.max_records_in_commit.get() == 1 { self.flush_append(txdata, true).await; - } else if let Err(retry) = self.clog.append(txdata) { - self.flush_append(retry, false).await + } else { + match self.clog.append(txdata) { + Err(retry) => self.flush_append(retry, false).await, + _ => {} + } } trace!("appended txdata"); diff --git a/crates/fs-utils/src/compression.rs b/crates/fs-utils/src/compression.rs index 8e72fcbe76d..3eff2f879df 100644 --- a/crates/fs-utils/src/compression.rs +++ b/crates/fs-utils/src/compression.rs @@ -235,7 +235,7 @@ mod async_impls { } } macro_rules! forward_reader { - ($self:ident.$method:ident($($args:expr),*)) => { + ($self:ident.$method:ident($($args:expr_2021),*)) => { match $self.get_mut() { AsyncCompressReader::None(r) => Pin::new(r).$method($($args),*), AsyncCompressReader::Zstd(r) => Pin::new(r).$method($($args),*), diff --git a/crates/lib/tests/serde.rs b/crates/lib/tests/serde.rs index dfc6eef0957..3bb4ac849c3 100644 --- a/crates/lib/tests/serde.rs +++ b/crates/lib/tests/serde.rs @@ -6,7 +6,7 @@ use spacetimedb_sats::algebraic_value::ser::value_serialize; use spacetimedb_sats::{satn::Satn, GroundSpacetimeType as _, SumTypeVariant, Typespace, WithTypespace}; macro_rules! de_json_snapshot { - ($schema:expr, $json:expr) => { + ($schema:expr_2021, $json:expr_2021) => { let (schema, json) = (&$schema, &$json); let value = de_json(schema, json).unwrap(); let value = WithTypespace::new(&EMPTY_TYPESPACE, schema) diff --git a/crates/metrics/src/typed_prometheus.rs b/crates/metrics/src/typed_prometheus.rs index 0a8eafe484a..ad4b96a61bb 100644 --- a/crates/metrics/src/typed_prometheus.rs +++ b/crates/metrics/src/typed_prometheus.rs @@ -3,7 +3,7 @@ use prometheus::core::{Metric, MetricVec, MetricVecBuilder}; #[macro_export] macro_rules! metrics_group { ($(#[$attr:meta])* $type_vis:vis struct $type_name:ident { - $(#[name = $name:ident] #[help = $help:expr] $(#[labels($($labels:ident: $labelty:ty),*)])? $(#[buckets($($bucket:literal),*)])? $vis:vis $field:ident: $ty:ident,)* + $(#[name = $name:ident] #[help = $help:expr_2021] $(#[labels($($labels:ident: $labelty:ty),*)])? $(#[buckets($($bucket:literal),*)])? $vis:vis $field:ident: $ty:ident,)* }) => { $(#[$attr])* $type_vis struct $type_name { @@ -58,10 +58,10 @@ pub use {itertools, paste::paste}; #[macro_export] macro_rules! make_collector { - ($ty:ty, $name:expr, $help:expr $(,)?) => { + ($ty:ty, $name:expr_2021, $help:expr_2021 $(,)?) => { <$ty>::with_opts(prometheus::Opts::new($name, $help).into()).unwrap() }; - ($ty:ty, $name:expr, $help:expr, $labels:expr $(,)?) => { + ($ty:ty, $name:expr_2021, $help:expr_2021, $labels:expr_2021 $(,)?) => { <$ty>::new(prometheus::Opts::new($name, $help).into(), $labels).unwrap() }; } diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index bd41c0bc629..3ae55eed685 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -282,9 +282,11 @@ mod tests { } fn maybe_set_var(var: &str, val: Option>) { if let Some(val) = val { - std::env::set_var(var, val); + // TODO: Audit that the environment access only happens in single-threaded code. + unsafe { std::env::set_var(var, val) }; } else { - std::env::remove_var(var); + // TODO: Audit that the environment access only happens in single-threaded code. + unsafe { std::env::remove_var(var) }; } } pub(super) fn with_vars(vars: [(&str, Option<&str>); N], f: impl FnOnce() -> R) -> R { diff --git a/crates/pg/src/pg_server.rs b/crates/pg/src/pg_server.rs index 860df156f25..6195df28732 100644 --- a/crates/pg/src/pg_server.rs +++ b/crates/pg/src/pg_server.rs @@ -246,10 +246,13 @@ impl { + log::info!("PG: Connecting to database: {database}, by {application_name}",); + } + _ => { + log::info!("PG: Connecting to database: {database}"); + } } let name = database::NameOrIdentity::Name(DatabaseName(database.clone())); diff --git a/crates/primitives/src/col_list.rs b/crates/primitives/src/col_list.rs index b763cfeafad..a49027d59f0 100644 --- a/crates/primitives/src/col_list.rs +++ b/crates/primitives/src/col_list.rs @@ -23,7 +23,7 @@ use itertools::Itertools; /// Mostly provided for testing. #[macro_export] macro_rules! col_list { - ($($elem:expr),* $(,)?) => {{ + ($($elem:expr_2021),* $(,)?) => {{ $crate::ColList::from([$($elem),*]) }}; } @@ -724,7 +724,7 @@ impl Clone for ColListVec { fn is_sorted_and_deduped(data: &[ColId]) -> bool { match data { [] => true, - [mut prev, rest @ ..] => !rest.iter().any(|elem| { + &[mut prev, ref rest @ ..] => !rest.iter().any(|elem| { let bad = prev >= *elem; prev = *elem; bad diff --git a/crates/sats/src/de.rs b/crates/sats/src/de.rs index 5b5b0b118c5..8ef760f5a13 100644 --- a/crates/sats/src/de.rs +++ b/crates/sats/src/de.rs @@ -189,10 +189,9 @@ pub trait Error: Sized { ProductKind::Normal => "field", ProductKind::ReducerArgs => "reducer argument", }; - if let Some(one_of) = one_of_names(|| expected.field_names()) { - Self::custom(format_args!("unknown {el_ty} `{field_name}`, expected {one_of}")) - } else { - Self::custom(format_args!("unknown {el_ty} `{field_name}`, there are no {el_ty}s")) + match one_of_names(|| expected.field_names()) { + Some(one_of) => Self::custom(format_args!("unknown {el_ty} `{field_name}`, expected {one_of}")), + _ => Self::custom(format_args!("unknown {el_ty} `{field_name}`, there are no {el_ty}s")), } } @@ -206,10 +205,9 @@ pub trait Error: Sized { /// The `name` is not that of a variant of the sum type. fn unknown_variant_name<'de, T: VariantVisitor<'de>>(name: &str, expected: &T) -> Self { - if let Some(one_of) = one_of_names(|| expected.variant_names().map(Some)) { - Self::custom(format_args!("unknown variant `{name}`, expected {one_of}",)) - } else { - Self::custom(format_args!("unknown variant `{name}`, there are no variants")) + match one_of_names(|| expected.variant_names().map(Some)) { + Some(one_of) => Self::custom(format_args!("unknown variant `{name}`, expected {one_of}",)), + _ => Self::custom(format_args!("unknown variant `{name}`, there are no variants")), } } } diff --git a/crates/sats/src/de/impls.rs b/crates/sats/src/de/impls.rs index d0c9a92c23d..79483f191c9 100644 --- a/crates/sats/src/de/impls.rs +++ b/crates/sats/src/de/impls.rs @@ -29,7 +29,7 @@ use std::{borrow::Cow, rc::Rc, sync::Arc}; /// ``` #[macro_export] macro_rules! impl_deserialize { - ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, $de:ident => $body:expr) => { + ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, $de:ident => $body:expr_2021) => { impl<'de, $($generics)*> $crate::de::Deserialize<'de> for $typ { fn deserialize>($de: D) -> Result { $body } } diff --git a/crates/sats/src/de/serde.rs b/crates/sats/src/de/serde.rs index fe928de5712..ea322cc15b3 100644 --- a/crates/sats/src/de/serde.rs +++ b/crates/sats/src/de/serde.rs @@ -206,10 +206,11 @@ impl<'de, V: super::FieldNameVisitor<'de>> serde::Visitor<'de> for FieldNameVisi type Value = V::Output; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { - if let Some(one_of) = super::one_of_names(|| self.visitor.field_names()) { - write!(f, "a tuple field ({one_of})") - } else { - f.write_str("a tuple field, but there are no fields") + match super::one_of_names(|| self.visitor.field_names()) { + Some(one_of) => { + write!(f, "a tuple field ({one_of})") + } + _ => f.write_str("a tuple field, but there are no fields"), } } diff --git a/crates/sats/src/product_value.rs b/crates/sats/src/product_value.rs index 25c3576e58e..c212fa63a13 100644 --- a/crates/sats/src/product_value.rs +++ b/crates/sats/src/product_value.rs @@ -18,7 +18,7 @@ pub struct ProductValue { /// Repeat notation from `vec![x; n]` is not supported. #[macro_export] macro_rules! product { - [$($elems:expr),*$(,)?] => { + [$($elems:expr_2021),*$(,)?] => { $crate::ProductValue { elements: [$($crate::AlgebraicValue::from($elems)),*].into(), } @@ -189,7 +189,7 @@ impl ProductValue { } impl<'a> ValueWithType<'a, ProductValue> { - pub fn elements(&self) -> impl ExactSizeIterator> { + pub fn elements(&self) -> impl ExactSizeIterator> + use<'a> { self.ty_s().with_values(self.value()) } } diff --git a/crates/sats/src/ser/impls.rs b/crates/sats/src/ser/impls.rs index 9baac393dff..b89067e02e1 100644 --- a/crates/sats/src/ser/impls.rs +++ b/crates/sats/src/ser/impls.rs @@ -29,7 +29,7 @@ use std::sync::Arc; /// ``` #[macro_export] macro_rules! impl_serialize { - ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, ($self:ident, $ser:ident) => $body:expr) => { + ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, ($self:ident, $ser:ident) => $body:expr_2021) => { impl<$($generics)*> $crate::ser::Serialize for $typ $(where $($wc)*)? { fn serialize($self: &Self, $ser: S) -> Result { $body diff --git a/crates/sats/src/typespace.rs b/crates/sats/src/typespace.rs index f7d0978d660..41941248406 100644 --- a/crates/sats/src/typespace.rs +++ b/crates/sats/src/typespace.rs @@ -352,7 +352,7 @@ pub trait TypespaceBuilder { /// ``` #[macro_export] macro_rules! impl_st { - ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $stty:expr) => { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $stty:expr_2021) => { impl<$($generic_wrapped $($other_generics)*)?> $crate::GroundSpacetimeType for $rty $(where $generic_wrapped: $crate::GroundSpacetimeType)? { @@ -363,7 +363,7 @@ macro_rules! impl_st { impl_st!([ $($generic $($other_generics)*)? ] $rty, _ts => $stty); }; - ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $ts:ident => $stty:expr) => { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $ts:ident => $stty:expr_2021) => { impl<$($generic_wrapped $($other_generics)*)?> $crate::SpacetimeType for $rty $(where $generic_wrapped: $crate::SpacetimeType)? { diff --git a/crates/schema/src/schema.rs b/crates/schema/src/schema.rs index 51826292454..f9c409daff3 100644 --- a/crates/schema/src/schema.rs +++ b/crates/schema/src/schema.rs @@ -685,7 +685,7 @@ fn find_remove(vec: &mut Vec, predicate: impl Fn(&T) -> bool) -> Option /// Like `assert_eq!` for `anyhow`, but `$msg` is just a string, not a format string. macro_rules! ensure_eq { - ($a:expr, $b:expr, $msg:expr) => { + ($a:expr_2021, $b:expr_2021, $msg:expr_2021) => { if $a != $b { anyhow::bail!( "{0}: expected {1} == {2}:\n {1}: {3:?}\n {2}: {4:?}", diff --git a/crates/snapshot/src/lib.rs b/crates/snapshot/src/lib.rs index e7ce7ed8b3f..5452c8a448d 100644 --- a/crates/snapshot/src/lib.rs +++ b/crates/snapshot/src/lib.rs @@ -948,7 +948,7 @@ impl SnapshotRepository { .max()) } - pub fn all_snapshots(&self) -> Result, SnapshotError> { + pub fn all_snapshots(&self) -> Result + use<>, SnapshotError> { Ok(self .root // Item = Result @@ -978,7 +978,9 @@ impl SnapshotRepository { } /// Return an interator of [`ArchivedSnapshotDirPath`] for all the archived snapshot directories on disk - pub fn all_archived_snapshots(&self) -> Result, SnapshotError> { + pub fn all_archived_snapshots( + &self, + ) -> Result + use<>, SnapshotError> { Ok(self .root // Item = Result diff --git a/crates/snapshot/src/remote.rs b/crates/snapshot/src/remote.rs index 28e8170b325..ba3c6bb8707 100644 --- a/crates/snapshot/src/remote.rs +++ b/crates/snapshot/src/remote.rs @@ -757,7 +757,7 @@ impl BufPool { /// /// The buffer is returned to the pool when the returned [`ScopeGuard`] /// goes out of scope. - pub fn get(&self) -> ScopeGuard { + pub fn get(&self) -> ScopeGuard> { let this = self.clone(); scopeguard::guard( this.inner.pop().unwrap_or_else(|| BytesMut::with_capacity(PAGE_SIZE)), diff --git a/crates/standalone/src/main.rs b/crates/standalone/src/main.rs index ca266f27d76..296bb17031c 100644 --- a/crates/standalone/src/main.rs +++ b/crates/standalone/src/main.rs @@ -56,7 +56,7 @@ static GLOBAL: Jemalloc = Jemalloc; // We export this symbol so that the jemalloc library can find it. // See https://github.com/polarsignals/rust-jemalloc-pprof?tab=readme-ov-file#usage #[allow(non_upper_case_globals)] -#[export_name = "_rjem_malloc_conf"] +#[unsafe(export_name = "_rjem_malloc_conf")] pub static _rjem_malloc_conf: &[u8] = b"prof:true,prof_active:false,lg_prof_sample:19\0"; fn main() -> anyhow::Result<()> { diff --git a/crates/subscription/src/lib.rs b/crates/subscription/src/lib.rs index d0f4668459b..055904ccd9c 100644 --- a/crates/subscription/src/lib.rs +++ b/crates/subscription/src/lib.rs @@ -32,7 +32,7 @@ struct Fragments { impl Fragments { /// Returns the index ids from which this fragment reads. - fn index_ids(&self) -> impl Iterator { + fn index_ids(&self) -> impl Iterator + use<> { let mut index_ids = HashSet::new(); for plan in self.insert_plans.iter().chain(self.delete_plans.iter()) { plan.visit(&mut |plan| match plan { @@ -419,7 +419,7 @@ impl SubscriptionPlan { } /// From which indexes does this plan read? - pub fn index_ids(&self) -> impl Iterator { + pub fn index_ids(&self) -> impl Iterator + use<> { self.fragments.index_ids() } diff --git a/crates/table/src/page.rs b/crates/table/src/page.rs index 0d540b2d1bf..49ddbc6668d 100644 --- a/crates/table/src/page.rs +++ b/crates/table/src/page.rs @@ -533,7 +533,7 @@ impl<'page> VarView<'page> { /// /// This has to be done due to `page.row_data.split_at_mut(last_fixed)`. #[inline(always)] - fn adjuster(&self) -> impl FnOnce(PageOffset) -> PageOffset { + fn adjuster(&self) -> impl FnOnce(PageOffset) -> PageOffset + use<> { let lf = self.last_fixed; move |offset| offset - lf } diff --git a/crates/table/src/read_column.rs b/crates/table/src/read_column.rs index 1cef02b2ff0..30c7865e2d7 100644 --- a/crates/table/src/read_column.rs +++ b/crates/table/src/read_column.rs @@ -485,7 +485,7 @@ mod test { /// e.g. a Rust integer, /// and asserts that the extracted value is as expected. macro_rules! test_read_column_primitive { - ($name:ident { $algebraic_type:expr => $rust_type:ty = $val:expr }) => { + ($name:ident { $algebraic_type:expr_2021 => $rust_type:ty = $val:expr_2021 }) => { #[test] fn $name() { let pool = PagePool::new_for_test(); @@ -500,7 +500,7 @@ mod test { }; - ($($name:ident { $algebraic_type:expr => $rust_type:ty = $val:expr };)*) => { + ($($name:ident { $algebraic_type:expr_2021 => $rust_type:ty = $val:expr_2021 };)*) => { $(test_read_column_primitive! { $name { $algebraic_type => $rust_type = $val } })* diff --git a/crates/table/src/util.rs b/crates/table/src/util.rs index ca74c4167e8..1a737b569e6 100644 --- a/crates/table/src/util.rs +++ b/crates/table/src/util.rs @@ -16,7 +16,7 @@ pub const fn range_move(r: Range, by: usize) -> Range { /// ``` #[macro_export] macro_rules! static_assert_size { - ($ty:ty, $size:expr) => { + ($ty:ty, $size:expr_2021) => { const _: [(); $size] = [(); ::core::mem::size_of::<$ty>()]; }; } @@ -30,7 +30,7 @@ macro_rules! static_assert_size { /// ``` #[macro_export] macro_rules! static_assert_align { - ($ty:ty, $align:expr) => { + ($ty:ty, $align:expr_2021) => { const _: [(); $align] = [(); ::core::mem::align_of::<$ty>()]; }; } diff --git a/modules/keynote-benchmarks/src/lib.rs b/modules/keynote-benchmarks/src/lib.rs index e7a8c47feca..c5189cff32a 100644 --- a/modules/keynote-benchmarks/src/lib.rs +++ b/modules/keynote-benchmarks/src/lib.rs @@ -42,8 +42,8 @@ fn init(ctx: &ReducerContext) { let db = ctx.db(); let mut rng = ctx.rng(); for id in 0..1_000_000 { - let (x, y, z) = rng.gen(); - let (dx, dy, dz) = rng.gen(); + let (x, y, z) = rng.r#gen(); + let (dx, dy, dz) = rng.r#gen(); db.position().insert(Position { id, x, y, z }); db.velocity().insert(Velocity { id, dx, dy, dz }); } diff --git a/sdks/rust/src/client_cache.rs b/sdks/rust/src/client_cache.rs index 4a5bbfc312c..c28aaac92bc 100644 --- a/sdks/rust/src/client_cache.rs +++ b/sdks/rust/src/client_cache.rs @@ -405,7 +405,7 @@ impl TableHandle { } /// Called by the autogenerated implementation of the [`crate::Table`] method of the same name. - pub fn iter(&self) -> impl Iterator { + pub fn iter(&self) -> impl Iterator + use { self.with_table_cache(|table| table.entries.values().map(|e| e.row.clone()).collect::>()) .into_iter() } diff --git a/sdks/rust/src/subscription.rs b/sdks/rust/src/subscription.rs index 93bf09b667b..61fba6528e4 100644 --- a/sdks/rust/src/subscription.rs +++ b/sdks/rust/src/subscription.rs @@ -125,10 +125,13 @@ impl SubscriptionManager { // This means that the subscription was cancelled before it was started. // We skip sending the subscription start message. self.new_subscriptions.remove(&sub_id); - if let Some(callback) = sub.on_ended() { - return PendingUnsubscribeResult::RunCallback(callback); - } else { - return PendingUnsubscribeResult::DoNothing; + match sub.on_ended() { + Some(callback) => { + return PendingUnsubscribeResult::RunCallback(callback); + } + _ => { + return PendingUnsubscribeResult::DoNothing; + } } } if sub.is_ended() { diff --git a/sdks/rust/src/websocket.rs b/sdks/rust/src/websocket.rs index e0372a53dbb..63eefb7a3b7 100644 --- a/sdks/rust/src/websocket.rs +++ b/sdks/rust/src/websocket.rs @@ -214,7 +214,7 @@ fn request_insert_auth_header(req: &mut http::Request<()>, token: Option<&str>) /// /// Could be trivially written as a function, but macro-ifying it preserves the source location of the log. macro_rules! maybe_log_error { - ($cause:expr, $res:expr) => { + ($cause:expr_2021, $res:expr_2021) => { if let Err(e) = $res { log::warn!("{}: {:?}", $cause, e); } diff --git a/sdks/rust/tests/connect_disconnect_client/src/main.rs b/sdks/rust/tests/connect_disconnect_client/src/main.rs index 67bb8322312..5d6d312a947 100644 --- a/sdks/rust/tests/connect_disconnect_client/src/main.rs +++ b/sdks/rust/tests/connect_disconnect_client/src/main.rs @@ -33,10 +33,13 @@ fn main() { .on_applied(move |ctx| { let check = || { anyhow::ensure!(ctx.db.connected().count() == 1); - if let Some(_row) = ctx.db.connected().iter().next() { - // TODO: anyhow::ensure!(row.identity == ctx.identity().unwrap()); - } else { - anyhow::bail!("Expected one row but Connected::iter().next() returned None"); + match ctx.db.connected().iter().next() { + Some(_row) => { + // TODO: anyhow::ensure!(row.identity == ctx.identity().unwrap()); + } + _ => { + anyhow::bail!("Expected one row but Connected::iter().next() returned None"); + } } Ok(()) }; @@ -85,10 +88,13 @@ fn main() { .on_applied(move |ctx| { let check = || { anyhow::ensure!(ctx.db.disconnected().count() == 1); - if let Some(_row) = ctx.db.disconnected().iter().next() { - // TODO: anyhow::ensure!(row.identity == ctx.identity().unwrap()); - } else { - anyhow::bail!("Expected one row but Disconnected::iter().next() returned None"); + match ctx.db.disconnected().iter().next() { + Some(_row) => { + // TODO: anyhow::ensure!(row.identity == ctx.identity().unwrap()); + } + _ => { + anyhow::bail!("Expected one row but Disconnected::iter().next() returned None"); + } } Ok(()) }; diff --git a/sdks/rust/tests/test-client/src/main.rs b/sdks/rust/tests/test-client/src/main.rs index fe30038ff59..e7aa131c8c4 100644 --- a/sdks/rust/tests/test-client/src/main.rs +++ b/sdks/rust/tests/test-client/src/main.rs @@ -48,7 +48,7 @@ fn exit_on_panic() { } macro_rules! assert_eq_or_bail { - ($expected:expr, $found:expr) => {{ + ($expected:expr_2021, $found:expr_2021) => {{ let expected = &$expected; let found = &$found; if expected != found { From e8068f248e352540e67a4b845f93117769049ef2 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 13:04:40 -0600 Subject: [PATCH 2/7] Switch crates over to Rust 2024 Keep rustfmt.toml style_edition on 2021 --- .rustfmt.toml | 2 +- Cargo.toml | 2 +- crates/bindings-typescript/test-app/server/Cargo.toml | 2 +- .../bindings-typescript/test-react-router-app/server/Cargo.toml | 2 +- crates/cli/templates/basic-rust/client/Cargo.toml | 2 +- crates/cli/templates/basic-rust/server/Cargo.toml | 2 +- demo/Blackholio/server-rust/Cargo.toml | 2 +- sdks/unreal/Cargo.toml | 2 +- tools/gen-bindings/Cargo.toml | 2 +- tools/generate-client-api/Cargo.toml | 2 +- tools/license-check/Cargo.toml | 2 +- tools/replace-spacetimedb/Cargo.toml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 01b441c0efd..060859441e8 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,2 +1,2 @@ max_width = 120 -edition = "2021" +style_edition = "2021" diff --git a/Cargo.toml b/Cargo.toml index 30d643f6425..8730890b2a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,7 +97,7 @@ debug = true [workspace.package] version = "1.11.0" -edition = "2021" +edition = "2024" # update rust-toolchain.toml too! rust-version = "1.90.0" diff --git a/crates/bindings-typescript/test-app/server/Cargo.toml b/crates/bindings-typescript/test-app/server/Cargo.toml index f47518024d9..c61fe890b87 100644 --- a/crates/bindings-typescript/test-app/server/Cargo.toml +++ b/crates/bindings-typescript/test-app/server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "typescript-test-app" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/bindings-typescript/test-react-router-app/server/Cargo.toml b/crates/bindings-typescript/test-react-router-app/server/Cargo.toml index 2bd6ae607e2..99797536040 100644 --- a/crates/bindings-typescript/test-react-router-app/server/Cargo.toml +++ b/crates/bindings-typescript/test-react-router-app/server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "typescript-test-react-router-app" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/cli/templates/basic-rust/client/Cargo.toml b/crates/cli/templates/basic-rust/client/Cargo.toml index 5d1fabdc702..902a2dfda7f 100644 --- a/crates/cli/templates/basic-rust/client/Cargo.toml +++ b/crates/cli/templates/basic-rust/client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spacetimedb-client" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] spacetimedb-sdk = "1.11.*" diff --git a/crates/cli/templates/basic-rust/server/Cargo.toml b/crates/cli/templates/basic-rust/server/Cargo.toml index 271b883365e..ca98a1d34aa 100644 --- a/crates/cli/templates/basic-rust/server/Cargo.toml +++ b/crates/cli/templates/basic-rust/server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spacetime-module" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/demo/Blackholio/server-rust/Cargo.toml b/demo/Blackholio/server-rust/Cargo.toml index 1acb7c7f811..d8217e1ffe1 100644 --- a/demo/Blackholio/server-rust/Cargo.toml +++ b/demo/Blackholio/server-rust/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "spacetime-module" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/sdks/unreal/Cargo.toml b/sdks/unreal/Cargo.toml index cfee1f430d2..4a22316d11b 100644 --- a/sdks/unreal/Cargo.toml +++ b/sdks/unreal/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sdk-unreal-test-harness" #version = "0.1.0" -#edition = "2021" +#edition = "2024" #publish = false version.workspace = true diff --git a/tools/gen-bindings/Cargo.toml b/tools/gen-bindings/Cargo.toml index 343564fba45..c0aec0d512c 100644 --- a/tools/gen-bindings/Cargo.toml +++ b/tools/gen-bindings/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gen-bindings" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow = "1" diff --git a/tools/generate-client-api/Cargo.toml b/tools/generate-client-api/Cargo.toml index e6645aa15b0..c73b4607300 100644 --- a/tools/generate-client-api/Cargo.toml +++ b/tools/generate-client-api/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "generate-client-api" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] tempfile = "3" diff --git a/tools/license-check/Cargo.toml b/tools/license-check/Cargo.toml index b8485f164e7..b38b103e95a 100644 --- a/tools/license-check/Cargo.toml +++ b/tools/license-check/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "check-license-symlinks" version = "0.1.0" -edition = "2021" +edition = "2024" [[bin]] name = "license-check" diff --git a/tools/replace-spacetimedb/Cargo.toml b/tools/replace-spacetimedb/Cargo.toml index 9cb80ef0282..ef4fc11e572 100644 --- a/tools/replace-spacetimedb/Cargo.toml +++ b/tools/replace-spacetimedb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "replace-spacetimedb" version = "0.1.0" -edition = "2021" +edition = "2024" [lib] name = "replace_spacetimedb" From 5167b6ab6809b00e8e5edb0b07128f6f26713138 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 13:05:27 -0600 Subject: [PATCH 3/7] Switch expr_2021 macro fragment back to expr --- crates/bindings-macro/src/util.rs | 6 +++--- crates/bindings/src/http.rs | 2 +- crates/bindings/src/lib.rs | 4 ++-- crates/bindings/src/query_builder/expr.rs | 2 +- crates/cli/src/tasks/csharp.rs | 2 +- crates/codegen/examples/regen-csharp-moduledef.rs | 2 +- crates/codegen/examples/regen-typescript-moduledef.rs | 2 +- crates/codegen/tests/codegen.rs | 2 +- crates/core/src/db/update.rs | 2 +- crates/core/src/host/v8/builtins/mod.rs | 2 +- crates/core/src/host/v8/from_value.rs | 4 ++-- crates/core/src/host/v8/syscall/v1.rs | 2 +- crates/core/src/host/v8/to_value.rs | 2 +- crates/core/src/sql/ast.rs | 4 ++-- .../core/src/subscription/module_subscription_actor.rs | 4 ++-- crates/data-structures/src/error_stream.rs | 4 ++-- crates/data-structures/src/slim_slice.rs | 2 +- crates/datastore/src/locking_tx_datastore/mut_tx.rs | 10 +++++++--- crates/datastore/src/system_tables.rs | 2 +- crates/fs-utils/src/compression.rs | 2 +- crates/lib/tests/serde.rs | 2 +- crates/metrics/src/typed_prometheus.rs | 6 +++--- crates/primitives/src/col_list.rs | 2 +- crates/sats/src/de/impls.rs | 2 +- crates/sats/src/product_value.rs | 2 +- crates/sats/src/ser/impls.rs | 2 +- crates/sats/src/typespace.rs | 4 ++-- crates/schema/src/schema.rs | 2 +- crates/table/src/read_column.rs | 4 ++-- crates/table/src/util.rs | 4 ++-- sdks/rust/src/websocket.rs | 2 +- sdks/rust/tests/test-client/src/main.rs | 2 +- 32 files changed, 50 insertions(+), 46 deletions(-) diff --git a/crates/bindings-macro/src/util.rs b/crates/bindings-macro/src/util.rs index 061e4b105f3..41c9dad016d 100644 --- a/crates/bindings-macro/src/util.rs +++ b/crates/bindings-macro/src/util.rs @@ -90,18 +90,18 @@ macro_rules! match_meta { (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:block $($rest:tt)* }) => { match_meta!(@case $acc, $comparisons, $meta, _, $sym, $body, { $($rest)* }) }; - (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:expr_2021, $($rest:tt)* }) => { + (@match $acc:tt, $comparisons:tt, $meta:ident { $sym:path => $body:expr, $($rest:tt)* }) => { match_meta!(@case $acc, $comparisons, $meta, _, $sym, $body, { $($rest)* }) }; - (@match ($($acc:tt)*), ($($comparisons:expr_2021),*), $meta:ident {}) => { + (@match ($($acc:tt)*), ($($comparisons:expr),*), $meta:ident {}) => { match () { $($acc)* _ => return Err($meta.error($crate::util::one_of(&[$($comparisons),*]))), } }; - (@case ($($acc:tt)*), ($($comparisons:expr_2021),*), $meta:ident, $binding:tt, $sym:path, $body:expr_2021, { $($rest:tt)* }) => { + (@case ($($acc:tt)*), ($($comparisons:expr),*), $meta:ident, $binding:tt, $sym:path, $body:expr, { $($rest:tt)* }) => { match_meta!(@match ( $($acc)* _ if $meta.path == $sym => $body, diff --git a/crates/bindings/src/http.rs b/crates/bindings/src/http.rs index 4c52620b1b8..68870192cfe 100644 --- a/crates/bindings/src/http.rs +++ b/crates/bindings/src/http.rs @@ -248,7 +248,7 @@ impl Default for Body { } macro_rules! impl_body_from_bytes { - ($bytes:ident : $t:ty => $conv:expr_2021) => { + ($bytes:ident : $t:ty => $conv:expr) => { impl From<$t> for Body { fn from($bytes: $t) -> Body { Body::from_bytes($conv) diff --git a/crates/bindings/src/lib.rs b/crates/bindings/src/lib.rs index 1423ee783cb..e1089ce5451 100644 --- a/crates/bindings/src/lib.rs +++ b/crates/bindings/src/lib.rs @@ -1551,10 +1551,10 @@ macro_rules! __volatile_nonatomic_schedule_immediate_impl { ([$($cur:tt)*] [$next:tt $($rest:tt)*]) => { $crate::__volatile_nonatomic_schedule_immediate_impl!([$($cur)* $next] [$($rest)*]) }; - (@process_args $repeater:path, ($($args:expr_2021),* $(,)?)) => { + (@process_args $repeater:path, ($($args:expr),* $(,)?)) => { $crate::__volatile_nonatomic_schedule_immediate_impl!(@call $repeater, ($($args),*)) }; - (@call $repeater:path, ($($args:expr_2021),*)) => { + (@call $repeater:path, ($($args:expr),*)) => { if false { let _ = $repeater(&$crate::ReducerContext::__dummy(), $($args,)*); } else { diff --git a/crates/bindings/src/query_builder/expr.rs b/crates/bindings/src/query_builder/expr.rs index 8f6710821cd..9591621dff8 100644 --- a/crates/bindings/src/query_builder/expr.rs +++ b/crates/bindings/src/query_builder/expr.rs @@ -71,7 +71,7 @@ impl LiteralValue { } macro_rules! impl_rhs { - ($ty:ty, $formatter:expr_2021) => { + ($ty:ty, $formatter:expr) => { impl RHS for $ty { fn to_expr(self) -> Operand { Operand::Literal(LiteralValue($formatter(self))) diff --git a/crates/cli/src/tasks/csharp.rs b/crates/cli/src/tasks/csharp.rs index 04127c3391a..5df8b730448 100644 --- a/crates/cli/src/tasks/csharp.rs +++ b/crates/cli/src/tasks/csharp.rs @@ -12,7 +12,7 @@ pub(crate) fn build_csharp(project_path: &Path, build_debug: bool) -> anyhow::Re // All `dotnet` commands must execute in the project directory, otherwise // global.json won't have any effect and wrong .NET SDK might be picked. macro_rules! dotnet { - ($($arg:expr_2021),*) => { + ($($arg:expr),*) => { duct::cmd!("dotnet", $($arg),*).dir(project_path) }; } diff --git a/crates/codegen/examples/regen-csharp-moduledef.rs b/crates/codegen/examples/regen-csharp-moduledef.rs index 6f782a11603..74db4b9de90 100644 --- a/crates/codegen/examples/regen-csharp-moduledef.rs +++ b/crates/codegen/examples/regen-csharp-moduledef.rs @@ -10,7 +10,7 @@ use std::path::Path; use std::sync::OnceLock; macro_rules! regex_replace { - ($value:expr_2021, $re:expr_2021, $replace:expr_2021) => {{ + ($value:expr, $re:expr, $replace:expr) => {{ static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new($re).unwrap()) .replace_all($value, $replace) diff --git a/crates/codegen/examples/regen-typescript-moduledef.rs b/crates/codegen/examples/regen-typescript-moduledef.rs index 42508fb53c4..47ecb692863 100644 --- a/crates/codegen/examples/regen-typescript-moduledef.rs +++ b/crates/codegen/examples/regen-typescript-moduledef.rs @@ -13,7 +13,7 @@ use std::path::Path; use std::sync::OnceLock; macro_rules! regex_replace { - ($value:expr_2021, $re:expr_2021, $replace:expr_2021) => {{ + ($value:expr, $re:expr, $replace:expr) => {{ static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new($re).unwrap()) .replace_all($value, $replace) diff --git a/crates/codegen/tests/codegen.rs b/crates/codegen/tests/codegen.rs index 907db0bc735..f9912ca44cc 100644 --- a/crates/codegen/tests/codegen.rs +++ b/crates/codegen/tests/codegen.rs @@ -11,7 +11,7 @@ fn compiled_module() -> &'static ModuleDef { } macro_rules! declare_tests { - ($($name:ident => $lang:expr_2021,)*) => ($( + ($($name:ident => $lang:expr,)*) => ($( #[test] fn $name() { let module = compiled_module(); diff --git a/crates/core/src/db/update.rs b/crates/core/src/db/update.rs index 5b3060497b6..fa5e5b64f10 100644 --- a/crates/core/src/db/update.rs +++ b/crates/core/src/db/update.rs @@ -80,7 +80,7 @@ fn manual_migrate_database( /// Logs with `info` level to `$logger` as well as via the `log` crate. macro_rules! log { - ($logger:expr_2021, $($tokens:tt)*) => { + ($logger:expr, $($tokens:tt)*) => { $logger.info(&format!($($tokens)*)); log::info!($($tokens)*); }; diff --git a/crates/core/src/host/v8/builtins/mod.rs b/crates/core/src/host/v8/builtins/mod.rs index b097fb81450..d790415f388 100644 --- a/crates/core/src/host/v8/builtins/mod.rs +++ b/crates/core/src/host/v8/builtins/mod.rs @@ -31,7 +31,7 @@ fn eval_builtin( } macro_rules! create_synthetic_module { - ($scope:expr_2021, $module_name:expr_2021 $(, $fun:ident)* $(,)?) => {{ + ($scope:expr, $module_name:expr $(, $fun:ident)* $(,)?) => {{ let export_names = &[$(str_from_ident!($fun).string($scope)),*]; let eval_steps = |context, module| { v8::callback_scope!(unsafe scope, context); diff --git a/crates/core/src/host/v8/from_value.rs b/crates/core/src/host/v8/from_value.rs index 1a9522a81b5..95c6f811062 100644 --- a/crates/core/src/host/v8/from_value.rs +++ b/crates/core/src/host/v8/from_value.rs @@ -11,7 +11,7 @@ pub(super) trait FromValue: Sized { /// Provides a [`FromValue`] implementation. macro_rules! impl_from_value { - ($ty:ty, ($val:ident, $scope:ident) => $logic:expr_2021) => { + ($ty:ty, ($val:ident, $scope:ident) => $logic:expr) => { impl FromValue for $ty { fn from_value<'scope>($val: Local<'_, Value>, $scope: &PinScope<'scope, '_>) -> ValueResult<'scope, Self> { $logic @@ -35,7 +35,7 @@ where /// Tries to cast `Value` into `T` or raises a JS exception as a returned `Err` value. macro_rules! cast { - ($scope:expr_2021, $val:expr_2021, $js_ty:ty, $expected:literal $(, $args:expr_2021)* $(,)?) => {{ + ($scope:expr, $val:expr, $js_ty:ty, $expected:literal $(, $args:expr)* $(,)?) => {{ $crate::host::v8::from_value::try_cast::<$js_ty>($scope, $val, |got| format!(concat!("Expected ", $expected, ", got {__got}"), $($args,)* __got = got)) }}; } diff --git a/crates/core/src/host/v8/syscall/v1.rs b/crates/core/src/host/v8/syscall/v1.rs index 6c21f573bac..588fd16a86e 100644 --- a/crates/core/src/host/v8/syscall/v1.rs +++ b/crates/core/src/host/v8/syscall/v1.rs @@ -31,7 +31,7 @@ use v8::{ }; macro_rules! create_synthetic_module { - ($scope:expr_2021, $module_name:expr_2021 $(, ($wrapper:ident, $abi_call:expr_2021, $fun:ident))* $(,)?) => {{ + ($scope:expr, $module_name:expr $(, ($wrapper:ident, $abi_call:expr, $fun:ident))* $(,)?) => {{ let export_names = &[$(str_from_ident!($fun).string($scope)),*]; let eval_steps = |context, module| { callback_scope!(unsafe scope, context); diff --git a/crates/core/src/host/v8/to_value.rs b/crates/core/src/host/v8/to_value.rs index 094ef2d541c..53ba5401f30 100644 --- a/crates/core/src/host/v8/to_value.rs +++ b/crates/core/src/host/v8/to_value.rs @@ -11,7 +11,7 @@ pub(super) trait ToValue { /// Provides a [`ToValue`] implementation. macro_rules! impl_to_value { - ($ty:ty, ($val:ident, $scope:ident) => $logic:expr_2021) => { + ($ty:ty, ($val:ident, $scope:ident) => $logic:expr) => { impl ToValue for $ty { fn to_value<'scope>(&self, $scope: &PinScope<'scope, '_>) -> Local<'scope, Value> { let $val = *self; diff --git a/crates/core/src/sql/ast.rs b/crates/core/src/sql/ast.rs index 6d8414eb66e..26c52d9b126 100644 --- a/crates/core/src/sql/ast.rs +++ b/crates/core/src/sql/ast.rs @@ -66,7 +66,7 @@ impl Unsupported for sqlparser::ast::GroupByExpr { } macro_rules! unsupported { - ($name:literal,$a:expr_2021)=>{{ + ($name:literal,$a:expr)=>{{ let name = stringify!($name); let it = stringify!($a); if $a.unsupported() { @@ -76,7 +76,7 @@ macro_rules! unsupported { }); } }}; - ($name:literal,$($a:expr_2021),+$(,)?)=> {{ + ($name:literal,$($a:expr),+$(,)?)=> {{ $(unsupported!($name,$a);)+ }}; } diff --git a/crates/core/src/subscription/module_subscription_actor.rs b/crates/core/src/subscription/module_subscription_actor.rs index b471bba25b0..a52a48ecb53 100644 --- a/crates/core/src/subscription/module_subscription_actor.rs +++ b/crates/core/src/subscription/module_subscription_actor.rs @@ -202,7 +202,7 @@ type FullSubscriptionUpdate = FormatSwitch, ws:: /// A utility for sending an error message to a client and returning early macro_rules! return_on_err { - ($expr:expr_2021, $handler:expr_2021, $metrics:expr_2021) => { + ($expr:expr, $handler:expr, $metrics:expr) => { match $expr { Ok(val) => val, Err(e) => { @@ -216,7 +216,7 @@ macro_rules! return_on_err { /// A utility for sending an error message to a client and returning early macro_rules! return_on_err_with_sql { - ($expr:expr_2021, $sql:expr_2021, $handler:expr_2021) => { + ($expr:expr, $sql:expr, $handler:expr) => { match $expr.map_err(|err| DBError::WithSql { sql: $sql.into(), error: Box::new(DBError::Other(err.into())), diff --git a/crates/data-structures/src/error_stream.rs b/crates/data-structures/src/error_stream.rs index 0e0651308c6..62fb55e37c9 100644 --- a/crates/data-structures/src/error_stream.rs +++ b/crates/data-structures/src/error_stream.rs @@ -459,7 +459,7 @@ impl>>> CollectAllErrors for I /// ``` #[macro_export] macro_rules! expect_error_matching ( - ($result:expr_2021, $expected:pat => $cond:expr_2021) => { + ($result:expr, $expected:pat => $cond:expr) => { let result: &::std::result::Result< _, $crate::error_stream::ErrorStream<_> @@ -480,7 +480,7 @@ macro_rules! expect_error_matching ( } } }; - ($result:expr_2021, $expected:pat) => { + ($result:expr, $expected:pat) => { let result: &::std::result::Result< _, $crate::error_stream::ErrorStream<_> diff --git a/crates/data-structures/src/slim_slice.rs b/crates/data-structures/src/slim_slice.rs index 3276e5b0fa1..0255e76fce6 100644 --- a/crates/data-structures/src/slim_slice.rs +++ b/crates/data-structures/src/slim_slice.rs @@ -116,7 +116,7 @@ pub fn try_into>>(x: A) -> Result { + ($thing:expr) => { let Ok(_) = u32::try_from($thing.len()) else { return Err(LenTooLong { len: $thing.len(), diff --git a/crates/datastore/src/locking_tx_datastore/mut_tx.rs b/crates/datastore/src/locking_tx_datastore/mut_tx.rs index 16872c2879c..e53792458f2 100644 --- a/crates/datastore/src/locking_tx_datastore/mut_tx.rs +++ b/crates/datastore/src/locking_tx_datastore/mut_tx.rs @@ -2322,7 +2322,9 @@ impl MutTxId { ) { // This is possible on restart if the database was previously running a version // before this system table was added. - log::error!("[{database_identity}]: delete_st_client_credentials: attempting to delete credentials for missing connection id ({connection_id}), error: {e}"); + log::error!( + "[{database_identity}]: delete_st_client_credentials: attempting to delete credentials for missing connection id ({connection_id}), error: {e}" + ); } Ok(()) } @@ -2350,7 +2352,9 @@ impl MutTxId { { Some(ptr) => self.delete(ST_CLIENT_ID, ptr).map(drop)?, _ => { - log::error!("[{database_identity}]: delete_st_client: attempting to delete client ({identity}, {connection_id}), but no st_client row for that client is resident"); + log::error!( + "[{database_identity}]: delete_st_client: attempting to delete client ({identity}, {connection_id}), but no st_client row for that client is resident" + ); } } self.delete_st_client_credentials(database_identity, connection_id) @@ -2687,7 +2691,7 @@ impl MutTxId { // This macros can be thought of as a `throw $e` within `'error`. // TODO(centril): Get rid of this once we have stable `try` blocks or polonius. macro_rules! throw { - ($e:expr_2021) => { + ($e:expr) => { break 'error $e.into() }; } diff --git a/crates/datastore/src/system_tables.rs b/crates/datastore/src/system_tables.rs index 97cf83ba7b7..107dfb5b1b2 100644 --- a/crates/datastore/src/system_tables.rs +++ b/crates/datastore/src/system_tables.rs @@ -186,7 +186,7 @@ pub(crate) const ST_VIEW_SUB_IDX: usize = 14; pub(crate) const ST_VIEW_ARG_IDX: usize = 15; macro_rules! st_fields_enum { - ($(#[$attr:meta])* enum $ty_name:ident { $($name:expr_2021, $var:ident = $discr:expr_2021,)* }) => { + ($(#[$attr:meta])* enum $ty_name:ident { $($name:expr, $var:ident = $discr:expr,)* }) => { #[derive(Copy, Clone, Debug)] $(#[$attr])* pub enum $ty_name { diff --git a/crates/fs-utils/src/compression.rs b/crates/fs-utils/src/compression.rs index 3eff2f879df..8e72fcbe76d 100644 --- a/crates/fs-utils/src/compression.rs +++ b/crates/fs-utils/src/compression.rs @@ -235,7 +235,7 @@ mod async_impls { } } macro_rules! forward_reader { - ($self:ident.$method:ident($($args:expr_2021),*)) => { + ($self:ident.$method:ident($($args:expr),*)) => { match $self.get_mut() { AsyncCompressReader::None(r) => Pin::new(r).$method($($args),*), AsyncCompressReader::Zstd(r) => Pin::new(r).$method($($args),*), diff --git a/crates/lib/tests/serde.rs b/crates/lib/tests/serde.rs index 3bb4ac849c3..dfc6eef0957 100644 --- a/crates/lib/tests/serde.rs +++ b/crates/lib/tests/serde.rs @@ -6,7 +6,7 @@ use spacetimedb_sats::algebraic_value::ser::value_serialize; use spacetimedb_sats::{satn::Satn, GroundSpacetimeType as _, SumTypeVariant, Typespace, WithTypespace}; macro_rules! de_json_snapshot { - ($schema:expr_2021, $json:expr_2021) => { + ($schema:expr, $json:expr) => { let (schema, json) = (&$schema, &$json); let value = de_json(schema, json).unwrap(); let value = WithTypespace::new(&EMPTY_TYPESPACE, schema) diff --git a/crates/metrics/src/typed_prometheus.rs b/crates/metrics/src/typed_prometheus.rs index ad4b96a61bb..0a8eafe484a 100644 --- a/crates/metrics/src/typed_prometheus.rs +++ b/crates/metrics/src/typed_prometheus.rs @@ -3,7 +3,7 @@ use prometheus::core::{Metric, MetricVec, MetricVecBuilder}; #[macro_export] macro_rules! metrics_group { ($(#[$attr:meta])* $type_vis:vis struct $type_name:ident { - $(#[name = $name:ident] #[help = $help:expr_2021] $(#[labels($($labels:ident: $labelty:ty),*)])? $(#[buckets($($bucket:literal),*)])? $vis:vis $field:ident: $ty:ident,)* + $(#[name = $name:ident] #[help = $help:expr] $(#[labels($($labels:ident: $labelty:ty),*)])? $(#[buckets($($bucket:literal),*)])? $vis:vis $field:ident: $ty:ident,)* }) => { $(#[$attr])* $type_vis struct $type_name { @@ -58,10 +58,10 @@ pub use {itertools, paste::paste}; #[macro_export] macro_rules! make_collector { - ($ty:ty, $name:expr_2021, $help:expr_2021 $(,)?) => { + ($ty:ty, $name:expr, $help:expr $(,)?) => { <$ty>::with_opts(prometheus::Opts::new($name, $help).into()).unwrap() }; - ($ty:ty, $name:expr_2021, $help:expr_2021, $labels:expr_2021 $(,)?) => { + ($ty:ty, $name:expr, $help:expr, $labels:expr $(,)?) => { <$ty>::new(prometheus::Opts::new($name, $help).into(), $labels).unwrap() }; } diff --git a/crates/primitives/src/col_list.rs b/crates/primitives/src/col_list.rs index a49027d59f0..6145a4dc294 100644 --- a/crates/primitives/src/col_list.rs +++ b/crates/primitives/src/col_list.rs @@ -23,7 +23,7 @@ use itertools::Itertools; /// Mostly provided for testing. #[macro_export] macro_rules! col_list { - ($($elem:expr_2021),* $(,)?) => {{ + ($($elem:expr),* $(,)?) => {{ $crate::ColList::from([$($elem),*]) }}; } diff --git a/crates/sats/src/de/impls.rs b/crates/sats/src/de/impls.rs index 79483f191c9..d0c9a92c23d 100644 --- a/crates/sats/src/de/impls.rs +++ b/crates/sats/src/de/impls.rs @@ -29,7 +29,7 @@ use std::{borrow::Cow, rc::Rc, sync::Arc}; /// ``` #[macro_export] macro_rules! impl_deserialize { - ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, $de:ident => $body:expr_2021) => { + ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, $de:ident => $body:expr) => { impl<'de, $($generics)*> $crate::de::Deserialize<'de> for $typ { fn deserialize>($de: D) -> Result { $body } } diff --git a/crates/sats/src/product_value.rs b/crates/sats/src/product_value.rs index c212fa63a13..634b4a935cc 100644 --- a/crates/sats/src/product_value.rs +++ b/crates/sats/src/product_value.rs @@ -18,7 +18,7 @@ pub struct ProductValue { /// Repeat notation from `vec![x; n]` is not supported. #[macro_export] macro_rules! product { - [$($elems:expr_2021),*$(,)?] => { + [$($elems:expr),*$(,)?] => { $crate::ProductValue { elements: [$($crate::AlgebraicValue::from($elems)),*].into(), } diff --git a/crates/sats/src/ser/impls.rs b/crates/sats/src/ser/impls.rs index b89067e02e1..9baac393dff 100644 --- a/crates/sats/src/ser/impls.rs +++ b/crates/sats/src/ser/impls.rs @@ -29,7 +29,7 @@ use std::sync::Arc; /// ``` #[macro_export] macro_rules! impl_serialize { - ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, ($self:ident, $ser:ident) => $body:expr_2021) => { + ([$($generics:tt)*] $(where [$($wc:tt)*])? $typ:ty, ($self:ident, $ser:ident) => $body:expr) => { impl<$($generics)*> $crate::ser::Serialize for $typ $(where $($wc)*)? { fn serialize($self: &Self, $ser: S) -> Result { $body diff --git a/crates/sats/src/typespace.rs b/crates/sats/src/typespace.rs index 41941248406..f7d0978d660 100644 --- a/crates/sats/src/typespace.rs +++ b/crates/sats/src/typespace.rs @@ -352,7 +352,7 @@ pub trait TypespaceBuilder { /// ``` #[macro_export] macro_rules! impl_st { - ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $stty:expr_2021) => { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $stty:expr) => { impl<$($generic_wrapped $($other_generics)*)?> $crate::GroundSpacetimeType for $rty $(where $generic_wrapped: $crate::GroundSpacetimeType)? { @@ -363,7 +363,7 @@ macro_rules! impl_st { impl_st!([ $($generic $($other_generics)*)? ] $rty, _ts => $stty); }; - ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $ts:ident => $stty:expr_2021) => { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $ts:ident => $stty:expr) => { impl<$($generic_wrapped $($other_generics)*)?> $crate::SpacetimeType for $rty $(where $generic_wrapped: $crate::SpacetimeType)? { diff --git a/crates/schema/src/schema.rs b/crates/schema/src/schema.rs index f9c409daff3..51826292454 100644 --- a/crates/schema/src/schema.rs +++ b/crates/schema/src/schema.rs @@ -685,7 +685,7 @@ fn find_remove(vec: &mut Vec, predicate: impl Fn(&T) -> bool) -> Option /// Like `assert_eq!` for `anyhow`, but `$msg` is just a string, not a format string. macro_rules! ensure_eq { - ($a:expr_2021, $b:expr_2021, $msg:expr_2021) => { + ($a:expr, $b:expr, $msg:expr) => { if $a != $b { anyhow::bail!( "{0}: expected {1} == {2}:\n {1}: {3:?}\n {2}: {4:?}", diff --git a/crates/table/src/read_column.rs b/crates/table/src/read_column.rs index 30c7865e2d7..1cef02b2ff0 100644 --- a/crates/table/src/read_column.rs +++ b/crates/table/src/read_column.rs @@ -485,7 +485,7 @@ mod test { /// e.g. a Rust integer, /// and asserts that the extracted value is as expected. macro_rules! test_read_column_primitive { - ($name:ident { $algebraic_type:expr_2021 => $rust_type:ty = $val:expr_2021 }) => { + ($name:ident { $algebraic_type:expr => $rust_type:ty = $val:expr }) => { #[test] fn $name() { let pool = PagePool::new_for_test(); @@ -500,7 +500,7 @@ mod test { }; - ($($name:ident { $algebraic_type:expr_2021 => $rust_type:ty = $val:expr_2021 };)*) => { + ($($name:ident { $algebraic_type:expr => $rust_type:ty = $val:expr };)*) => { $(test_read_column_primitive! { $name { $algebraic_type => $rust_type = $val } })* diff --git a/crates/table/src/util.rs b/crates/table/src/util.rs index 1a737b569e6..ca74c4167e8 100644 --- a/crates/table/src/util.rs +++ b/crates/table/src/util.rs @@ -16,7 +16,7 @@ pub const fn range_move(r: Range, by: usize) -> Range { /// ``` #[macro_export] macro_rules! static_assert_size { - ($ty:ty, $size:expr_2021) => { + ($ty:ty, $size:expr) => { const _: [(); $size] = [(); ::core::mem::size_of::<$ty>()]; }; } @@ -30,7 +30,7 @@ macro_rules! static_assert_size { /// ``` #[macro_export] macro_rules! static_assert_align { - ($ty:ty, $align:expr_2021) => { + ($ty:ty, $align:expr) => { const _: [(); $align] = [(); ::core::mem::align_of::<$ty>()]; }; } diff --git a/sdks/rust/src/websocket.rs b/sdks/rust/src/websocket.rs index 63eefb7a3b7..e0372a53dbb 100644 --- a/sdks/rust/src/websocket.rs +++ b/sdks/rust/src/websocket.rs @@ -214,7 +214,7 @@ fn request_insert_auth_header(req: &mut http::Request<()>, token: Option<&str>) /// /// Could be trivially written as a function, but macro-ifying it preserves the source location of the log. macro_rules! maybe_log_error { - ($cause:expr_2021, $res:expr_2021) => { + ($cause:expr, $res:expr) => { if let Err(e) = $res { log::warn!("{}: {:?}", $cause, e); } diff --git a/sdks/rust/tests/test-client/src/main.rs b/sdks/rust/tests/test-client/src/main.rs index e7aa131c8c4..fe30038ff59 100644 --- a/sdks/rust/tests/test-client/src/main.rs +++ b/sdks/rust/tests/test-client/src/main.rs @@ -48,7 +48,7 @@ fn exit_on_panic() { } macro_rules! assert_eq_or_bail { - ($expected:expr_2021, $found:expr_2021) => {{ + ($expected:expr, $found:expr) => {{ let expected = &$expected; let found = &$found; if expected != found { From 8f01e488ff587dc4adf29f752ceff3b792213a75 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 13:07:35 -0600 Subject: [PATCH 4/7] Wrap export_name attribute in unsafe() --- crates/bindings-macro/src/lib.rs | 2 +- crates/bindings-macro/src/procedure.rs | 2 +- crates/bindings-macro/src/reducer.rs | 6 +++--- crates/bindings-macro/src/table.rs | 2 +- crates/bindings-macro/src/view.rs | 2 +- crates/bindings/src/rt.rs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bindings-macro/src/lib.rs b/crates/bindings-macro/src/lib.rs index c82ac7429df..93f65125ef5 100644 --- a/crates/bindings-macro/src/lib.rs +++ b/crates/bindings-macro/src/lib.rs @@ -279,7 +279,7 @@ pub fn client_visibility_filter(args: StdTokenStream, item: StdTokenStream) -> S #item const _: () = { - #[export_name = #register_rls_symbol] + #[unsafe(export_name = #register_rls_symbol)] extern "C" fn __register_client_visibility_filter() { spacetimedb::rt::register_row_level_security(#rls_ident.sql_text()) } diff --git a/crates/bindings-macro/src/procedure.rs b/crates/bindings-macro/src/procedure.rs index 0f4013d96ae..6189141dcaa 100644 --- a/crates/bindings-macro/src/procedure.rs +++ b/crates/bindings-macro/src/procedure.rs @@ -80,7 +80,7 @@ pub(crate) fn procedure_impl(args: ProcedureArgs, original_function: &ItemFn) -> let lifetime_where_clause = &lifetime_params.where_clause; let generated_describe_function = quote! { - #[export_name = #register_describer_symbol] + #[unsafe(export_name = #register_describer_symbol)] pub extern "C" fn __register_describer() { spacetimedb::rt::register_procedure::<_, _, #func_name>(#func_name) } diff --git a/crates/bindings-macro/src/reducer.rs b/crates/bindings-macro/src/reducer.rs index 5adf4075284..7233a141ab0 100644 --- a/crates/bindings-macro/src/reducer.rs +++ b/crates/bindings-macro/src/reducer.rs @@ -67,12 +67,12 @@ pub(crate) fn assert_only_lifetime_generics(original_function: &ItemFn, function syn::GenericParam::Type(_) => { return Err(err(format!( "type parameters are not allowed on {function_kind_plural}" - ))) + ))); } syn::GenericParam::Const(_) => { return Err(err(format!( "const parameters are not allowed on {function_kind_plural}" - ))) + ))); } } } @@ -131,7 +131,7 @@ pub(crate) fn reducer_impl(args: ReducerArgs, original_function: &ItemFn) -> syn let lt_where_clause = <_params.where_clause; let generated_describe_function = quote! { - #[export_name = #register_describer_symbol] + #[unsafe(export_name = #register_describer_symbol)] pub extern "C" fn __register_describer() { spacetimedb::rt::register_reducer::<_, #func_name>(#func_name) } diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 68eb2f11777..a302ef4ec02 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -911,7 +911,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R let register_describer_symbol = format!("__preinit__20_register_describer_{table_ident}"); let describe_table_func = quote! { - #[export_name = #register_describer_symbol] + #[unsafe(export_name = #register_describer_symbol)] extern "C" fn __register_describer() { spacetimedb::rt::register_table::<#tablehandle_ident>() } diff --git a/crates/bindings-macro/src/view.rs b/crates/bindings-macro/src/view.rs index 34e7286598c..cf518d1806d 100644 --- a/crates/bindings-macro/src/view.rs +++ b/crates/bindings-macro/src/view.rs @@ -131,7 +131,7 @@ pub(crate) fn view_impl(args: ViewArgs, original_function: &ItemFn) -> syn::Resu let lt_where_clause = <_params.where_clause; let generated_describe_function = quote! { - #[export_name = #register_describer_symbol] + #[unsafe(export_name = #register_describer_symbol)] pub extern "C" fn __register_describer() { spacetimedb::rt::ViewRegistrar::<#ctx_ty>::register::<_, #func_name, _, _>(#func_name) } diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 11f4eff74a0..762e48160a5 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -1236,7 +1236,7 @@ fn write_to_sink(sink: BytesSink, mut buf: &[u8]) { macro_rules! __make_register_reftype { ($ty:ty, $name:literal) => { const _: () = { - #[export_name = concat!("__preinit__20_register_describer_", $name)] + #[unsafe(export_name = concat!("__preinit__20_register_describer_", $name))] extern "C" fn __register_describer() { $crate::rt::register_reftype::<$ty>() } From df3f8b3de6e0b93bab2995f2bde582bb99822b5b Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 13:10:58 -0600 Subject: [PATCH 5/7] Fix some RPIT lifetime capturing issues that weren't automigrated --- crates/client-api/src/routes/energy.rs | 6 +++--- crates/commitlog/tests/streaming/mod.rs | 2 +- .../subscription/module_subscription_manager.rs | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/client-api/src/routes/energy.rs b/crates/client-api/src/routes/energy.rs index b2ab94c0c66..a554c418ad9 100644 --- a/crates/client-api/src/routes/energy.rs +++ b/crates/client-api/src/routes/energy.rs @@ -22,7 +22,7 @@ pub async fn get_energy_balance( Path(IdentityParams { identity }): Path, ) -> axum::response::Result { let identity = Identity::from(identity); - get_budget_inner(ctx, &identity).await + get_budget_inner(ctx, identity).await } #[serde_with::serde_as] @@ -66,10 +66,10 @@ pub async fn add_energy( async fn get_budget_inner( ctx: impl ControlStateDelegate, - identity: &Identity, + identity: Identity, ) -> axum::response::Result { let balance = ctx - .get_energy_balance(identity) + .get_energy_balance(&identity) .await .map_err(log_and_500)? .map_or(0, |quanta| quanta.get()); diff --git a/crates/commitlog/tests/streaming/mod.rs b/crates/commitlog/tests/streaming/mod.rs index 0474ae75b30..2f9b2547abf 100644 --- a/crates/commitlog/tests/streaming/mod.rs +++ b/crates/commitlog/tests/streaming/mod.rs @@ -214,7 +214,7 @@ fn repo(at: &Path) -> repo::Fs { repo::Fs::new(CommitLogDir::from_path_unchecked(at), None).unwrap() } -fn create_reader(path: &Path, range: impl RangeBounds) -> impl AsyncBufRead { +fn create_reader>(path: &Path, range: R) -> impl AsyncBufRead + use { BufReader::new(StreamReader::new(stream::commits( repo::Fs::new(CommitLogDir::from_path_unchecked(path), None).unwrap(), range, diff --git a/crates/core/src/subscription/module_subscription_manager.rs b/crates/core/src/subscription/module_subscription_manager.rs index c242d79b305..9764ef818d5 100644 --- a/crates/core/src/subscription/module_subscription_manager.rs +++ b/crates/core/src/subscription/module_subscription_manager.rs @@ -1095,14 +1095,14 @@ impl SubscriptionManager { fn queries_for_table_update<'a>( &'a self, table_update: &'a DatabaseTableUpdate, - find_rhs_val: &impl Fn(&JoinEdge, &ProductValue) -> Option, + find_rhs_val: impl Fn(&JoinEdge, &ProductValue) -> Option, ) -> impl Iterator { let mut queries = HashSet::new(); for hash in table_update .inserts .iter() .chain(table_update.deletes.iter()) - .flat_map(|row| self.queries_for_row(table_update.table_id, row, find_rhs_val)) + .flat_map(|row| self.queries_for_row(table_update.table_id, row, &find_rhs_val)) { queries.insert(hash); } @@ -1182,7 +1182,7 @@ impl SubscriptionManager { .iter() .filter(|table| !table.inserts.is_empty() || !table.deletes.is_empty()) .flat_map(|table_update| { - self.queries_for_table_update(table_update, &|edge, row| find_rhs_val(edge, row, tx)) + self.queries_for_table_update(table_update, |edge, row| find_rhs_val(edge, row, tx)) }) // deduplicate queries by their hash .filter({ @@ -2161,7 +2161,7 @@ mod tests { }; let hashes = subscriptions - .queries_for_table_update(&table_update, &|_, _| None) + .queries_for_table_update(&table_update, |_, _| None) .collect::>(); assert!(hashes.len() == 3); @@ -2179,7 +2179,7 @@ mod tests { }; let hashes = subscriptions - .queries_for_table_update(&table_update, &|_, _| None) + .queries_for_table_update(&table_update, |_, _| None) .collect::>(); assert!(hashes.len() == 1); @@ -2220,7 +2220,7 @@ mod tests { }; let hashes = subscriptions - .queries_for_table_update(&table_update, &|_, _| None) + .queries_for_table_update(&table_update, |_, _| None) .cloned() .collect::>(); @@ -2236,7 +2236,7 @@ mod tests { }; let hashes = subscriptions - .queries_for_table_update(&table_update, &|_, _| None) + .queries_for_table_update(&table_update, |_, _| None) .cloned() .collect::>(); @@ -2252,7 +2252,7 @@ mod tests { }; let hashes = subscriptions - .queries_for_table_update(&table_update, &|_, _| None) + .queries_for_table_update(&table_update, |_, _| None) .cloned() .collect::>(); From a16470d8ae878d9ecea523b4602fac2fa3470032 Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 1 Dec 2025 14:43:37 -0600 Subject: [PATCH 6/7] Run cargo clippy --all-targets --workspace --fix && cargo fmt --- crates/auth/src/identity.rs | 8 +- crates/bench/src/sqlite.rs | 8 +- crates/bindings-macro/src/table.rs | 16 +- crates/cli/build.rs | 8 +- crates/cli/src/config.rs | 82 +-- crates/cli/src/subcommands/dev.rs | 50 +- crates/cli/src/subcommands/init.rs | 135 ++-- crates/cli/src/subcommands/logs.rs | 40 +- crates/cli/tests/util.rs | 16 +- crates/client-api/src/lib.rs | 8 +- crates/client-api/src/routes/database.rs | 33 +- crates/client-api/src/routes/subscribe.rs | 10 +- crates/commitlog/src/commitlog.rs | 8 +- crates/commitlog/src/tests/partial.rs | 14 +- crates/core/src/auth/token_validation.rs | 16 +- crates/core/src/db/relational_db.rs | 27 +- crates/core/src/error.rs | 8 +- crates/core/src/host/host_controller.rs | 10 +- crates/core/src/host/module_host.rs | 6 +- crates/core/src/sql/type_check.rs | 28 +- crates/core/src/startup.rs | 14 +- .../module_subscription_manager.rs | 40 +- crates/core/src/vm.rs | 22 +- .../src/locking_tx_datastore/mut_tx.rs | 22 +- crates/durability/src/imp/local.rs | 23 +- crates/expr/src/check.rs | 10 +- crates/expr/src/expr.rs | 8 +- crates/fs-utils/src/dir_trie.rs | 10 +- crates/pg/src/encoder.rs | 13 +- crates/physical-plan/src/plan.rs | 19 +- crates/physical-plan/src/rules.rs | 594 +++++++++--------- crates/schema/src/type_for_generate.rs | 6 +- crates/snapshot/src/lib.rs | 20 +- crates/sql-parser/src/ast/sql.rs | 8 +- crates/sql-parser/src/ast/sub.rs | 8 +- crates/standalone/src/control_db.rs | 24 +- crates/table/src/pointer_map.rs | 6 +- crates/table/src/table_index/multimap.rs | 10 +- crates/testing/src/lib.rs | 35 +- crates/update/src/cli/install.rs | 8 +- crates/vm/src/expr.rs | 10 +- crates/vm/src/rel_ops.rs | 11 +- sdks/rust/src/db_connection.rs | 6 +- 43 files changed, 707 insertions(+), 751 deletions(-) diff --git a/crates/auth/src/identity.rs b/crates/auth/src/identity.rs index 5298a8f8954..8e4adbdf4c3 100644 --- a/crates/auth/src/identity.rs +++ b/crates/auth/src/identity.rs @@ -115,12 +115,12 @@ impl TryInto for IncomingClaims { let computed_identity = Identity::from_claims(&self.issuer, &self.subject); // If an identity is provided, it must match the computed identity. - if let Some(token_identity) = self.identity { - if token_identity != computed_identity { - return Err(anyhow::anyhow!( + if let Some(token_identity) = self.identity + && token_identity != computed_identity + { + return Err(anyhow::anyhow!( "Identity mismatch: token identity {token_identity:?} does not match computed identity {computed_identity:?}", )); - } } Ok(SpacetimeIdentityClaims { diff --git a/crates/bench/src/sqlite.rs b/crates/bench/src/sqlite.rs index b51f5958812..7fae43d84f1 100644 --- a/crates/bench/src/sqlite.rs +++ b/crates/bench/src/sqlite.rs @@ -226,10 +226,10 @@ fn memo_query String>(bench_name: BenchName, table_id: &str, gene // fast path let queries = QUERIES.read().unwrap(); - if let Some(bench_queries) = queries.get(&bench_name) { - if let Some(query) = bench_queries.get(table_id) { - return query.clone(); - } + if let Some(bench_queries) = queries.get(&bench_name) + && let Some(query) = bench_queries.get(table_id) + { + return query.clone(); } // slow path diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index a302ef4ec02..e1efe11a72e 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -679,14 +679,14 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R } } - if let Some(default_value) = &default_value { - if auto_inc.is_some() || primary_key.is_some() || unique.is_some() { - return Err(syn::Error::new( - default_value.span(), - "invalid combination: auto_inc, unique index or primary key cannot have a default value", - )); - }; - } + if let Some(default_value) = &default_value + && (auto_inc.is_some() || primary_key.is_some() || unique.is_some()) + { + return Err(syn::Error::new( + default_value.span(), + "invalid combination: auto_inc, unique index or primary key cannot have a default value", + )); + }; let column = Column { index: col_num, diff --git a/crates/cli/build.rs b/crates/cli/build.rs index 45b2b7da86f..fcc20bdba27 100644 --- a/crates/cli/build.rs +++ b/crates/cli/build.rs @@ -467,10 +467,10 @@ fn write_if_changed(path: &Path, contents: &[u8]) -> io::Result<()> { fn copy_if_changed(src: &Path, dst: &Path) -> io::Result<()> { let src_bytes = fs::read(src)?; - if let Ok(existing) = fs::read(dst) { - if existing == src_bytes { - return Ok(()); - } + if let Ok(existing) = fs::read(dst) + && existing == src_bytes + { + return Ok(()); } if let Some(parent) = dst.parent() { diff --git a/crates/cli/src/config.rs b/crates/cli/src/config.rs index cfc1b99155d..6627f6b61e9 100644 --- a/crates/cli/src/config.rs +++ b/crates/cli/src/config.rs @@ -220,22 +220,22 @@ impl RawConfig { ecdsa_public_key: Option, nickname: Option, ) -> anyhow::Result<()> { - if let Some(nickname) = &nickname { - if let Ok(cfg) = self.find_server(nickname) { - anyhow::bail!( - "Server nickname {} already in use: {}://{}", - nickname, - cfg.protocol, - cfg.host, - ); - } + if let Some(nickname) = &nickname + && let Ok(cfg) = self.find_server(nickname) + { + anyhow::bail!( + "Server nickname {} already in use: {}://{}", + nickname, + cfg.protocol, + cfg.host, + ); } if let Ok(cfg) = self.find_server(&host) { - if let Some(nick) = &cfg.nickname { - if nick == &host { - anyhow::bail!("Server host name is ambiguous with existing server nickname: {nick}"); - } + if let Some(nick) = &cfg.nickname + && nick == &host + { + anyhow::bail!("Server host name is ambiguous with existing server nickname: {nick}"); } anyhow::bail!("Server already configured for host: {host}"); } @@ -295,10 +295,10 @@ impl RawConfig { // If we're removing the default server, // unset the default server. - if let Some(default_server) = &self.default_server { - if cfg.nick_or_host_or_url_is(default_server) { - self.default_server = None; - } + if let Some(default_server) = &self.default_server + && cfg.nick_or_host_or_url_is(default_server) + { + self.default_server = None; } return Ok(()); @@ -370,27 +370,27 @@ Fetch the server's fingerprint with: ) -> anyhow::Result<(Option, Option, Option)> { // Check if the new nickname or host name would introduce ambiguities between // server configurations. - if let Some(new_nick) = new_nickname { - if let Ok(other_server) = self.find_server(new_nick) { - anyhow::bail!( - "Nickname {} conflicts with saved configuration for server {}: {}://{}", - new_nick, - other_server.nick_or_host(), - other_server.protocol, - other_server.host - ); - } + if let Some(new_nick) = new_nickname + && let Ok(other_server) = self.find_server(new_nick) + { + anyhow::bail!( + "Nickname {} conflicts with saved configuration for server {}: {}://{}", + new_nick, + other_server.nick_or_host(), + other_server.protocol, + other_server.host + ); } - if let Some(new_host) = new_host { - if let Ok(other_server) = self.find_server(new_host) { - anyhow::bail!( - "Host {} conflicts with saved configuration for server {}: {}://{}", - new_host, - other_server.nick_or_host(), - other_server.protocol, - other_server.host - ); - } + if let Some(new_host) = new_host + && let Ok(other_server) = self.find_server(new_host) + { + anyhow::bail!( + "Host {} conflicts with saved configuration for server {}: {}://{}", + new_host, + other_server.nick_or_host(), + other_server.protocol, + other_server.host + ); } let cfg = self.find_server_mut(server)?; @@ -418,10 +418,10 @@ Fetch the server's fingerprint with: if default_server == old_host { *default_server = new_host.unwrap().to_string(); } - } else if let Some(old_nick) = &old_nickname { - if default_server == old_nick { - *default_server = new_nickname.unwrap().to_string(); - } + } else if let Some(old_nick) = &old_nickname + && default_server == old_nick + { + *default_server = new_nickname.unwrap().to_string(); } } diff --git a/crates/cli/src/subcommands/dev.rs b/crates/cli/src/subcommands/dev.rs index ef8f876d973..09636895a83 100644 --- a/crates/cli/src/subcommands/dev.rs +++ b/crates/cli/src/subcommands/dev.rs @@ -255,13 +255,13 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E let (tx, rx) = channel(); let mut watcher: RecommendedWatcher = Watcher::new( move |res: Result| { - if let Ok(event) = res { - if matches!( + if let Ok(event) = res + && matches!( event.kind, notify::EventKind::Modify(_) | notify::EventKind::Create(_) | notify::EventKind::Remove(_) - ) { - let _ = tx.send(()); - } + ) + { + let _ = tx.send(()); } }, notify::Config::default().with_poll_interval(Duration::from_millis(500)), @@ -670,28 +670,28 @@ fn format_log_record(out: &mut W, record: &LogRecord<'_>) -> Resu let mut need_space_before_filename = false; let mut need_colon_sep = false; let dimmed = ColorSpec::new().set_dimmed(true).clone(); - if let Some(function) = &record.function { - if function.as_ref() != SENTINEL { - out.set_color(&dimmed)?; - write!(out, "{function}")?; - out.reset()?; - need_space_before_filename = true; - need_colon_sep = true; - } + if let Some(function) = &record.function + && function.as_ref() != SENTINEL + { + out.set_color(&dimmed)?; + write!(out, "{function}")?; + out.reset()?; + need_space_before_filename = true; + need_colon_sep = true; } - if let Some(filename) = &record.filename { - if filename.as_ref() != SENTINEL { - out.set_color(&dimmed)?; - if need_space_before_filename { - write!(out, " ")?; - } - write!(out, "{filename}")?; - if let Some(line) = record.line_number { - write!(out, ":{line}")?; - } - out.reset()?; - need_colon_sep = true; + if let Some(filename) = &record.filename + && filename.as_ref() != SENTINEL + { + out.set_color(&dimmed)?; + if need_space_before_filename { + write!(out, " ")?; + } + write!(out, "{filename}")?; + if let Some(line) = record.line_number { + write!(out, ":{line}")?; } + out.reset()?; + need_colon_sep = true; } if need_colon_sep { write!(out, ": ")?; diff --git a/crates/cli/src/subcommands/init.rs b/crates/cli/src/subcommands/init.rs index 19cec472996..be3552c6abe 100644 --- a/crates/cli/src/subcommands/init.rs +++ b/crates/cli/src/subcommands/init.rs @@ -759,10 +759,10 @@ fn clone_github_template(repo_input: &str, target: &Path, is_server_only: bool) let mut callbacks = git2::RemoteCallbacks::new(); callbacks.credentials(|_url, username_from_url, allowed_types| { - if allowed_types.contains(git2::CredentialType::SSH_KEY) { - if let Some(username) = username_from_url { - return git2::Cred::ssh_key_from_agent(username); - } + if allowed_types.contains(git2::CredentialType::SSH_KEY) + && let Some(username) = username_from_url + { + return git2::Cred::ssh_key_from_agent(username); } if allowed_types.contains(git2::CredentialType::USER_PASS_PLAINTEXT) { return git2::Cred::userpass_plaintext("", ""); @@ -828,10 +828,10 @@ fn update_package_json(dir: &Path, package_name: &str) -> anyhow::Result<()> { package["name"] = json!(package_name); // Update spacetimedb version if it exists in dependencies - if let Some(deps) = package.get_mut("dependencies") { - if deps.get("spacetimedb").is_some() { - deps["spacetimedb"] = json!(format!("^{}", get_spacetimedb_typescript_version())); - } + if let Some(deps) = package.get_mut("dependencies") + && deps.get("spacetimedb").is_some() + { + deps["spacetimedb"] = json!(format!("^{}", get_spacetimedb_typescript_version())); } let updated_content = serde_json::to_string_pretty(&package)?; @@ -864,40 +864,40 @@ fn update_cargo_toml_name(dir: &Path, package_name: &str) -> anyhow::Result<()> .map(|c| if c.is_alphanumeric() || c == '_' { c } else { '_' }) .collect::(); - if let Some(package_item) = doc.get_mut("package") { - if let Some(package_table) = package_item.as_table_mut() { - package_table["name"] = value(safe_name); - if let Some(edition_item) = package_table.get_mut("edition") { - if edition_uses_workspace(edition_item) { - *edition_item = value(embedded::get_workspace_edition()); - } - } + if let Some(package_item) = doc.get_mut("package") + && let Some(package_table) = package_item.as_table_mut() + { + package_table["name"] = value(safe_name); + if let Some(edition_item) = package_table.get_mut("edition") + && edition_uses_workspace(edition_item) + { + *edition_item = value(embedded::get_workspace_edition()); } } - if let Some(deps_item) = doc.get_mut("dependencies") { - if let Some(deps_table) = deps_item.as_table_mut() { - let keys: Vec = deps_table.iter().map(|(k, _)| k.to_string()).collect(); - for key in keys { - if let Some(dep_item) = deps_table.get_mut(&key) { - if dependency_uses_workspace(dep_item) { - if has_path(dep_item) { - if key == "spacetimedb" { - if let Some(version) = embedded::get_workspace_dependency_version(&key) { - set_dependency_version(dep_item, version, true); - } - } else if key == "spacetimedb-sdk" { - set_dependency_version(dep_item, patch_wildcard.as_str(), true); - } - continue; - } - - if uses_workspace(dep_item) { - if let Some(version) = embedded::get_workspace_dependency_version(&key) { - set_dependency_version(dep_item, version, key == "spacetimedb"); - } + if let Some(deps_item) = doc.get_mut("dependencies") + && let Some(deps_table) = deps_item.as_table_mut() + { + let keys: Vec = deps_table.iter().map(|(k, _)| k.to_string()).collect(); + for key in keys { + if let Some(dep_item) = deps_table.get_mut(&key) + && dependency_uses_workspace(dep_item) + { + if has_path(dep_item) { + if key == "spacetimedb" { + if let Some(version) = embedded::get_workspace_dependency_version(&key) { + set_dependency_version(dep_item, version, true); } + } else if key == "spacetimedb-sdk" { + set_dependency_version(dep_item, patch_wildcard.as_str(), true); } + continue; + } + + if uses_workspace(dep_item) + && let Some(version) = embedded::get_workspace_dependency_version(&key) + { + set_dependency_version(dep_item, version, key == "spacetimedb"); } } } @@ -977,20 +977,20 @@ fn find_first_csproj(dir: &Path) -> anyhow::Result> { /// Remove every under any fn remove_all_project_references(project: &mut Element) { for node in project.children.iter_mut() { - if let XMLNode::Element(item_group) = node { - if item_group.name == "ItemGroup" { - item_group - .children - .retain(|n| !matches!(n, XMLNode::Element(el) if el.name == "ProjectReference")); - } + if let XMLNode::Element(item_group) = node + && item_group.name == "ItemGroup" + { + item_group + .children + .retain(|n| !matches!(n, XMLNode::Element(el) if el.name == "ProjectReference")); } } // Optional: prune empty ItemGroups project.children.retain(|n| { - if let XMLNode::Element(el) = n { - if el.name == "ItemGroup" { - return el.children.iter().any(|c| matches!(c, XMLNode::Element(_))); - } + if let XMLNode::Element(el) = n + && el.name == "ItemGroup" + { + return el.children.iter().any(|c| matches!(c, XMLNode::Element(_))); } true }); @@ -1000,19 +1000,18 @@ fn remove_all_project_references(project: &mut Element) { fn upsert_packageref(project: &mut Element, include: &str, version: &str) { // Try to find an existing PackageReference for node in project.children.iter_mut() { - if let XMLNode::Element(item_group) = node { - if item_group.name == "ItemGroup" { - if let Some(XMLNode::Element(existing)) = item_group.children.iter_mut().find(|n| { - matches!(n, - XMLNode::Element(e) - if e.name == "PackageReference" - && e.attributes.get("Include").map(|v| v == include).unwrap_or(false) - ) - }) { - existing.attributes.insert("Version".to_string(), version.to_string()); - return; - } - } + if let XMLNode::Element(item_group) = node + && item_group.name == "ItemGroup" + && let Some(XMLNode::Element(existing)) = item_group.children.iter_mut().find(|n| { + matches!(n, + XMLNode::Element(e) + if e.name == "PackageReference" + && e.attributes.get("Include").map(|v| v == include).unwrap_or(false) + ) + }) + { + existing.attributes.insert("Version".to_string(), version.to_string()); + return; } } // Otherwise create one in (or create) an ItemGroup @@ -1650,15 +1649,15 @@ fn has_path(item: &Item) -> bool { } fn set_dependency_version(item: &mut Item, version: &str, remove_path: bool) { - if let Item::Value(val) = item { - if let Some(inline) = val.as_inline_table_mut() { - inline.remove("workspace"); - if remove_path { - inline.remove("path"); - } - inline.insert("version", toml_edit::Value::from(version.to_string())); - return; + if let Item::Value(val) = item + && let Some(inline) = val.as_inline_table_mut() + { + inline.remove("workspace"); + if remove_path { + inline.remove("path"); } + inline.insert("version", toml_edit::Value::from(version.to_string())); + return; } if let Item::Table(table) = item { diff --git a/crates/cli/src/subcommands/logs.rs b/crates/cli/src/subcommands/logs.rs index 4f8ed6a5b01..5ad3baa27d2 100644 --- a/crates/cli/src/subcommands/logs.rs +++ b/crates/cli/src/subcommands/logs.rs @@ -206,28 +206,28 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E let mut need_space_before_filename = false; let mut need_colon_sep = false; let dimmed = ColorSpec::new().set_dimmed(true).clone(); - if let Some(function) = record.function { - if function != SENTINEL { - out.set_color(&dimmed)?; - write!(out, "{function}")?; - out.reset()?; - need_space_before_filename = true; - need_colon_sep = true; - } + if let Some(function) = record.function + && function != SENTINEL + { + out.set_color(&dimmed)?; + write!(out, "{function}")?; + out.reset()?; + need_space_before_filename = true; + need_colon_sep = true; } - if let Some(filename) = record.filename { - if filename != SENTINEL { - out.set_color(&dimmed)?; - if need_space_before_filename { - write!(out, " ")?; - } - write!(out, "{filename}")?; - if let Some(line) = record.line_number { - write!(out, ":{line}")?; - } - out.reset()?; - need_colon_sep = true; + if let Some(filename) = record.filename + && filename != SENTINEL + { + out.set_color(&dimmed)?; + if need_space_before_filename { + write!(out, " ")?; + } + write!(out, "{filename}")?; + if let Some(line) = record.line_number { + write!(out, ":{line}")?; } + out.reset()?; + need_colon_sep = true; } if need_colon_sep { write!(out, ": ")?; diff --git a/crates/cli/tests/util.rs b/crates/cli/tests/util.rs index 1bb5a99fb15..b010b80d27d 100644 --- a/crates/cli/tests/util.rs +++ b/crates/cli/tests/util.rs @@ -122,10 +122,10 @@ impl SpacetimeDbGuard { while Instant::now() < deadline { let url = format!("{}/v1/ping", self.host_url); - if let Ok(resp) = client.get(&url).send() { - if resp.status().is_success() { - return; // Fully ready! - } + if let Ok(resp) = client.get(&url).send() + && resp.status().is_success() + { + return; // Fully ready! } sleep(Duration::from_millis(50)); @@ -141,10 +141,10 @@ impl Drop for SpacetimeDbGuard { let _ = self.child.wait(); // Only print logs if the test is currently panicking - if std::thread::panicking() { - if let Ok(logs) = self.logs.lock() { - eprintln!("\n===== SpacetimeDB child logs (only on failure) =====\n{}\n====================================================", *logs); - } + if std::thread::panicking() + && let Ok(logs) = self.logs.lock() + { + eprintln!("\n===== SpacetimeDB child logs (only on failure) =====\n{}\n====================================================", *logs); } } } diff --git a/crates/client-api/src/lib.rs b/crates/client-api/src/lib.rs index 8c882774461..93e03c1f611 100644 --- a/crates/client-api/src/lib.rs +++ b/crates/client-api/src/lib.rs @@ -131,11 +131,9 @@ impl Host { .await .map_err(log_and_500)??; - if confirmed_read { - if let Some(mut durable_offset) = durable_offset { - let tx_offset = tx_offset.await.map_err(|_| log_and_500("transaction aborted"))?; - durable_offset.wait_for(tx_offset).await.map_err(log_and_500)?; - } + if confirmed_read && let Some(mut durable_offset) = durable_offset { + let tx_offset = tx_offset.await.map_err(|_| log_and_500("transaction aborted"))?; + durable_offset.wait_for(tx_offset).await.map_err(log_and_500)?; } Ok(json) diff --git a/crates/client-api/src/routes/database.rs b/crates/client-api/src/routes/database.rs index b2fc3fbece2..fc62ee3eec3 100644 --- a/crates/client-api/src/routes/database.rs +++ b/crates/client-api/src/routes/database.rs @@ -711,27 +711,26 @@ pub async fn publish( let name_or_identity = name_or_identity .as_ref() .ok_or_else(|| bad_request("Clear database requires database name or identity".into()))?; - if let Ok(identity) = name_or_identity.try_resolve(&ctx).await.map_err(log_and_500)? { - if ctx + if let Ok(identity) = name_or_identity.try_resolve(&ctx).await.map_err(log_and_500)? + && ctx .get_database_by_identity(&identity) .await .map_err(log_and_500)? .is_some() - { - return reset( - State(ctx), - Path(ResetDatabaseParams { - name_or_identity: name_or_identity.clone(), - }), - Query(ResetDatabaseQueryParams { - num_replicas, - host_type, - }), - Extension(auth), - Some(program_bytes), - ) - .await; - } + { + return reset( + State(ctx), + Path(ResetDatabaseParams { + name_or_identity: name_or_identity.clone(), + }), + Query(ResetDatabaseQueryParams { + num_replicas, + host_type, + }), + Extension(auth), + Some(program_bytes), + ) + .await; } } diff --git a/crates/client-api/src/routes/subscribe.rs b/crates/client-api/src/routes/subscribe.rs index 94c152d64db..0e6c87abe45 100644 --- a/crates/client-api/src/routes/subscribe.rs +++ b/crates/client-api/src/routes/subscribe.rs @@ -584,19 +584,17 @@ async fn ws_main_loop( // [`tokio::task::AbortHandle`]s), the reasonable thing to do is to // exit the loop as if the tasks completed normally. res = &mut send_task => { - if let Err(e) = res { - if e.is_panic() { + if let Err(e) = res + && e.is_panic() { panic::resume_unwind(e.into_panic()) } - } break; }, res = &mut recv_task => { - if let Err(e) = res { - if e.is_panic() { + if let Err(e) = res + && e.is_panic() { panic::resume_unwind(e.into_panic()) } - } break; }, diff --git a/crates/commitlog/src/commitlog.rs b/crates/commitlog/src/commitlog.rs index cbf97d96367..ad63043b6f6 100644 --- a/crates/commitlog/src/commitlog.rs +++ b/crates/commitlog/src/commitlog.rs @@ -347,10 +347,10 @@ impl Generic { impl Drop for Generic { fn drop(&mut self) { - if !self.panicked { - if let Err(e) = self.head.commit() { - warn!("failed to commit on drop: {e}"); - } + if !self.panicked + && let Err(e) = self.head.commit() + { + warn!("failed to commit on drop: {e}"); } } } diff --git a/crates/commitlog/src/tests/partial.rs b/crates/commitlog/src/tests/partial.rs index e4020f93006..0f2f27055b1 100644 --- a/crates/commitlog/src/tests/partial.rs +++ b/crates/commitlog/src/tests/partial.rs @@ -334,13 +334,13 @@ where total_txs += 1; } let res = log.commit(); - if let Err(Some(os)) = res.as_ref().map_err(|e| e.raw_os_error()) { - if os == ENOSPC { - debug!("fill: ignoring ENOSPC"); - seen_enospc = true; - log.commit().unwrap(); - continue; - } + if let Err(Some(os)) = res.as_ref().map_err(|e| e.raw_os_error()) + && os == ENOSPC + { + debug!("fill: ignoring ENOSPC"); + seen_enospc = true; + log.commit().unwrap(); + continue; } res.unwrap(); } diff --git a/crates/core/src/auth/token_validation.rs b/crates/core/src/auth/token_validation.rs index 2e50cb317e2..907f65ddb5a 100644 --- a/crates/core/src/auth/token_validation.rs +++ b/crates/core/src/auth/token_validation.rs @@ -166,14 +166,14 @@ impl TokenValidator for BasicTokenValidator { async fn validate_token(&self, token: &str) -> Result { // This validates everything but the issuer. let claims = self.public_key.validate_token(token).await?; - if let Some(expected_issuer) = &self.issuer { - if claims.issuer != *expected_issuer { - return Err(TokenValidationError::Other(anyhow::anyhow!( - "Issuer mismatch: got {:?}, expected {:?}", - claims.issuer, - expected_issuer - ))); - } + if let Some(expected_issuer) = &self.issuer + && claims.issuer != *expected_issuer + { + return Err(TokenValidationError::Other(anyhow::anyhow!( + "Issuer mismatch: got {:?}, expected {:?}", + claims.issuer, + expected_issuer + ))); } Ok(claims) } diff --git a/crates/core/src/db/relational_db.rs b/crates/core/src/db/relational_db.rs index c89a0c81226..6c2977e15dd 100644 --- a/crates/core/src/db/relational_db.rs +++ b/crates/core/src/db/relational_db.rs @@ -899,12 +899,11 @@ impl RelationalDB { /// This requires a small amount of additional logic when restoring from a snapshot /// to ensure we don't restore a snapshot more recent than the durable TX offset. fn maybe_do_snapshot(&self, tx_data: &TxData) { - if let Some(snapshot_worker) = &self.snapshot_worker { - if let Some(tx_offset) = tx_data.tx_offset() { - if tx_offset % SNAPSHOT_FREQUENCY == 0 { - snapshot_worker.request_snapshot(); - } - } + if let Some(snapshot_worker) = &self.snapshot_worker + && let Some(tx_offset) = tx_data.tx_offset() + && tx_offset % SNAPSHOT_FREQUENCY == 0 + { + snapshot_worker.request_snapshot(); } } @@ -1830,10 +1829,10 @@ pub async fn snapshot_watching_commitlog_compressor( let snapshot_offset = *snapshot_rx.borrow_and_update(); let durability = durability.clone(); - if let Some(snap_tx) = &mut snap_tx { - if let Err(err) = snap_tx.try_send(snapshot_offset) { - tracing::warn!("failed to send offset {snapshot_offset} after snapshot creation: {err}"); - } + if let Some(snap_tx) = &mut snap_tx + && let Err(err) = snap_tx.try_send(snapshot_offset) + { + tracing::warn!("failed to send offset {snapshot_offset} after snapshot creation: {err}"); } let res: io::Result<_> = asyncify(move || { @@ -1866,10 +1865,10 @@ pub async fn snapshot_watching_commitlog_compressor( }; prev_snapshot_offset = snapshot_offset; - if let Some((clog_tx, last_compressed_segment)) = clog_tx.as_mut().zip(last_compressed_segment) { - if let Err(err) = clog_tx.try_send(last_compressed_segment) { - tracing::warn!("failed to send offset {last_compressed_segment} after compression: {err}"); - } + if let Some((clog_tx, last_compressed_segment)) = clog_tx.as_mut().zip(last_compressed_segment) + && let Err(err) = clog_tx.try_send(last_compressed_segment) + { + tracing::warn!("failed to send offset {last_compressed_segment} after compression: {err}"); } } } diff --git a/crates/core/src/error.rs b/crates/core/src/error.rs index d0a7e2cd4d4..8ed8d4ee2c0 100644 --- a/crates/core/src/error.rs +++ b/crates/core/src/error.rs @@ -155,10 +155,10 @@ pub enum DBError { impl DBError { pub fn get_auth_error(&self) -> Option<&ErrorLang> { - if let Self::VmUser(err) = self { - if err.kind == ErrorKind::Unauthorized { - return Some(err); - } + if let Self::VmUser(err) = self + && err.kind == ErrorKind::Unauthorized + { + return Some(err); } None } diff --git a/crates/core/src/host/host_controller.rs b/crates/core/src/host/host_controller.rs index 3d1e5118103..b3a72b6f144 100644 --- a/crates/core/src/host/host_controller.rs +++ b/crates/core/src/host/host_controller.rs @@ -254,11 +254,11 @@ impl HostController { ) -> anyhow::Result> { // Try a read lock first. { - if let Ok(guard) = self.acquire_read_lock(replica_id).await { - if let Some(host) = &*guard { - trace!("cached host {}/{}", database.database_identity, replica_id); - return Ok(host.module.subscribe()); - } + if let Ok(guard) = self.acquire_read_lock(replica_id).await + && let Some(host) = &*guard + { + trace!("cached host {}/{}", database.database_identity, replica_id); + return Ok(host.module.subscribe()); } } diff --git a/crates/core/src/host/module_host.rs b/crates/core/src/host/module_host.rs index 6f9da4fd81b..7e0f8e9d40e 100644 --- a/crates/core/src/host/module_host.rs +++ b/crates/core/src/host/module_host.rs @@ -1289,10 +1289,8 @@ impl ModuleHost { // Decrement the number of subscribers for each view this caller is subscribed to let dec_view_subscribers = |tx: &mut MutTxId| { - if drop_view_subscribers { - if let Err(err) = tx.unsubscribe_views(caller_identity) { - log::error!("`call_identity_disconnected`: failed to delete client view data: {err}"); - } + if drop_view_subscribers && let Err(err) = tx.unsubscribe_views(caller_identity) { + log::error!("`call_identity_disconnected`: failed to delete client view data: {err}"); } }; diff --git a/crates/core/src/sql/type_check.rs b/crates/core/src/sql/type_check.rs index e302eeabe95..12324686407 100644 --- a/crates/core/src/sql/type_check.rs +++ b/crates/core/src/sql/type_check.rs @@ -95,16 +95,17 @@ fn resolve_type(field: &FieldExpr, ty: AlgebraicType) -> Result Result<(), PlanError> { /// Patch the type of the field if the type is an `Identity`, `ConnectionId` or `Enum` fn patch_type(lhs: &FieldOp, ty_lhs: &mut Typed, ty_rhs: &Typed) -> Result<(), PlanError> { - if let FieldOp::Field(lhs_field) = lhs { - if let Some(ty) = ty_rhs.ty() { - if ty.is_sum() || ty.as_product().is_some_and(|x| x.is_special()) { - ty_lhs.set_ty(resolve_type(lhs_field, ty.clone())?); - } - } + if let FieldOp::Field(lhs_field) = lhs + && let Some(ty) = ty_rhs.ty() + && (ty.is_sum() || ty.as_product().is_some_and(|x| x.is_special())) + { + ty_lhs.set_ty(resolve_type(lhs_field, ty.clone())?); } Ok(()) } diff --git a/crates/core/src/startup.rs b/crates/core/src/startup.rs index ebd8c079fc8..a1cf458a94d 100644 --- a/crates/core/src/startup.rs +++ b/crates/core/src/startup.rs @@ -137,13 +137,13 @@ fn reload_config(conf_file: &ConfigToml, reload_handle: &reload::Handle prev) { - log::info!("reloading log config..."); - prev_time = Some(modified); - if reload_handle.reload(parse_from_file(conf_file)).is_err() { - break; - } + if let Ok(modified) = conf_file.metadata().and_then(|m| m.modified()) + && prev_time.is_none_or(|prev| modified > prev) + { + log::info!("reloading log config..."); + prev_time = Some(modified); + if reload_handle.reload(parse_from_file(conf_file)).is_err() { + break; } } } diff --git a/crates/core/src/subscription/module_subscription_manager.rs b/crates/core/src/subscription/module_subscription_manager.rs index 9764ef818d5..d218249ec48 100644 --- a/crates/core/src/subscription/module_subscription_manager.rs +++ b/crates/core/src/subscription/module_subscription_manager.rs @@ -374,16 +374,16 @@ impl QueriedTableIndexIds { /// Note, different queries may read from the same index. /// Hence we only remove this key from the map if its ref count goes to zero. pub fn delete_index_id(&mut self, table_id: TableId, index_id: IndexId) { - if let Some(ids) = self.ids.get_mut(&table_id) { - if let Some(n) = ids.get_mut(&index_id) { - *n -= 1; + if let Some(ids) = self.ids.get_mut(&table_id) + && let Some(n) = ids.get_mut(&index_id) + { + *n -= 1; - if *n == 0 { - ids.remove(&index_id); + if *n == 0 { + ids.remove(&index_id); - if ids.is_empty() { - self.ids.remove(&table_id); - } + if ids.is_empty() { + self.ids.remove(&table_id); } } } @@ -434,14 +434,14 @@ impl JoinEdges { /// If this query has any join edges, remove them from the map. fn remove_query(&mut self, query: &Query) { for (edge, rhs_val) in query.join_edges() { - if let Some(values) = self.edges.get_mut(&edge) { - if let Some(hashes) = values.get_mut(&rhs_val) { - hashes.remove(&query.hash); - if hashes.is_empty() { - values.remove(&rhs_val); - if values.is_empty() { - self.edges.remove(&edge); - } + if let Some(values) = self.edges.get_mut(&edge) + && let Some(hashes) = values.get_mut(&rhs_val) + { + hashes.remove(&query.hash); + if hashes.is_empty() { + values.remove(&rhs_val); + if values.is_empty() { + self.edges.remove(&edge); } } } @@ -782,10 +782,10 @@ impl SubscriptionManager { /// Remove any clients that have been marked for removal pub fn remove_dropped_clients(&mut self) { for id in self.clients.keys().copied().collect::>() { - if let Some(client) = self.clients.get(&id) { - if client.dropped.load(Ordering::Relaxed) { - self.remove_all_subscriptions(&id); - } + if let Some(client) = self.clients.get(&id) + && client.dropped.load(Ordering::Relaxed) + { + self.remove_all_subscriptions(&id); } } } diff --git a/crates/core/src/vm.rs b/crates/core/src/vm.rs index 39b4c7f8506..549daf1c560 100644 --- a/crates/core/src/vm.rs +++ b/crates/core/src/vm.rs @@ -466,17 +466,17 @@ pub fn check_row_limit( row_est: impl Fn(&Query, &TxId) -> u64, auth: &AuthCtx, ) -> Result<(), DBError> { - if !auth.exceed_row_limit() { - if let Some(limit) = db.row_limit(tx)? { - let mut estimate: u64 = 0; - for query in queries { - estimate = estimate.saturating_add(row_est(query, tx)); - } - if estimate > limit { - return Err(DBError::Other(anyhow::anyhow!( - "Estimated cardinality ({estimate} rows) exceeds limit ({limit} rows)" - ))); - } + if !auth.exceed_row_limit() + && let Some(limit) = db.row_limit(tx)? + { + let mut estimate: u64 = 0; + for query in queries { + estimate = estimate.saturating_add(row_est(query, tx)); + } + if estimate > limit { + return Err(DBError::Other(anyhow::anyhow!( + "Estimated cardinality ({estimate} rows) exceeds limit ({limit} rows)" + ))); } } Ok(()) diff --git a/crates/datastore/src/locking_tx_datastore/mut_tx.rs b/crates/datastore/src/locking_tx_datastore/mut_tx.rs index e53792458f2..205f522c5c8 100644 --- a/crates/datastore/src/locking_tx_datastore/mut_tx.rs +++ b/crates/datastore/src/locking_tx_datastore/mut_tx.rs @@ -268,18 +268,18 @@ impl MutTxId { }; // Check for precise index seek - if let (Bound::Included(low_val), Bound::Included(up_val)) = (&lower, &upper) { - if low_val == up_val { - // Fetch index metadata - let Some((_, idx, _)) = self.get_table_and_index(index_id) else { - return; - }; - - let cols = idx.index().indexed_columns.clone(); - self.read_sets - .insert_index_scan(table_id, cols, low_val.clone(), view.clone()); + if let (Bound::Included(low_val), Bound::Included(up_val)) = (&lower, &upper) + && low_val == up_val + { + // Fetch index metadata + let Some((_, idx, _)) = self.get_table_and_index(index_id) else { return; - } + }; + + let cols = idx.index().indexed_columns.clone(); + self.read_sets + .insert_index_scan(table_id, cols, low_val.clone(), view.clone()); + return; } // Everything else is treated as a table scan diff --git a/crates/durability/src/imp/local.rs b/crates/durability/src/imp/local.rs index 016281d160c..39e1f5197b7 100644 --- a/crates/durability/src/imp/local.rs +++ b/crates/durability/src/imp/local.rs @@ -157,10 +157,10 @@ impl Local { info!("close local durability"); drop(self.queue); - if let Err(e) = self.persister_task.await { - if e.is_panic() { - return Err(e).context("persister task panicked"); - } + if let Err(e) = self.persister_task.await + && e.is_panic() + { + return Err(e).context("persister task panicked"); } spawn_blocking(move || self.clog.flush_and_sync()) @@ -197,11 +197,8 @@ impl PersisterTask { // require `spawn_blocking`. if self.max_records_in_commit.get() == 1 { self.flush_append(txdata, true).await; - } else { - match self.clog.append(txdata) { - Err(retry) => self.flush_append(retry, false).await, - _ => {} - } + } else if let Err(retry) = self.clog.append(txdata) { + self.flush_append(retry, false).await } trace!("appended txdata"); @@ -277,10 +274,10 @@ impl FlushAndSyncTask { break; }; // Skip if nothing changed. - if let Some(committed) = clog.max_committed_offset() { - if self.offset.borrow().is_some_and(|durable| durable == committed) { - continue; - } + if let Some(committed) = clog.max_committed_offset() + && self.offset.borrow().is_some_and(|durable| durable == committed) + { + continue; } let task = spawn_blocking(move || clog.flush_and_sync()).await; diff --git a/crates/expr/src/check.rs b/crates/expr/src/check.rs index 9c4717f9a9f..45897c4925d 100644 --- a/crates/expr/src/check.rs +++ b/crates/expr/src/check.rs @@ -99,11 +99,11 @@ pub trait TypeChecker { vars.insert(rhs.alias.clone(), rhs.schema.clone()); if let Some(on) = on { - if let Expr::BinOp(BinOp::Eq, a, b) = type_expr(vars, on, Some(&AlgebraicType::Bool))? { - if let (Expr::Field(a), Expr::Field(b)) = (*a, *b) { - join = RelExpr::EqJoin(LeftDeepJoin { lhs, rhs }, a, b); - continue; - } + if let Expr::BinOp(BinOp::Eq, a, b) = type_expr(vars, on, Some(&AlgebraicType::Bool))? + && let (Expr::Field(a), Expr::Field(b)) = (*a, *b) + { + join = RelExpr::EqJoin(LeftDeepJoin { lhs, rhs }, a, b); + continue; } unreachable!("Unreachability guaranteed by parser") } diff --git a/crates/expr/src/expr.rs b/crates/expr/src/expr.rs index 451b9f3498c..58f6d647829 100644 --- a/crates/expr/src/expr.rs +++ b/crates/expr/src/expr.rs @@ -261,10 +261,10 @@ pub struct Relvar { impl CollectViews for RelExpr { fn collect_views(&self, views: &mut HashSet) { self.visit(&mut |expr| { - if let Self::RelVar(Relvar { schema, .. }) = expr { - if let Some(info) = &schema.view_info { - views.insert(info.view_id); - } + if let Self::RelVar(Relvar { schema, .. }) = expr + && let Some(info) = &schema.view_info + { + views.insert(info.view_id); } }); } diff --git a/crates/fs-utils/src/dir_trie.rs b/crates/fs-utils/src/dir_trie.rs index 03b93eda13c..14e6aa7bdeb 100644 --- a/crates/fs-utils/src/dir_trie.rs +++ b/crates/fs-utils/src/dir_trie.rs @@ -167,11 +167,11 @@ impl DirTrie { return Ok(()); } - if let Some(src_repo) = src_repo { - if self.try_hardlink_from(src_repo, file_id)? { - counter.objects_hardlinked += 1; - return Ok(()); - } + if let Some(src_repo) = src_repo + && self.try_hardlink_from(src_repo, file_id)? + { + counter.objects_hardlinked += 1; + return Ok(()); } let mut file = self.open_entry_writer(file_id)?; diff --git a/crates/pg/src/encoder.rs b/crates/pg/src/encoder.rs index f5a6ed990ed..e3d574392e3 100644 --- a/crates/pg/src/encoder.rs +++ b/crates/pg/src/encoder.rs @@ -137,13 +137,12 @@ impl TypedWriter for PsqlFormatter<'_> { value: ValueWithType, ) -> Result<(), Self::Error> { // Is a simple enum? - if let AlgebraicType::Sum(sum) = &ty.field.algebraic_type { - if sum.is_simple_enum() { - if let Some(variant_name) = name { - self.encoder.encode_field(&variant_name)?; - return Ok(()); - } - } + if let AlgebraicType::Sum(sum) = &ty.field.algebraic_type + && sum.is_simple_enum() + && let Some(variant_name) = name + { + self.encoder.encode_field(&variant_name)?; + return Ok(()); } let PsqlChars { start, sep, end, quote } = ty.client.format_chars(); diff --git a/crates/physical-plan/src/plan.rs b/crates/physical-plan/src/plan.rs index 81933829ef9..5a55db8ae4a 100644 --- a/crates/physical-plan/src/plan.rs +++ b/crates/physical-plan/src/plan.rs @@ -754,10 +754,10 @@ impl PhysicalPlan { match self { Self::Filter(input, expr) => { expr.visit(&mut |expr| { - if let PhysicalExpr::Field(TupleField { label: var, .. }) = expr { - if !reqs.contains(var) { - reqs.push(*var); - } + if let PhysicalExpr::Field(TupleField { label: var, .. }) = expr + && !reqs.contains(var) + { + reqs.push(*var); } }); Self::Filter(Box::new(input.introduce_semijoins(reqs)), expr) @@ -936,12 +936,11 @@ impl PhysicalPlan { Self::Filter(input, expr) => { let mut cols: Vec<_> = cols.iter().collect(); expr.visit(&mut |plan| { - if let PhysicalExpr::BinOp(BinOp::Eq, expr, value) = plan { - if let (PhysicalExpr::Field(proj), PhysicalExpr::Value(..)) = (&**expr, &**value) { - if proj.label == *label { - cols.push(proj.field_pos.into()); - } - } + if let PhysicalExpr::BinOp(BinOp::Eq, expr, value) = plan + && let (PhysicalExpr::Field(proj), PhysicalExpr::Value(..)) = (&**expr, &**value) + && proj.label == *label + { + cols.push(proj.field_pos.into()); } }); input.returns_distinct_values(label, &ColSet::from_iter(cols)) diff --git a/crates/physical-plan/src/rules.rs b/crates/physical-plan/src/rules.rs index 37905f41e27..b212ee70453 100644 --- a/crates/physical-plan/src/rules.rs +++ b/crates/physical-plan/src/rules.rs @@ -272,10 +272,10 @@ impl RewriteRule for PushConstEq { let is_filter = |plan: &PhysicalPlan| { !plan.any(&|plan| !matches!(plan, PhysicalPlan::TableScan(..) | PhysicalPlan::Filter(..))) }; - if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(_, expr, value)) = plan { - if let (PhysicalExpr::Field(TupleField { label, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value) { - return (input.has_table_scan(Some(label)) && !is_filter(input)).then_some(*label); - } + if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(_, expr, value)) = plan + && let (PhysicalExpr::Field(TupleField { label, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value) + { + return (input.has_table_scan(Some(label)) && !is_filter(input)).then_some(*label); } None } @@ -340,11 +340,10 @@ impl RewriteRule for PushConstAnd { }; if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan { return exprs.iter().find_map(|expr| { - if let PhysicalExpr::BinOp(_, expr, value) = expr { - if let (PhysicalExpr::Field(TupleField { label, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value) - { - return (input.has_table_scan(Some(label)) && !is_filter(input)).then_some(*label); - } + if let PhysicalExpr::BinOp(_, expr, value) = expr + && let (PhysicalExpr::Field(TupleField { label, .. }), PhysicalExpr::Value(_)) = (&**expr, &**value) + { + return (input.has_table_scan(Some(label)) && !is_filter(input)).then_some(*label); } None }); @@ -358,15 +357,13 @@ impl RewriteRule for PushConstAnd { let mut leaf_exprs = vec![]; let mut root_exprs = vec![]; for expr in exprs { - if let PhysicalExpr::BinOp(_, lhs, value) = &expr { - if let (PhysicalExpr::Field(TupleField { label: var, .. }), PhysicalExpr::Value(_)) = + if let PhysicalExpr::BinOp(_, lhs, value) = &expr + && let (PhysicalExpr::Field(TupleField { label: var, .. }), PhysicalExpr::Value(_)) = (&**lhs, &**value) - { - if var == &relvar { - leaf_exprs.push(expr); - continue; - } - } + && var == &relvar + { + leaf_exprs.push(expr); + continue; } root_exprs.push(expr); } @@ -421,8 +418,8 @@ impl RewriteRule for IxScanEq { type Info = (IndexId, ColId); fn matches(plan: &PhysicalPlan) -> Option { - if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(BinOp::Eq, expr, value)) = plan { - if let PhysicalPlan::TableScan( + if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(BinOp::Eq, expr, value)) = plan + && let PhysicalPlan::TableScan( TableScan { schema, limit: None, @@ -430,47 +427,43 @@ impl RewriteRule for IxScanEq { }, _, ) = &**input - { - if let (PhysicalExpr::Field(TupleField { field_pos: pos, .. }), PhysicalExpr::Value(_)) = - (&**expr, &**value) - { - return schema.indexes.iter().find_map( - |IndexSchema { - index_id, - index_algorithm, - .. - }| { - // TODO: Support prefix scans - if index_algorithm.columns().len() == 1 { - Some((*index_id, index_algorithm.find_col_index(*pos)?)) - } else { - None - } - }, - ); - } - } + && let (PhysicalExpr::Field(TupleField { field_pos: pos, .. }), PhysicalExpr::Value(_)) = + (&**expr, &**value) + { + return schema.indexes.iter().find_map( + |IndexSchema { + index_id, + index_algorithm, + .. + }| { + // TODO: Support prefix scans + if index_algorithm.columns().len() == 1 { + Some((*index_id, index_algorithm.find_col_index(*pos)?)) + } else { + None + } + }, + ); } None } fn rewrite(plan: PhysicalPlan, (index_id, col_id): Self::Info) -> Result { - if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(BinOp::Eq, _, value)) = plan { - if let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, var) = *input { - if let PhysicalExpr::Value(v) = *value { - return Ok(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id, - prefix: vec![], - arg: Sarg::Eq(col_id, v), - }, - var, - )); - } - } + if let PhysicalPlan::Filter(input, PhysicalExpr::BinOp(BinOp::Eq, _, value)) = plan + && let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, var) = *input + && let PhysicalExpr::Value(v) = *value + { + return Ok(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id, + prefix: vec![], + arg: Sarg::Eq(col_id, v), + }, + var, + )); } bail!("{INVARIANT_VIOLATION}: Failed to create single column index scan from equality condition") } @@ -492,8 +485,8 @@ impl RewriteRule for IxScanAnd { type Info = (IndexId, usize, ColId); fn matches(plan: &PhysicalPlan) -> Option { - if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan { - if let PhysicalPlan::TableScan( + if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan + && let PhysicalPlan::TableScan( TableScan { schema, limit: None, @@ -501,60 +494,56 @@ impl RewriteRule for IxScanAnd { }, _, ) = &**input - { - return exprs.iter().enumerate().find_map(|(i, expr)| { - if let PhysicalExpr::BinOp(BinOp::Eq, lhs, value) = expr { - if let (PhysicalExpr::Field(TupleField { field_pos: pos, .. }), PhysicalExpr::Value(_)) = - (&**lhs, &**value) - { - return schema.indexes.iter().find_map( - |IndexSchema { - index_id, - index_algorithm, - .. - }| { - index_algorithm - .columns() - // TODO: Support prefix scans - .as_singleton() - .filter(|col_id| col_id.idx() == *pos) - .map(|col_id| (*index_id, i, col_id)) - }, - ); - } - } - None - }); - } + { + return exprs.iter().enumerate().find_map(|(i, expr)| { + if let PhysicalExpr::BinOp(BinOp::Eq, lhs, value) = expr + && let (PhysicalExpr::Field(TupleField { field_pos: pos, .. }), PhysicalExpr::Value(_)) = + (&**lhs, &**value) + { + return schema.indexes.iter().find_map( + |IndexSchema { + index_id, + index_algorithm, + .. + }| { + index_algorithm + .columns() + // TODO: Support prefix scans + .as_singleton() + .filter(|col_id| col_id.idx() == *pos) + .map(|col_id| (*index_id, i, col_id)) + }, + ); + } + None + }); } None } fn rewrite(plan: PhysicalPlan, (index_id, i, col_id): Self::Info) -> Result { - if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, mut exprs)) = plan { - if let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input { - if let PhysicalExpr::BinOp(BinOp::Eq, _, value) = exprs.swap_remove(i) { - if let PhysicalExpr::Value(v) = *value { - return Ok(PhysicalPlan::Filter( - Box::new(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id, - prefix: vec![], - arg: Sarg::Eq(col_id, v), - }, - label, - )), - match exprs.len() { - 1 => exprs.swap_remove(0), - _ => PhysicalExpr::LogOp(LogOp::And, exprs), - }, - )); - } - } - } + if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, mut exprs)) = plan + && let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input + && let PhysicalExpr::BinOp(BinOp::Eq, _, value) = exprs.swap_remove(i) + && let PhysicalExpr::Value(v) = *value + { + return Ok(PhysicalPlan::Filter( + Box::new(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id, + prefix: vec![], + arg: Sarg::Eq(col_id, v), + }, + label, + )), + match exprs.len() { + 1 => exprs.swap_remove(0), + _ => PhysicalExpr::LogOp(LogOp::And, exprs), + }, + )); } bail!("{INVARIANT_VIOLATION}: Failed to create single column index scan from conjunction") } @@ -636,84 +625,79 @@ impl RewriteRule for IxScanEq2Col { fn rewrite(plan: PhysicalPlan, info: Self::Info) -> Result { match info.cols.as_slice() { [(i, a), (j, b)] => { - if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan { - if let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input { - if let ( - Some(PhysicalExpr::BinOp(BinOp::Eq, _, u)), - Some(PhysicalExpr::BinOp(BinOp::Eq, _, v)), - ) = (exprs.get(*i), exprs.get(*j)) - { - if let (PhysicalExpr::Value(u), PhysicalExpr::Value(v)) = (&**u, &**v) { - return Ok(match exprs.len() { - n @ 0 | n @ 1 => { - bail!("{INVARIANT_VIOLATION}: Cannot create 2-column index scan from {n} conditions") - } - // If there are only 2 conditions in this filter, - // we replace the filter with an index scan. - 2 => PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone())], - arg: Sarg::Eq(*b, v.clone()), - }, - label, - ), - // If there are 3 conditions in this filter, - // we create an index scan from 2 of them. - // The original conjunction is no longer well defined, - // because it only has a single operand now. - // Hence we must replace it with its operand. - 3 => PhysicalPlan::Filter( - Box::new(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone())], - arg: Sarg::Eq(*b, v.clone()), - }, - label, - )), - exprs - .into_iter() - .enumerate() - .find(|(pos, _)| pos != i && pos != j) - .map(|(_, expr)| expr) - .unwrap(), - ), - // If there are more than 3 conditions in this filter, - // we remove the 2 conditions used in the index scan. - // The remaining conditions still form a conjunction. - _ => PhysicalPlan::Filter( - Box::new(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone())], - arg: Sarg::Eq(*b, v.clone()), - }, - label, - )), - PhysicalExpr::LogOp( - LogOp::And, - exprs - .into_iter() - .enumerate() - .filter(|(pos, _)| pos != i && pos != j) - .map(|(_, expr)| expr) - .collect(), - ), - ), - }); - } + if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan + && let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input + && let (Some(PhysicalExpr::BinOp(BinOp::Eq, _, u)), Some(PhysicalExpr::BinOp(BinOp::Eq, _, v))) = + (exprs.get(*i), exprs.get(*j)) + && let (PhysicalExpr::Value(u), PhysicalExpr::Value(v)) = (&**u, &**v) + { + return Ok(match exprs.len() { + n @ 0 | n @ 1 => { + bail!("{INVARIANT_VIOLATION}: Cannot create 2-column index scan from {n} conditions") } - } + // If there are only 2 conditions in this filter, + // we replace the filter with an index scan. + 2 => PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone())], + arg: Sarg::Eq(*b, v.clone()), + }, + label, + ), + // If there are 3 conditions in this filter, + // we create an index scan from 2 of them. + // The original conjunction is no longer well defined, + // because it only has a single operand now. + // Hence we must replace it with its operand. + 3 => PhysicalPlan::Filter( + Box::new(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone())], + arg: Sarg::Eq(*b, v.clone()), + }, + label, + )), + exprs + .into_iter() + .enumerate() + .find(|(pos, _)| pos != i && pos != j) + .map(|(_, expr)| expr) + .unwrap(), + ), + // If there are more than 3 conditions in this filter, + // we remove the 2 conditions used in the index scan. + // The remaining conditions still form a conjunction. + _ => PhysicalPlan::Filter( + Box::new(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone())], + arg: Sarg::Eq(*b, v.clone()), + }, + label, + )), + PhysicalExpr::LogOp( + LogOp::And, + exprs + .into_iter() + .enumerate() + .filter(|(pos, _)| pos != i && pos != j) + .map(|(_, expr)| expr) + .collect(), + ), + ), + }); } bail!("{INVARIANT_VIOLATION}: Failed to create 2-column index scan") } @@ -816,87 +800,82 @@ impl RewriteRule for IxScanEq3Col { fn rewrite(plan: PhysicalPlan, info: Self::Info) -> Result { match info.cols.as_slice() { [(i, a), (j, b), (k, c)] => { - if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan { - if let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input { - if let ( - Some(PhysicalExpr::BinOp(BinOp::Eq, _, u)), - Some(PhysicalExpr::BinOp(BinOp::Eq, _, v)), - Some(PhysicalExpr::BinOp(BinOp::Eq, _, w)), - ) = (exprs.get(*i), exprs.get(*j), exprs.get(*k)) - { - if let (PhysicalExpr::Value(u), PhysicalExpr::Value(v), PhysicalExpr::Value(w)) = - (&**u, &**v, &**w) - { - return Ok(match exprs.len() { - n @ 0 | n @ 1 | n @ 2 => { - bail!("{INVARIANT_VIOLATION}: Cannot create 3-column index scan from {n} conditions") - } - // If there are only 3 conditions in this filter, - // we replace the filter with an index scan. - 3 => PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone()), (*b, v.clone())], - arg: Sarg::Eq(*c, w.clone()), - }, - label, - ), - // If there are 4 conditions in this filter, - // we create an index scan from 3 of them. - // The original conjunction is no longer well defined, - // because it only has a single operand now. - // Hence we must replace it with its operand. - 4 => PhysicalPlan::Filter( - Box::new(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone()), (*b, v.clone())], - arg: Sarg::Eq(*c, w.clone()), - }, - label, - )), - exprs - .into_iter() - .enumerate() - .find(|(pos, _)| pos != i && pos != j && pos != k) - .map(|(_, expr)| expr) - .unwrap(), - ), - // If there are more than 4 conditions in this filter, - // we remove the 3 conditions used in the index scan. - // The remaining conditions still form a conjunction. - _ => PhysicalPlan::Filter( - Box::new(PhysicalPlan::IxScan( - IxScan { - schema, - limit, - delta, - index_id: info.index_id, - prefix: vec![(*a, u.clone()), (*b, v.clone())], - arg: Sarg::Eq(*c, w.clone()), - }, - label, - )), - PhysicalExpr::LogOp( - LogOp::And, - exprs - .into_iter() - .enumerate() - .filter(|(pos, _)| pos != i && pos != j && pos != k) - .map(|(_, expr)| expr) - .collect(), - ), - ), - }); - } + if let PhysicalPlan::Filter(input, PhysicalExpr::LogOp(LogOp::And, exprs)) = plan + && let PhysicalPlan::TableScan(TableScan { schema, limit, delta }, label) = *input + && let ( + Some(PhysicalExpr::BinOp(BinOp::Eq, _, u)), + Some(PhysicalExpr::BinOp(BinOp::Eq, _, v)), + Some(PhysicalExpr::BinOp(BinOp::Eq, _, w)), + ) = (exprs.get(*i), exprs.get(*j), exprs.get(*k)) + && let (PhysicalExpr::Value(u), PhysicalExpr::Value(v), PhysicalExpr::Value(w)) = (&**u, &**v, &**w) + { + return Ok(match exprs.len() { + n @ 0 | n @ 1 | n @ 2 => { + bail!("{INVARIANT_VIOLATION}: Cannot create 3-column index scan from {n} conditions") } - } + // If there are only 3 conditions in this filter, + // we replace the filter with an index scan. + 3 => PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone()), (*b, v.clone())], + arg: Sarg::Eq(*c, w.clone()), + }, + label, + ), + // If there are 4 conditions in this filter, + // we create an index scan from 3 of them. + // The original conjunction is no longer well defined, + // because it only has a single operand now. + // Hence we must replace it with its operand. + 4 => PhysicalPlan::Filter( + Box::new(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone()), (*b, v.clone())], + arg: Sarg::Eq(*c, w.clone()), + }, + label, + )), + exprs + .into_iter() + .enumerate() + .find(|(pos, _)| pos != i && pos != j && pos != k) + .map(|(_, expr)| expr) + .unwrap(), + ), + // If there are more than 4 conditions in this filter, + // we remove the 3 conditions used in the index scan. + // The remaining conditions still form a conjunction. + _ => PhysicalPlan::Filter( + Box::new(PhysicalPlan::IxScan( + IxScan { + schema, + limit, + delta, + index_id: info.index_id, + prefix: vec![(*a, u.clone()), (*b, v.clone())], + arg: Sarg::Eq(*c, w.clone()), + }, + label, + )), + PhysicalExpr::LogOp( + LogOp::And, + exprs + .into_iter() + .enumerate() + .filter(|(pos, _)| pos != i && pos != j && pos != k) + .map(|(_, expr)| expr) + .collect(), + ), + ), + }); } bail!("{INVARIANT_VIOLATION}: Failed to create 3-column index scan") } @@ -1040,41 +1019,39 @@ impl RewriteRule for PullFilterAboveHashJoin { }, Semi::All, ) = plan + && let PhysicalPlan::Filter(input, _) = &**rhs + && let PhysicalPlan::TableScan(TableScan { schema, .. }, _) = &**input { - if let PhysicalPlan::Filter(input, _) = &**rhs { - if let PhysicalPlan::TableScan(TableScan { schema, .. }, _) = &**input { - return ((lhs.is_delta_scan() - || matches!(**lhs, PhysicalPlan::Filter(..)) - || matches!(**lhs, PhysicalPlan::IxScan(..))) - && schema.indexes.iter().any(|schema| { - schema - .index_algorithm - .columns() - .as_singleton() - .is_some_and(|col_id| col_id.idx() == rhs_field.field_pos) - })) - .then_some(()); - } - } + return ((lhs.is_delta_scan() + || matches!(**lhs, PhysicalPlan::Filter(..)) + || matches!(**lhs, PhysicalPlan::IxScan(..))) + && schema.indexes.iter().any(|schema| { + schema + .index_algorithm + .columns() + .as_singleton() + .is_some_and(|col_id| col_id.idx() == rhs_field.field_pos) + })) + .then_some(()); } None } fn rewrite(plan: Self::Plan, _: Self::Info) -> Result { - if let PhysicalPlan::HashJoin(join, semi) = plan { - if let PhysicalPlan::Filter(rhs, expr) = *join.rhs { - return Ok(PhysicalPlan::Filter( - Box::new(PhysicalPlan::HashJoin( - HashJoin { - lhs: join.lhs, - rhs, - ..join - }, - semi, - )), - expr, - )); - } + if let PhysicalPlan::HashJoin(join, semi) = plan + && let PhysicalPlan::Filter(rhs, expr) = *join.rhs + { + return Ok(PhysicalPlan::Filter( + Box::new(PhysicalPlan::HashJoin( + HashJoin { + lhs: join.lhs, + rhs, + ..join + }, + semi, + )), + expr, + )); } bail!("{INVARIANT_VIOLATION}: Failed to pull filter above hash join") } @@ -1122,8 +1099,8 @@ impl RewriteRule for HashToIxJoin { } fn rewrite(plan: PhysicalPlan, (rhs_index, rhs_field): Self::Info) -> Result { - if let PhysicalPlan::HashJoin(join, semi) = plan { - if let PhysicalPlan::TableScan( + if let PhysicalPlan::HashJoin(join, semi) = plan + && let PhysicalPlan::TableScan( TableScan { schema: rhs, limit: None, @@ -1131,21 +1108,20 @@ impl RewriteRule for HashToIxJoin { }, rhs_label, ) = *join.rhs - { - return Ok(PhysicalPlan::IxJoin( - IxJoin { - lhs: join.lhs, - rhs, - rhs_label, - rhs_index, - rhs_field, - rhs_delta, - unique: false, - lhs_field: join.lhs_field, - }, - semi, - )); - } + { + return Ok(PhysicalPlan::IxJoin( + IxJoin { + lhs: join.lhs, + rhs, + rhs_label, + rhs_index, + rhs_field, + rhs_delta, + unique: false, + lhs_field: join.lhs_field, + }, + semi, + )); } bail!("{INVARIANT_VIOLATION}: Failed to rewrite hash join as index join") } diff --git a/crates/schema/src/type_for_generate.rs b/crates/schema/src/type_for_generate.rs index 6c2a259f080..4b0ad39137c 100644 --- a/crates/schema/src/type_for_generate.rs +++ b/crates/schema/src/type_for_generate.rs @@ -499,7 +499,7 @@ impl TypespaceForGenerateBuilder<'_> { .get(ref_) .ok_or_else(|| ErrorStream::from(ClientCodegenError::TypeRefError(TypeRefError::InvalidTypeRef(ref_))))?; - let result = match def { + match def { AlgebraicType::Product(product) => product .elements .iter() @@ -543,9 +543,7 @@ impl TypespaceForGenerateBuilder<'_> { ty: PrettyAlgebraicType(def.clone()), } .into()), - }; - - result + } } /// Process an element/variant of a product/sum type. diff --git a/crates/snapshot/src/lib.rs b/crates/snapshot/src/lib.rs index 5452c8a448d..579c7c3a3ef 100644 --- a/crates/snapshot/src/lib.rs +++ b/crates/snapshot/src/lib.rs @@ -1089,17 +1089,17 @@ impl SnapshotRepository { if read.is_compressed() { return Ok(()); // Already compressed } - if let Some(hash) = hash { - if let Some(old_path) = old.get(&hash) { - let old_file = CompressReader::new(o_rdonly().open(old_path)?)?; - if old_file.is_compressed() { - std::fs::hard_link(old_path, src.with_extension("_tmp"))?; - std::fs::rename(src.with_extension("_tmp"), src)?; - if let Some(stats) = stats { - stats.hardlinked += 1; - } - return Ok(()); + if let Some(hash) = hash + && let Some(old_path) = old.get(&hash) + { + let old_file = CompressReader::new(o_rdonly().open(old_path)?)?; + if old_file.is_compressed() { + std::fs::hard_link(old_path, src.with_extension("_tmp"))?; + std::fs::rename(src.with_extension("_tmp"), src)?; + if let Some(stats) = stats { + stats.hardlinked += 1; } + return Ok(()); } } diff --git a/crates/sql-parser/src/ast/sql.rs b/crates/sql-parser/src/ast/sql.rs index 567b5ec5328..be7b753f395 100644 --- a/crates/sql-parser/src/ast/sql.rs +++ b/crates/sql-parser/src/ast/sql.rs @@ -88,10 +88,10 @@ impl SqlSelect { if self.project.has_unqualified_vars() { return Err(SqlUnsupported::UnqualifiedNames.into()); } - if let Some(expr) = &self.filter { - if expr.has_unqualified_vars() { - return Err(SqlUnsupported::UnqualifiedNames.into()); - } + if let Some(expr) = &self.filter + && expr.has_unqualified_vars() + { + return Err(SqlUnsupported::UnqualifiedNames.into()); } Ok(self) } diff --git a/crates/sql-parser/src/ast/sub.rs b/crates/sql-parser/src/ast/sub.rs index bd6fde0d98c..fb1168176e5 100644 --- a/crates/sql-parser/src/ast/sub.rs +++ b/crates/sql-parser/src/ast/sub.rs @@ -31,10 +31,10 @@ impl SqlSelect { if self.project.has_unqualified_vars() { return Err(SqlUnsupported::UnqualifiedNames.into()); } - if let Some(expr) = &self.filter { - if expr.has_unqualified_vars() { - return Err(SqlUnsupported::UnqualifiedNames.into()); - } + if let Some(expr) = &self.filter + && expr.has_unqualified_vars() + { + return Err(SqlUnsupported::UnqualifiedNames.into()); } Ok(self) } diff --git a/crates/standalone/src/control_db.rs b/crates/standalone/src/control_db.rs index b6d9f2821ac..8333695a42a 100644 --- a/crates/standalone/src/control_db.rs +++ b/crates/standalone/src/control_db.rs @@ -246,12 +246,12 @@ impl ControlDb { // Remove all existing names. if let Some(value) = rev_tx.get(database_identity_bytes)? { for domain in decode_domain_names(&value)? { - if let Some(ref owner) = domain_owner(tld_tx, &domain)? { - if owner != owner_identity { - transaction::abort(AbortWith::Domain(SetDomainsResult::PermissionDenied { - domain: domain.clone(), - }))?; - } + if let Some(ref owner) = domain_owner(tld_tx, &domain)? + && owner != owner_identity + { + transaction::abort(AbortWith::Domain(SetDomainsResult::PermissionDenied { + domain: domain.clone(), + }))?; } dns_tx.remove(domain.to_lowercase().as_bytes())?; } @@ -260,12 +260,12 @@ impl ControlDb { // Insert the new names. for domain in domain_names { - if let Some(ref owner) = domain_owner(tld_tx, domain)? { - if owner != owner_identity { - transaction::abort(AbortWith::Domain(SetDomainsResult::PermissionDenied { - domain: domain.clone(), - }))?; - } + if let Some(ref owner) = domain_owner(tld_tx, domain)? + && owner != owner_identity + { + transaction::abort(AbortWith::Domain(SetDomainsResult::PermissionDenied { + domain: domain.clone(), + }))?; } tld_tx.insert(domain.tld().to_lowercase().as_bytes(), &owner_identity.to_byte_array())?; dns_tx.insert(domain.to_lowercase().as_bytes(), &database_identity_bytes)?; diff --git a/crates/table/src/pointer_map.rs b/crates/table/src/pointer_map.rs index ea5523b8813..c0f173197aa 100644 --- a/crates/table/src/pointer_map.rs +++ b/crates/table/src/pointer_map.rs @@ -278,7 +278,7 @@ impl PointerMap { /// /// Returns whether the association was deleted. pub fn remove(&mut self, hash: RowHash, ptr: RowPointer) -> bool { - let ret = 'fun: { + 'fun: { let Entry::Occupied(mut entry) = self.map.entry(hash) else { break 'fun false; }; @@ -309,9 +309,7 @@ impl PointerMap { } true - }; - - ret + } } } diff --git a/crates/table/src/table_index/multimap.rs b/crates/table/src/table_index/multimap.rs index 51dad1d95b4..76d5b63a462 100644 --- a/crates/table/src/table_index/multimap.rs +++ b/crates/table/src/table_index/multimap.rs @@ -118,11 +118,11 @@ impl<'a, K, V> Iterator for MultiMapRangeIter<'a, K, V> { fn next(&mut self) -> Option { loop { - if let Some(inner) = self.inner.as_mut() { - if let Some(val) = inner.next() { - // While the inner iterator has elements, yield them. - return Some(val); - } + if let Some(inner) = self.inner.as_mut() + && let Some(val) = inner.next() + { + // While the inner iterator has elements, yield them. + return Some(val); } // This makes the iterator fused. diff --git a/crates/testing/src/lib.rs b/crates/testing/src/lib.rs index f99a46f4769..3a63371e3c3 100644 --- a/crates/testing/src/lib.rs +++ b/crates/testing/src/lib.rs @@ -28,25 +28,26 @@ pub fn invoke_cli(paths: &SpacetimePaths, args: &[&str]) { .map(|v| v.eq_ignore_ascii_case("true")) .unwrap_or(false); - if use_custom && cmd == "generate" { - if let Ok(custom_path) = env::var("CUSTOM_SPACETIMEDB_PATH") { - // Call the dev CLI exactly like the manual command: - // cargo run --bin spacetimedb-cli -- generate ... - let status = Command::new("cargo") - .current_dir(&custom_path) // Ensure we run in the custom path directory - .arg("run") - .arg("--bin") - .arg("spacetimedb-cli") - .arg("--") - .args(args) // `args` are like ["generate", "--lang", ...] - .status() - .expect("Failed to run custom SpacetimeDB CLI via cargo"); + if use_custom + && cmd == "generate" + && let Ok(custom_path) = env::var("CUSTOM_SPACETIMEDB_PATH") + { + // Call the dev CLI exactly like the manual command: + // cargo run --bin spacetimedb-cli -- generate ... + let status = Command::new("cargo") + .current_dir(&custom_path) // Ensure we run in the custom path directory + .arg("run") + .arg("--bin") + .arg("spacetimedb-cli") + .arg("--") + .args(args) // `args` are like ["generate", "--lang", ...] + .status() + .expect("Failed to run custom SpacetimeDB CLI via cargo"); - assert!(status.success(), "Custom SpacetimeDB CLI failed"); - return; - } - // If CUSTOM_SPACETIMEDB_PATH is missing, fall through to the default behavior. + assert!(status.success(), "Custom SpacetimeDB CLI failed"); + return; } + // If CUSTOM_SPACETIMEDB_PATH is missing, fall through to the default behavior. // Default: run in-process CLI (fast/path-friendly for tests). let config = Config::new_with_localhost(paths.cli_config_dir.cli_toml()); diff --git a/crates/update/src/cli/install.rs b/crates/update/src/cli/install.rs index bc04ab2b3ef..f52f125c24c 100644 --- a/crates/update/src/cli/install.rs +++ b/crates/update/src/cli/install.rs @@ -83,10 +83,10 @@ pub(super) async fn download_and_install( .await? .error_for_status() .map_err(|e| { - if e.status() == Some(reqwest::StatusCode::NOT_FOUND) { - if let Some(version) = &version { - return anyhow::anyhow!(e).context(format!("No release found for version {version}")); - } + if e.status() == Some(reqwest::StatusCode::NOT_FOUND) + && let Some(version) = &version + { + return anyhow::anyhow!(e).context(format!("No release found for version {version}")); } anyhow::anyhow!(e).context("Could not fetch release info") })? diff --git a/crates/vm/src/expr.rs b/crates/vm/src/expr.rs index 23cc59e12d2..d085923658e 100644 --- a/crates/vm/src/expr.rs +++ b/crates/vm/src/expr.rs @@ -1928,11 +1928,11 @@ impl QueryExpr { query: Vec::with_capacity(self.query.len()), }; - if matches!(&*self.query, [Query::IndexJoin(_)]) { - if let Some(Query::IndexJoin(join)) = self.query.pop() { - q.query.push(Query::IndexJoin(join.reorder(row_count))); - return q; - } + if matches!(&*self.query, [Query::IndexJoin(_)]) + && let Some(Query::IndexJoin(join)) = self.query.pop() + { + q.query.push(Query::IndexJoin(join.reorder(row_count))); + return q; } for query in self.query { diff --git a/crates/vm/src/rel_ops.rs b/crates/vm/src/rel_ops.rs index 47250b71d60..088049f33bd 100644 --- a/crates/vm/src/rel_ops.rs +++ b/crates/vm/src/rel_ops.rs @@ -224,12 +224,11 @@ where // If we can relate `KeyLhs` and `KeyRhs`, we have candidate. // If that candidate still has rhs elements, test against the predicate and yield. - if let Some(rvv) = self.map.get_mut(&k) { - if let Some(rhs) = rvv.pop() { - if (self.predicate)(lhs, &rhs) { - return Some((self.projection)(lhs.clone(), rhs)); - } - } + if let Some(rvv) = self.map.get_mut(&k) + && let Some(rhs) = rvv.pop() + && (self.predicate)(lhs, &rhs) + { + return Some((self.projection)(lhs.clone(), rhs)); } self.left = None; continue; diff --git a/sdks/rust/src/db_connection.rs b/sdks/rust/src/db_connection.rs index 6ad86a45ba3..60648fcfa1a 100644 --- a/sdks/rust/src/db_connection.rs +++ b/sdks/rust/src/db_connection.rs @@ -117,7 +117,7 @@ impl DbContextImpl { /// Process a parsed WebSocket message, /// applying its mutations to the client cache and invoking callbacks. fn process_message(&self, msg: ParsedMessage) -> crate::Result<()> { - let res = match msg { + match msg { // Error: treat this as an erroneous disconnect. ParsedMessage::Error(e) => { let disconnect_ctx = self.make_event_ctx(Some(e.clone())); @@ -239,9 +239,7 @@ impl DbContextImpl { .resolve(&ctx, request_id, result); Ok(()) } - }; - - res + } } fn apply_update( From 41044c10f5a5864f69b8d905c1fa9cebed1ffd53 Mon Sep 17 00:00:00 2001 From: Noa Date: Tue, 2 Dec 2025 12:38:46 -0600 Subject: [PATCH 7/7] Bless ui tests --- crates/bindings/tests/ui/tables.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bindings/tests/ui/tables.stderr b/crates/bindings/tests/ui/tables.stderr index 46b2d2271d1..507c0232c8c 100644 --- a/crates/bindings/tests/ui/tables.stderr +++ b/crates/bindings/tests/ui/tables.stderr @@ -166,7 +166,7 @@ error[E0277]: the trait bound `Alpha: IndexScanRangeBounds<(Alpha,), SingleBound note: required by a bound in `RangedIndex::::filter` --> src/table.rs | - | pub fn filter(&self, b: B) -> impl Iterator + | pub fn filter(&self, b: B) -> impl Iterator + use | ------ required by a bound in this associated function | where | B: IndexScanRangeBounds,