Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
max_width = 120
edition = "2021"
style_edition = "2021"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions crates/auth/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ impl TryInto<SpacetimeIdentityClaims> 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 {
Expand Down
36 changes: 18 additions & 18 deletions crates/bench/src/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn table_name<T: BenchTable>(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;
Expand All @@ -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<T: RandomTable>(seed: u64, count: u32, buckets: u64) -> Vec<T> {
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.
Expand All @@ -236,13 +236,13 @@ pub fn create_partly_identical<T: RandomTable>(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
Expand All @@ -253,8 +253,8 @@ pub fn create_random<T: RandomTable>(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()
}
Expand Down Expand Up @@ -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 {}->{}",
Expand Down
8 changes: 4 additions & 4 deletions crates/bench/src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ fn memo_query<F: FnOnce() -> 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
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-macro/src/procedure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-macro/src/reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)))
)));
}
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ pub(crate) fn reducer_impl(args: ReducerArgs, original_function: &ItemFn) -> syn
let lt_where_clause = &lt_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)
}
Expand Down
18 changes: 9 additions & 9 deletions crates/bindings-macro/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-macro/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub(crate) fn view_impl(args: ViewArgs, original_function: &ItemFn) -> syn::Resu
let lt_where_clause = &lt_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)
}
Expand Down
18 changes: 10 additions & 8 deletions crates/bindings-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]`.
///
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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`.
Expand All @@ -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.
Expand Down Expand Up @@ -949,10 +949,12 @@ fn cvt(x: u16) -> Result<()> {
/// before writing a safe and valid `T` to it.
#[inline]
unsafe fn call<T: Copy>(f: impl FnOnce(*mut T) -> u16) -> Result<T> {
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`.
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-typescript/test-app/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions crates/bindings/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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() {
Expand Down
12 changes: 6 additions & 6 deletions crates/bindings/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ static ANONYMOUS_VIEWS: OnceLock<Vec<AnonymousFn>> = 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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1015,7 +1015,7 @@ fn convert_err_to_errno(res: Result<(), Box<str>>, 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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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>()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bindings/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ impl<Tbl: Table, IndexType, Idx: Index> RangedIndex<Tbl, IndexType, Idx> {
/// > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RangedIndex::<Tbl, IndexType, Idx>::filter`
/// > ```
/// <!-- TODO: check if that error is up to date! -->
pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row>
pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row> + use<B, K, Tbl, IndexType, Idx>
where
B: IndexScanRangeBounds<IndexType, K>,
{
Expand Down Expand Up @@ -715,7 +715,7 @@ impl<Tbl: Table, IndexType, Idx: Index> RangedIndexReadOnly<Tbl, IndexType, Idx>
#[doc(hidden)]
pub const __NEW: Self = Self { _marker: PhantomData };

pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row>
pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row> + use<B, K, Tbl, IndexType, Idx>
where
B: IndexScanRangeBounds<IndexType, K>,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings/tests/ui/tables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ error[E0277]: the trait bound `Alpha: IndexScanRangeBounds<(Alpha,), SingleBound
note: required by a bound in `RangedIndex::<Tbl, IndexType, Idx>::filter`
--> src/table.rs
|
| pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row>
| pub fn filter<B, K>(&self, b: B) -> impl Iterator<Item = Tbl::Row> + use<B, K, Tbl, IndexType, Idx>
| ------ required by a bound in this associated function
| where
| B: IndexScanRangeBounds<IndexType, K>,
Expand Down
Loading