Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bump to Rust 1.82 #2001

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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 .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20 # on a successful run, runs in 8 minutes
container:
image: rust:1.78
image: rust:1.82.0
options: --privileged
# filter for a comment containing 'benchmarks please'
if: ${{ github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, 'benchmarks please')) }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ debug = true
version = "1.0.0-rc2"
edition = "2021"
# update rust-toolchain.toml too!
rust-version = "1.78.0"
rust-version = "1.82.0"

[workspace.dependencies]
spacetimedb = { path = "crates/bindings", version = "1.0.0-rc2" }
Expand Down
2 changes: 1 addition & 1 deletion crates/bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See the README for commands to run.

# sync with: ../../rust-toolchain.toml
FROM rust:1.77.0
FROM rust:1.82.0

RUN apt-get update && \
apt-get install -y valgrind bash && \
Expand Down
2 changes: 2 additions & 0 deletions crates/bindings-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub mod raw {
/// - `prefix = prefix_ptr[..prefix_len]`,
/// - `rstart = rstart_ptr[..rstart_len]`,
/// - `rend = rend_ptr[..rend_len]`,
///
gefjon marked this conversation as resolved.
Show resolved Hide resolved
/// in WASM memory.
///
/// The index itself has a schema/type.
Expand Down Expand Up @@ -171,6 +172,7 @@ pub mod raw {
/// - `prefix = prefix_ptr[..prefix_len]`,
/// - `rstart = rstart_ptr[..rstart_len]`,
/// - `rend = rend_ptr[..rend_len]`,
///
gefjon marked this conversation as resolved.
Show resolved Hide resolved
/// in WASM memory.
///
/// This syscall will delete all the rows found by
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" fn __preinit__00_panic_hook() {
}

/// Our own panic hook logging to the console.
fn panic_hook(info: &panic::PanicInfo) {
fn panic_hook(info: &panic::PanicHookInfo) {
gefjon marked this conversation as resolved.
Show resolved Hide resolved
// Try to look into some string types we know (`&'static str` and `String`).
let msg = match info.payload().downcast_ref::<&'static str>() {
Some(s) => *s,
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<E: fmt::Display> IntoReducerResult for Result<(), E> {

#[diagnostic::on_unimplemented(
message = "the first argument of a reducer must be `&ReducerContext`",
note = "all reducers must take `&ReducerContext` as their first argument"
label = "first argument must be `&ReducerContext`"
gefjon marked this conversation as resolved.
Show resolved Hide resolved
)]
pub trait ReducerContextArg {
// a little hack used in the macro to make error messages nicer. it generates <T as ReducerContextArg>::_ITEM
Expand Down
24 changes: 15 additions & 9 deletions crates/bindings/tests/ui/reducers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ error[E0277]: the reducer argument `Test` does not implement `SpacetimeType`
| ^^^^ the trait `SpacetimeType` is not implemented for `Test`, which is required by `Test: ReducerArg`
|
= note: if you own the type, try adding `#[derive(SpacetimeType)]` to its definition
= help: the following other types implement trait `SpacetimeType`:
&T
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<T>
ArrayType
Box<T>
and $N others
= note: required for `Test` to implement `ReducerArg`

error[E0277]: invalid reducer signature
Expand Down Expand Up @@ -109,8 +119,8 @@ error[E0277]: `Test` is not a valid reducer return type
|
= note: reducers cannot return values -- you can only return `()` or `Result<(), impl Display>`
= help: the following other types implement trait `IntoReducerResult`:
Result<(), E>
()
Result<(), E>

error[E0277]: invalid reducer signature
--> tests/ui/reducers.rs:9:4
Expand Down Expand Up @@ -158,9 +168,9 @@ error[E0277]: the first argument of a reducer must be `&ReducerContext`
--> tests/ui/reducers.rs:23:20
|
23 | fn missing_ctx(_a: u8) {}
| ^^ the trait `ReducerContextArg` is not implemented for `u8`
| ^^ first argument must be `&ReducerContext`
|
= note: all reducers must take `&ReducerContext` as their first argument
= help: the trait `ReducerContextArg` is not implemented for `u8`
= help: the trait `ReducerContextArg` is implemented for `&ReducerContext`

error[E0277]: invalid reducer signature
Expand Down Expand Up @@ -209,13 +219,9 @@ error[E0277]: the first argument of a reducer must be `&ReducerContext`
--> tests/ui/reducers.rs:26:21
|
26 | fn ctx_by_val(_ctx: ReducerContext, _a: u8) {}
| ^^^^^^^^^^^^^^
| |
| the trait `ReducerContextArg` is not implemented for `ReducerContext`
| the trait `ReducerContextArg` is not implemented for `ReducerContext`
| ^^^^^^^^^^^^^^ first argument must be `&ReducerContext`
|
= note: the trait bound `ReducerContext: ReducerContextArg` is not satisfied
= note: all reducers must take `&ReducerContext` as their first argument
= help: the trait `ReducerContextArg` is not implemented for `ReducerContext`
= help: the trait `ReducerContextArg` is implemented for `&ReducerContext`

error[E0277]: invalid reducer signature
Expand Down
74 changes: 42 additions & 32 deletions crates/bindings/tests/ui/tables.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ error[E0277]: the column type `Test` does not implement `SpacetimeType`
|
= note: table column types all must implement `SpacetimeType`
= note: if you own the type, try adding `#[derive(SpacetimeType)]` to its definition
= help: the following other types implement trait `SpacetimeType`:
&T
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<T>
ArrayType
Box<T>
and $N others
= note: required for `Test` to implement `TableColumn`

error[E0277]: the trait bound `Test: SpacetimeType` is not satisfied
Expand All @@ -28,14 +38,14 @@ error[E0277]: the trait bound `Test: SpacetimeType` is not satisfied
|
= note: if you own the type, try adding `#[derive(SpacetimeType)]` to its definition
= help: the following other types implement trait `SpacetimeType`:
bool
i8
i16
i32
i64
i128
u8
u16
&T
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<T>
ArrayType
Box<T>
and $N others

error[E0277]: the trait bound `Test: Deserialize<'de>` is not satisfied
Expand All @@ -48,14 +58,14 @@ error[E0277]: the trait bound `Test: Deserialize<'de>` is not satisfied
| ^^^^ the trait `Deserialize<'de>` is not implemented for `Test`
|
= help: the following other types implement trait `Deserialize<'de>`:
bool
i8
i16
i32
i64
i128
u8
u16
&'de [u8]
&'de str
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<[T]>
ArrayType
and $N others
note: required by a bound in `spacetimedb::spacetimedb_lib::de::SeqProductAccess::next_element`
--> $WORKSPACE/crates/sats/src/de.rs
Expand All @@ -70,14 +80,14 @@ error[E0277]: the trait bound `Test: Deserialize<'_>` is not satisfied
| ^^^^ the trait `Deserialize<'_>` is not implemented for `Test`
|
= help: the following other types implement trait `Deserialize<'de>`:
bool
i8
i16
i32
i64
i128
u8
u16
&'de [u8]
&'de str
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<[T]>
ArrayType
and $N others
note: required by a bound in `get_field_value`
--> $WORKSPACE/crates/sats/src/de.rs
Expand All @@ -92,14 +102,14 @@ error[E0277]: the trait bound `Test: Serialize` is not satisfied
| ^^^^ the trait `Serialize` is not implemented for `Test`
|
= help: the following other types implement trait `Serialize`:
bool
i8
i16
i32
i64
i128
u8
u16
&T
()
Address
AddressForUrl
AlgebraicTypeRef
Arc<T>
ArrayType
ArrayValue
and $N others
note: required by a bound in `spacetimedb::spacetimedb_lib::ser::SerializeNamedProduct::serialize_element`
--> $WORKSPACE/crates/sats/src/ser.rs
Expand Down
1 change: 0 additions & 1 deletion crates/client-api-messages/src/name/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ fn test_tld_is_domain_name() {
assert_eq!(None, dom.sub_domain());
}

#[cfg(feature = "serde")]
gefjon marked this conversation as resolved.
Show resolved Hide resolved
mod serde {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions crates/client-api/src/util/flat_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl Separator for Comma {
const CHAR: char = ',';
}

#[allow(unused)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) enum SemiColon {}
Comment on lines +50 to 52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here? Why is it newly #[allow(unused)]? Did the new rust version somehow reveal that it's unused, where the previous version was unable to detect it? If so, please just remove it.


Expand Down
1 change: 0 additions & 1 deletion crates/commitlog/src/repo/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{
io,
ops::DerefMut as _,
sync::{Arc, RwLock},
u64,
gefjon marked this conversation as resolved.
Show resolved Hide resolved
};

use crate::segment::FileLike;
Expand Down
2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ faststr = "0.2.23"
unindexed_iter_by_col_range_warn = []
# Optional storage engines.
default = ["unindexed_iter_by_col_range_warn"]
# Enable timing for wasm ABI calls
spacetimedb-wasm-instance-env-times = []
Comment on lines +115 to +116
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this come from?

# Enable test helpers and utils
test = []

Expand Down
24 changes: 12 additions & 12 deletions crates/core/src/db/datastore/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ use spacetimedb_table::table::RowRef;
/// The ANSI SQL standard defined three anomalies in 1992:
///
/// - Dirty Reads: Occur when a transaction reads data written by a concurrent
/// uncommitted transaction.
/// uncommitted transaction.
///
/// - Non-repeatable Reads: Occur when a transaction reads the same row twice
/// and gets different data each time because another transaction has modified
/// the data in between the reads.
/// and gets different data each time because another transaction has modified
/// the data in between the reads.
///
/// - Phantom Reads: Occur when a transaction re-executes a query returning a
/// set of rows that satisfy a search condition and finds that the set of rows
/// satisfying the condition has changed due to another recently-committed
/// transaction.
/// set of rows that satisfy a search condition and finds that the set of rows
/// satisfying the condition has changed due to another recently-committed
/// transaction.
gefjon marked this conversation as resolved.
Show resolved Hide resolved
///
/// However since then database researchers have identified and cataloged many
/// more. See:
Expand All @@ -90,14 +90,14 @@ use spacetimedb_table::table::RowRef;
/// The following anomalies are not part of the SQL standard, but are important:
///
/// - Write Skew: Occurs when two transactions concurrently read the same data,
/// make decisions based on that data, and then write back modifications that
/// are mutually inconsistent with the decisions made by the other transaction,
/// despite no direct conflict on the same row being detected. e.g. I read what
/// you write and you read what I write.
/// make decisions based on that data, and then write back modifications that
/// are mutually inconsistent with the decisions made by the other transaction,
/// despite no direct conflict on the same row being detected. e.g. I read what
/// you write and you read what I write.
///
/// - Serialization Anomalies: Occur when the results of a set of transactions
/// are inconsistent with any serial execution of those transactions.

/// are inconsistent with any serial execution of those transactions.
///
gefjon marked this conversation as resolved.
Show resolved Hide resolved
/// PostgreSQL's documentation provides a good summary of the anomalies and
/// isolation levels that it supports:
///
Expand Down
4 changes: 0 additions & 4 deletions crates/core/src/host/module_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ pub trait Module: Send + Sync + 'static {
fn create_instance(&self) -> Self::Instance;
fn replica_ctx(&self) -> &ReplicaContext;
fn close(self);
#[cfg(feature = "tracelogging")]
fn get_trace(&self) -> Option<bytes::Bytes>;
#[cfg(feature = "tracelogging")]
fn stop_trace(&self) -> anyhow::Result<()>;
gefjon marked this conversation as resolved.
Show resolved Hide resolved
}

pub trait ModuleInstance: Send + 'static {
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/host/wasm_common/module_host_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub struct EnergyStats {

pub struct ExecutionTimings {
pub total_duration: Duration,
#[expect(unused)] // TODO: do we want to do something with this?
gefjon marked this conversation as resolved.
Show resolved Hide resolved
pub wasm_instance_env_call_times: CallTimes,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/host/wasmtime/wasm_instance_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ impl WasmInstanceEnv {
/// - `prefix = prefix_ptr[..prefix_len]`,
/// - `rstart = rstart_ptr[..rstart_len]`,
/// - `rend = rend_ptr[..rend_len]`,
///
gefjon marked this conversation as resolved.
Show resolved Hide resolved
/// in WASM memory.
///
/// The index itself has a schema/type.
Expand Down Expand Up @@ -693,6 +694,7 @@ impl WasmInstanceEnv {
/// - `prefix = prefix_ptr[..prefix_len]`,
/// - `rstart = rstart_ptr[..rstart_len]`,
/// - `rend = rend_ptr[..rend_len]`,
///
gefjon marked this conversation as resolved.
Show resolved Hide resolved
/// in WASM memory.
///
/// This syscall will delete all the rows found by
Expand Down
33 changes: 2 additions & 31 deletions crates/lib/src/db/default_element_ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,19 @@ impl<'a> From<(usize, &'a SumTypeVariant)> for ElementLabel<'a> {
///
/// Not a recursive check.
pub fn sum_type_has_default_ordering(ty: &SumType) -> bool {
is_sorted(ty.variants.iter().enumerate().map(ElementLabel::from))
ty.variants.iter().enumerate().map(ElementLabel::from).is_sorted()
}

/// Checks if a product type has the default ordering.
///
/// Not a recursive check.
pub fn product_type_has_default_ordering(ty: &ProductType) -> bool {
is_sorted(ty.elements.iter().enumerate().map(ElementLabel::from))
}

/// Check that an iterator is sorted.
///
/// TODO: remove this when [`Iterator`::is_sorted`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.is_sorted) is stabilized.
fn is_sorted<T: Ord>(mut it: impl Iterator<Item = T>) -> bool {
let Some(mut curr) = it.next() else {
return true;
};
it.all(|next| {
let ordered = curr <= next;
curr = next;
ordered
})
ty.elements.iter().enumerate().map(ElementLabel::from).is_sorted()
}

#[cfg(test)]
mod tests {
use super::*;
use proptest::proptest;

#[test]
fn test_element_label_comparison() {
Expand Down Expand Up @@ -106,18 +91,4 @@ mod tests {
assert!(e > d);
assert!(e == e);
}

proptest! {
#[test]
fn test_is_sorted(v in proptest::collection::vec(0..100, 0..100)) {
let mut v: Vec<i32> = v;
v.sort();
assert!(is_sorted(v.iter()));
}
}

#[test]
fn test_is_not_sorted() {
assert!(!is_sorted([1, 2, 4, 3].iter()));
}
}
Loading
Loading