From 0e0c9afa1be5caf2863293badda6e69ad7336b79 Mon Sep 17 00:00:00 2001 From: ordian Date: Thu, 14 Sep 2023 20:40:02 +0200 Subject: [PATCH 1/5] bounded-collections: fix build for no_std + serde --- bounded-collections/src/bounded_btree_set.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bounded-collections/src/bounded_btree_set.rs b/bounded-collections/src/bounded_btree_set.rs index c4eb255e..9888dcc8 100644 --- a/bounded-collections/src/bounded_btree_set.rs +++ b/bounded-collections/src/bounded_btree_set.rs @@ -50,7 +50,7 @@ where D: Deserializer<'de>, { // Create a visitor to visit each element in the sequence - struct BTreeSetVisitor(std::marker::PhantomData<(T, S)>); + struct BTreeSetVisitor(PhantomData<(T, S)>); impl<'de, T, S> Visitor<'de> for BTreeSetVisitor where @@ -59,7 +59,7 @@ where { type Value = BTreeSet; - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("a sequence") } @@ -396,10 +396,10 @@ where } } -#[cfg(all(test, feature = "std"))] +#[cfg(test)] mod test { use super::*; - use crate::ConstU32; + use crate::{alloc::string::ToString as _, ConstU32}; use alloc::{vec, vec::Vec}; use codec::CompactLen; From a3c4d5e1a4f776a74308773a8e11c90e5365e32c Mon Sep 17 00:00:00 2001 From: ordian Date: Thu, 14 Sep 2023 21:11:44 +0200 Subject: [PATCH 2/5] put serde test under feature --- bounded-collections/src/bounded_btree_set.rs | 82 +++++++++++--------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/bounded-collections/src/bounded_btree_set.rs b/bounded-collections/src/bounded_btree_set.rs index 9888dcc8..c966bce8 100644 --- a/bounded-collections/src/bounded_btree_set.rs +++ b/bounded-collections/src/bounded_btree_set.rs @@ -399,7 +399,7 @@ where #[cfg(test)] mod test { use super::*; - use crate::{alloc::string::ToString as _, ConstU32}; + use crate::ConstU32; use alloc::{vec, vec::Vec}; use codec::CompactLen; @@ -586,48 +586,56 @@ mod test { } } - #[test] - fn test_serializer() { - let mut c = BoundedBTreeSet::>::new(); - c.try_insert(0).unwrap(); - c.try_insert(1).unwrap(); - c.try_insert(2).unwrap(); - - assert_eq!(serde_json::json!(&c).to_string(), r#"[0,1,2]"#); - } + #[cfg(feature = "serde")] + mod serde { + use super::*; + use crate::alloc::string::ToString as _; - #[test] - fn test_deserializer() { - let c: Result>, serde_json::error::Error> = serde_json::from_str(r#"[0,1,2]"#); - assert!(c.is_ok()); - let c = c.unwrap(); + #[test] + fn test_serializer() { + let mut c = BoundedBTreeSet::>::new(); + c.try_insert(0).unwrap(); + c.try_insert(1).unwrap(); + c.try_insert(2).unwrap(); - assert_eq!(c.len(), 3); - assert!(c.contains(&0)); - assert!(c.contains(&1)); - assert!(c.contains(&2)); - } + assert_eq!(serde_json::json!(&c).to_string(), r#"[0,1,2]"#); + } - #[test] - fn test_deserializer_bound() { - let c: Result>, serde_json::error::Error> = serde_json::from_str(r#"[0,1,2]"#); - assert!(c.is_ok()); - let c = c.unwrap(); + #[test] + fn test_deserializer() { + let c: Result>, serde_json::error::Error> = + serde_json::from_str(r#"[0,1,2]"#); + assert!(c.is_ok()); + let c = c.unwrap(); + + assert_eq!(c.len(), 3); + assert!(c.contains(&0)); + assert!(c.contains(&1)); + assert!(c.contains(&2)); + } - assert_eq!(c.len(), 3); - assert!(c.contains(&0)); - assert!(c.contains(&1)); - assert!(c.contains(&2)); - } + #[test] + fn test_deserializer_bound() { + let c: Result>, serde_json::error::Error> = + serde_json::from_str(r#"[0,1,2]"#); + assert!(c.is_ok()); + let c = c.unwrap(); + + assert_eq!(c.len(), 3); + assert!(c.contains(&0)); + assert!(c.contains(&1)); + assert!(c.contains(&2)); + } - #[test] - fn test_deserializer_failed() { - let c: Result>, serde_json::error::Error> = - serde_json::from_str(r#"[0,1,2,3,4]"#); + #[test] + fn test_deserializer_failed() { + let c: Result>, serde_json::error::Error> = + serde_json::from_str(r#"[0,1,2,3,4]"#); - match c { - Err(msg) => assert_eq!(msg.to_string(), "out of bounds at line 1 column 11"), - _ => unreachable!("deserializer must raise error"), + match c { + Err(msg) => assert_eq!(msg.to_string(), "out of bounds at line 1 column 11"), + _ => unreachable!("deserializer must raise error"), + } } } } From 5f9e2673f854c66991f0dba96e0d00027722a29a Mon Sep 17 00:00:00 2001 From: ordian Date: Sun, 17 Sep 2023 21:01:18 +0200 Subject: [PATCH 3/5] try something --- .github/workflows/ci.yml | 1 + uint/Cargo.toml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81de60cc..3bf72198 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 - run: rustup target add wasm32-unknown-unknown + - run: rustup target add mips64-unknown-linux-gnuabi64 - name: Test no-default-features uses: actions-rs/cargo@v1 diff --git a/uint/Cargo.toml b/uint/Cargo.toml index 36f3de1b..78e28721 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -10,6 +10,9 @@ readme = "README.md" edition = "2021" rust-version = "1.56.1" +[package.metadata.cross.target.mips64-unknown-linux-gnuabi64] +build-std = true + [dependencies] byteorder = { version = "1.4.2", default-features = false } crunchy = { version = "0.2.2", default-features = false } From f02baa1114a3cfbdee0c30c14269f10d83145aee Mon Sep 17 00:00:00 2001 From: ordian Date: Sun, 17 Sep 2023 21:07:08 +0200 Subject: [PATCH 4/5] try something else --- .github/workflows/ci.yml | 4 ++-- uint/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bf72198..57da5eff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 - run: rustup target add wasm32-unknown-unknown - - run: rustup target add mips64-unknown-linux-gnuabi64 + - run: rustup target add mips64-unknown-linux-muslabi64 - name: Test no-default-features uses: actions-rs/cargo@v1 @@ -123,7 +123,7 @@ jobs: with: use-cross: true command: test - args: -p uint --target=mips64-unknown-linux-gnuabi64 + args: -p uint --target=mips64-unknown-linux-muslabi64 test_windows: name: Test Windows diff --git a/uint/Cargo.toml b/uint/Cargo.toml index 78e28721..d6c0a5e9 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" edition = "2021" rust-version = "1.56.1" -[package.metadata.cross.target.mips64-unknown-linux-gnuabi64] +[package.metadata.cross.target.mips64-unknown-linux-muslabi64] build-std = true [dependencies] From d4be58c64cf13e26f572f278bfe2f4b5bd2535a4 Mon Sep 17 00:00:00 2001 From: ordian Date: Sun, 17 Sep 2023 21:31:24 +0200 Subject: [PATCH 5/5] try without --- uint/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/uint/Cargo.toml b/uint/Cargo.toml index d6c0a5e9..36f3de1b 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -10,9 +10,6 @@ readme = "README.md" edition = "2021" rust-version = "1.56.1" -[package.metadata.cross.target.mips64-unknown-linux-muslabi64] -build-std = true - [dependencies] byteorder = { version = "1.4.2", default-features = false } crunchy = { version = "0.2.2", default-features = false }