From 657108c9887945ce8132dba2fe305ce0a55d0a72 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 25 Nov 2024 17:49:13 +0100 Subject: [PATCH] transaction-error: Fix warning for bpf build, feature gating (#3742) #### Problem There's a warning when building solana-transaction-error in bpf: ``` warning: unused import: `std::io` --> sdk/transaction-error/src/lib.rs:8:93 | 8 | ...or, solana_sanitize::SanitizeError, std::io, ``` This is because the part that uses std::io is gated on `not(target_os = "solana")`. Also, clippy is failing on this crate individually because the "serde" feature is not enabled on solana-instruction. #### Summary of changes Fix those two things. --- sdk/transaction-error/Cargo.toml | 2 +- sdk/transaction-error/src/lib.rs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/transaction-error/Cargo.toml b/sdk/transaction-error/Cargo.toml index 33c24903c1666b..862282446be5e4 100644 --- a/sdk/transaction-error/Cargo.toml +++ b/sdk/transaction-error/Cargo.toml @@ -21,7 +21,7 @@ solana-sanitize = { workspace = true } [features] frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] -serde = ["dep:serde", "dep:serde_derive"] +serde = ["dep:serde", "dep:serde_derive", "solana-instruction/serde"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/transaction-error/src/lib.rs b/sdk/transaction-error/src/lib.rs index 26587523109fbc..433a48b0122e31 100644 --- a/sdk/transaction-error/src/lib.rs +++ b/sdk/transaction-error/src/lib.rs @@ -4,9 +4,7 @@ use serde_derive::{Deserialize, Serialize}; #[cfg(feature = "frozen-abi")] use solana_frozen_abi_macro::{AbiEnumVisitor, AbiExample}; -use { - core::fmt, solana_instruction::error::InstructionError, solana_sanitize::SanitizeError, std::io, -}; +use {core::fmt, solana_instruction::error::InstructionError, solana_sanitize::SanitizeError}; pub type TransactionResult = Result; @@ -356,7 +354,7 @@ impl From for SanitizeMessageError { #[cfg(not(target_os = "solana"))] #[derive(Debug)] pub enum TransportError { - IoError(io::Error), + IoError(std::io::Error), TransactionError(TransactionError), Custom(String), } @@ -386,8 +384,8 @@ impl fmt::Display for TransportError { } #[cfg(not(target_os = "solana"))] -impl From for TransportError { - fn from(e: io::Error) -> Self { +impl From for TransportError { + fn from(e: std::io::Error) -> Self { TransportError::IoError(e) } }