diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e95a98481..ee18251e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,6 +110,21 @@ jobs: - name: cargo hack run: cargo hack check --feature-powerset --depth 2 + check-no-std: + name: check no_std ${{ matrix.features }} + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: riscv32imac-unknown-none-elf + - uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - run: ./scripts/check_no_std.sh + clippy: runs-on: ubuntu-latest timeout-minutes: 30 diff --git a/Cargo.toml b/Cargo.toml index f012e0135..c6c1fd2af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ quote = "1.0" syn = "2.0" cfg-if = "1.0.0" -derive_more = { version = "1.0", features = ["full"] } +derive_more = { version = "1.0", default-features = false } hex-literal = "0.4" paste = "1.0" num_enum = "0.7" diff --git a/crates/dyn-abi/Cargo.toml b/crates/dyn-abi/Cargo.toml index a28e726c1..705b6a83d 100644 --- a/crates/dyn-abi/Cargo.toml +++ b/crates/dyn-abi/Cargo.toml @@ -31,7 +31,13 @@ itoa.workspace = true winnow.workspace = true # eip712 -derive_more = { workspace = true, optional = true } +derive_more = { workspace = true, optional = true, features = [ + "deref", + "deref_mut", + "from", + "into", + "into_iterator", +] } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 43819fbfe..c41462069 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -30,7 +30,21 @@ tiny-keccak = { workspace = true, features = ["keccak"] } keccak-asm = { workspace = true, optional = true } # macros -derive_more.workspace = true +derive_more = { workspace = true, features = [ + "as_ref", + "add", + "add_assign", + "not", + "deref", + "deref_mut", + "from", + "from_str", + "index", + "index_mut", + "into", + "into_iterator", + "display", +] } cfg-if.workspace = true # rlp diff --git a/crates/primitives/src/postgres.rs b/crates/primitives/src/postgres.rs index 8fa6b6a70..9d058178b 100644 --- a/crates/primitives/src/postgres.rs +++ b/crates/primitives/src/postgres.rs @@ -5,9 +5,10 @@ use super::{FixedBytes, Sign, Signed}; use bytes::{BufMut, BytesMut}; -use derive_more::{Display, Error}; +use derive_more::Display; use postgres_types::{accepts, to_sql_checked, FromSql, IsNull, ToSql, Type, WrongType}; use std::{ + error::Error, iter, str::{from_utf8, FromStr}, }; @@ -55,13 +56,15 @@ fn trim_end_vec(vec: &mut Vec, value: &T) { } /// Error when converting to Postgres types. -#[derive(Clone, Debug, PartialEq, Eq, Display, Error)] +#[derive(Clone, Debug, PartialEq, Eq, Display)] pub enum ToSqlError { /// The value is too large for the type. #[display("Signed<{_0}> value too large to fit target type {_1}")] Overflow(usize, Type), } +impl std::error::Error for ToSqlError {} + /// Convert to Postgres types. /// /// Compatible [Postgres data types][dt] are: diff --git a/scripts/check_no_std.sh b/scripts/check_no_std.sh new file mode 100755 index 000000000..3fcd1c2e8 --- /dev/null +++ b/scripts/check_no_std.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -eo pipefail + +target=riscv32imac-unknown-none-elf +crates=( + alloy-core + alloy-core-sol-test + alloy-dyn-abi + alloy-json-abi + alloy-json-abi + alloy-primitives + # alloy-sol-macro + # alloy-sol-macro-expander + # alloy-sol-macro-input + alloy-sol-type-parser + alloy-sol-types + # syn-solidity +) + +cmd=(cargo +stable hack check --no-default-features --target "$target") +for crate in "${crates[@]}"; do + cmd+=(-p "$crate") +done + +echo "Running: ${cmd[*]}" +"${cmd[@]}"