diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index cd9f77e175f..2b00c970499 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -258,7 +258,10 @@ mod tests { use crate::transaction::SignableTransaction; use alloy_eips::eip2930::{AccessList, AccessListItem}; use alloy_primitives::{hex, Address, Bytes, Signature, TxKind, B256, U256}; - use std::{fs, path::PathBuf, vec, vec::Vec}; + use std::{fs, path::PathBuf, vec}; + + #[cfg(not(feature = "std"))] + use std::vec::Vec; #[test] #[cfg(feature = "k256")] diff --git a/crates/serde/src/num.rs b/crates/serde/src/num.rs index c1eaf2a6bef..160d185a8be 100644 --- a/crates/serde/src/num.rs +++ b/crates/serde/src/num.rs @@ -292,9 +292,11 @@ pub mod u128_hex_or_decimal_opt { /// serde functions for handling `Vec` as [U128](alloy_primitives::U128) pub mod u128_hex_or_decimal_vec { + #[cfg(not(feature = "std"))] use alloc::vec::Vec; use alloy_primitives::U128; use serde::{Deserialize, Deserializer, Serialize, Serializer}; + /// Deserializes an `u128` accepting a hex quantity string with optional 0x prefix or /// a number pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> @@ -314,10 +316,12 @@ pub mod u128_hex_or_decimal_vec { /// serde functions for handling `Vec>` as [U128](alloy_primitives::U128) pub mod u128_hex_or_decimal_vec_vec_opt { - use alloc::vec::Vec; use alloy_primitives::U128; use serde::{Deserialize, Deserializer, Serialize, Serializer}; + #[cfg(not(feature = "std"))] + use alloc::vec::Vec; + /// Deserializes an `u128` accepting a hex quantity string with optional 0x prefix or /// a number pub fn deserialize<'de, D>(deserializer: D) -> Result>>, D::Error> @@ -353,9 +357,11 @@ pub mod u128_hex_or_decimal_vec_vec_opt { #[cfg(test)] mod tests { use super::*; - use alloc::{vec, vec::Vec}; use serde::{Deserialize, Serialize}; + #[cfg(not(feature = "std"))] + use alloc::{vec, vec::Vec}; + #[test] fn test_hex_u64() { #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] diff --git a/crates/transport-http/src/hyper.rs b/crates/transport-http/src/hyper.rs index b5b33844582..2590b6b667d 100644 --- a/crates/transport-http/src/hyper.rs +++ b/crates/transport-http/src/hyper.rs @@ -40,17 +40,16 @@ where if status != hyper::StatusCode::OK { return Err(TransportErrorKind::custom_str(&format!( - r#"HTTP error: {} with body: "{}""#, - status, - String::from_utf8_lossy(body.as_ref()) + "HTTP error {status} with body: {}", + String::from_utf8_lossy(&body) ))); } // Deser a Box from the body. If deser fails, return the // body as a string in the error. If the body is not UTF8, this will // fail and give the empty string in the error. - serde_json::from_slice(body.as_ref()).map_err(|err| { - TransportError::deser_err(err, std::str::from_utf8(body.as_ref()).unwrap_or("")) + serde_json::from_slice(&body).map_err(|err| { + TransportError::deser_err(err, String::from_utf8_lossy(body.as_ref())) }) }) }