Stoeoef/spade

Spade 2.3.0 doesn't compile

Closed this issue · 1 comments

I updated from spade-2.2.1 to 2.3.0:

adam@Minnesota ~/projects/cdt-rs (main*?) $ cargo update
    Updating crates.io index
      Adding ahash v0.8.6
      Adding allocator-api2 v0.2.16
    Updating bstr v1.7.0 -> v1.8.0
    Updating clap v4.4.7 -> v4.4.8
    Updating clap_builder v4.4.7 -> v4.4.8
    Updating getrandom v0.2.10 -> v0.2.11
      Adding hashbrown v0.14.2
      Adding once_cell v1.18.0
    Updating smallvec v1.11.1 -> v1.11.2
    Updating spade v2.2.1 -> v2.3.0
      Adding version_check v0.9.4
      Adding zerocopy v0.7.25
      Adding zerocopy-derive v0.7.25

adam@Minnesota ~/projects/cdt-rs (main) $ cat Cargo.toml
[package]
name = "cdt-rs"
version = "0.1.0"
authors = ["Adam Getchell <adam@adamgetchell.org>"]
edition = "2021"
description = "Causal Dynamical Triangulations using Constrained Delaunay Triangulations in Rust"
readme = "README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.4.8", features = ["derive"] }
float-ord = "0.3.2"
rand = "0.8.5"
spade = { version = "2.3.0", features = ["serde"] }
assert_cmd = "2.0.12"


[dev-dependencies]
predicates = "3.0.4"

And now my project won't compile:

adam@Minnesota ~/projects/cdt-rs (main*?) $ cargo clean
adam@Minnesota ~/projects/cdt-rs (main*?) $ cargo build
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.150
   Compiling cfg-if v1.0.0
   Compiling anstyle v1.0.4
   Compiling version_check v0.9.4
   Compiling utf8parse v0.2.1
   Compiling autocfg v1.1.0
   Compiling anstyle-parse v0.2.2
   Compiling colorchoice v1.0.0
   Compiling either v1.9.0
   Compiling zerocopy v0.7.25
   Compiling doc-comment v0.3.3
   Compiling serde v1.0.192
   Compiling once_cell v1.18.0
   Compiling ahash v0.8.6
   Compiling num-traits v0.2.17
   Compiling anstyle-query v1.0.0
   Compiling predicates-core v1.0.6
   Compiling anstream v0.6.4
   Compiling itertools v0.11.0
   Compiling heck v0.4.1
   Compiling termtree v0.4.1
   Compiling quote v1.0.33
   Compiling allocator-api2 v0.2.16
   Compiling getrandom v0.2.11
   Compiling clap_lex v0.6.0
   Compiling syn v2.0.39
   Compiling rand_core v0.6.4
   Compiling ppv-lite86 v0.2.17
   Compiling memchr v2.6.4
   Compiling difflib v0.4.0
   Compiling strsim v0.10.0
   Compiling regex-automata v0.4.3
   Compiling hashbrown v0.14.2
   Compiling rand_chacha v0.3.1
   Compiling clap_builder v4.4.8
   Compiling wait-timeout v0.2.0
   Compiling predicates-tree v1.0.9
   Compiling predicates v3.0.4
   Compiling bstr v1.8.0
   Compiling smallvec v1.11.2
   Compiling robust v1.1.0
   Compiling rand v0.8.5
   Compiling float-ord v0.3.2
   Compiling assert_cmd v2.0.12
   Compiling serde_derive v1.0.192
   Compiling clap_derive v4.4.7
   Compiling clap v4.4.8
   Compiling spade v2.3.0
error[E0277]: the trait bound `AtomicUsize: Serialize` is not satisfied
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spade-2.3.0/src/delaunay_core/hint_generator.rs:76:12
     |
76   |     derive(Serialize, Deserialize),
     |            ^^^^^^^^^ the trait `Serialize` is not implemented for `AtomicUsize`
...
80   |     index: AtomicUsize,
     |     ----- required by a bound introduced by this call
     |
     = help: the following other types implement trait `Serialize`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 120 others
note: required by a bound in `serde::ser::SerializeStruct::serialize_field`
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.192/src/ser/mod.rs:1865:12
     |
1859 |     fn serialize_field<T: ?Sized>(
     |        --------------- required by a bound in this associated function
...
1865 |         T: Serialize;
     |            ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field`

error[E0277]: the trait bound `AtomicUsize: Deserialize<'_>` is not satisfied
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spade-2.3.0/src/delaunay_core/hint_generator.rs:80:12
     |
80   |     index: AtomicUsize,
     |            ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `AtomicUsize`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 121 others
note: required by a bound in `next_element`
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.192/src/de/mod.rs:1726:12
     |
1724 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1725 |     where
1726 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`

error[E0277]: the trait bound `AtomicUsize: Deserialize<'_>` is not satisfied
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spade-2.3.0/src/delaunay_core/hint_generator.rs:80:12
     |
80   |     index: AtomicUsize,
     |            ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `AtomicUsize`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 121 others
note: required by a bound in `next_value`
    --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.192/src/de/mod.rs:1865:12
     |
1863 |     fn next_value<V>(&mut self) -> Result<V, Self::Error>
     |        ---------- required by a bound in this associated function
1864 |     where
1865 |         V: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value`

error[E0277]: the trait bound `AtomicUsize: Deserialize<'_>` is not satisfied
  --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spade-2.3.0/src/delaunay_core/hint_generator.rs:80:5
   |
80 |     index: AtomicUsize,
   |     ^^^^^ the trait `Deserialize<'_>` is not implemented for `AtomicUsize`
   |
   = help: the following other types implement trait `Deserialize<'de>`:
             bool
             char
             isize
             i8
             i16
             i32
             i64
             i128
           and 121 others
note: required by a bound in `serde::__private::de::missing_field`
  --> /Users/adam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.192/src/private/de.rs:25:8
   |
23 | pub fn missing_field<'de, V, E>(field: &'static str) -> Result<V, E>
   |        ------------- required by a bound in this function
24 | where
25 |     V: Deserialize<'de>,
   |        ^^^^^^^^^^^^^^^^ required by this bound in `missing_field`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `spade` (lib) due to 4 previous errors

Confirmed!

The issue happens when compiling spade in no-std environments with the serde feature. serde doesn't implement Serialize and Deserialize for the now used core::sync::atomic::AtomicUsize. It does implement it for std::sync::atomic::AtomicUsize though, leading to this confusing error.

I've simply skipped the serialization of that field as a workaround. Its value is only used as a hint, hence it doesn't really affect the functionality.

Issue is fixed in version 2.3.1 (just released)

Thanks for reporting this!