From 6830edb15e989658fd8c3c0d515f580a3fdc2e26 Mon Sep 17 00:00:00 2001 From: clabby Date: Sat, 21 Sep 2024 19:49:13 -0400 Subject: [PATCH] chore(workspace): Allow stdlib in `cfg(test)` (#548) * chore(workspace): Allow stdlib in `cfg(test)` * rebase * rebase --- crates/common/src/io.rs | 2 -- crates/common/src/lib.rs | 2 +- crates/executor/src/lib.rs | 6 ++---- crates/mpt/src/lib.rs | 2 +- crates/mpt/src/test_util.rs | 2 -- crates/preimage/src/hint.rs | 2 -- crates/preimage/src/lib.rs | 2 +- crates/preimage/src/oracle.rs | 2 -- crates/preimage/src/test_utils.rs | 2 -- 9 files changed, 5 insertions(+), 17 deletions(-) diff --git a/crates/common/src/io.rs b/crates/common/src/io.rs index 6a34cf4b..e0300b66 100644 --- a/crates/common/src/io.rs +++ b/crates/common/src/io.rs @@ -58,8 +58,6 @@ pub fn exit(code: usize) -> ! { #[cfg(not(any(target_arch = "mips", target_arch = "riscv64", target_os = "zkvm")))] mod native_io { - extern crate std; - use crate::{ errors::{IOError, IOResult}, io::FileDescriptor, diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 2d4779fa..958693b5 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -3,7 +3,7 @@ #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(target_arch = "mips", feature(asm_experimental_arch))] -#![no_std] +#![cfg_attr(any(target_arch = "mips", target_arch = "riscv64", target_os = "zkvm"), no_std)] extern crate alloc; diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index 9d309df9..db12ba2f 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -3,7 +3,7 @@ #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![no_std] +#![cfg_attr(not(test), no_std)] extern crate alloc; @@ -646,8 +646,6 @@ where #[cfg(test)] mod test { - extern crate std; - use super::*; use alloy_primitives::{address, b256, hex}; use alloy_rlp::Decodable; @@ -656,7 +654,7 @@ mod test { use kona_mpt::NoopTrieHinter; use op_alloy_genesis::{OP_BASE_FEE_PARAMS, OP_CANYON_BASE_FEE_PARAMS}; use serde::Deserialize; - use std::{collections::HashMap, format}; + use std::collections::HashMap; /// A [TrieProvider] implementation that fetches trie nodes and bytecode from the local /// testdata folder. diff --git a/crates/mpt/src/lib.rs b/crates/mpt/src/lib.rs index 3de42454..fc2830ef 100644 --- a/crates/mpt/src/lib.rs +++ b/crates/mpt/src/lib.rs @@ -3,7 +3,7 @@ #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![no_std] +#![cfg_attr(not(test), no_std)] extern crate alloc; diff --git a/crates/mpt/src/test_util.rs b/crates/mpt/src/test_util.rs index 2716a246..cb590bcb 100644 --- a/crates/mpt/src/test_util.rs +++ b/crates/mpt/src/test_util.rs @@ -1,7 +1,5 @@ //! Testing utilities for `kona-mpt` -extern crate std; - use crate::{ordered_trie_with_encoder, TrieProvider}; use alloc::{collections::BTreeMap, vec::Vec}; use alloy_consensus::{Receipt, ReceiptEnvelope, ReceiptWithBloom, TxEnvelope, TxType}; diff --git a/crates/preimage/src/hint.rs b/crates/preimage/src/hint.rs index e71b9a74..208771c4 100644 --- a/crates/preimage/src/hint.rs +++ b/crates/preimage/src/hint.rs @@ -111,8 +111,6 @@ impl HintReaderServer for HintReader { #[cfg(test)] mod test { - extern crate std; - use super::*; use crate::test_utils::bidirectional_pipe; use alloc::{string::ToString, sync::Arc, vec::Vec}; diff --git a/crates/preimage/src/lib.rs b/crates/preimage/src/lib.rs index ef62c8a6..5bf2ac29 100644 --- a/crates/preimage/src/lib.rs +++ b/crates/preimage/src/lib.rs @@ -3,7 +3,7 @@ #![deny(unused_must_use, rust_2018_idioms)] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] -#![no_std] +#![cfg_attr(not(test), no_std)] extern crate alloc; diff --git a/crates/preimage/src/oracle.rs b/crates/preimage/src/oracle.rs index 70b5c954..a569c12c 100644 --- a/crates/preimage/src/oracle.rs +++ b/crates/preimage/src/oracle.rs @@ -130,8 +130,6 @@ impl PreimageOracleServer for OracleServer { #[cfg(test)] mod test { - extern crate std; - use super::*; use crate::{test_utils::bidirectional_pipe, PreimageKeyType}; use alloc::sync::Arc; diff --git a/crates/preimage/src/test_utils.rs b/crates/preimage/src/test_utils.rs index 57855a59..3a12d7c0 100644 --- a/crates/preimage/src/test_utils.rs +++ b/crates/preimage/src/test_utils.rs @@ -1,7 +1,5 @@ //! Test utilities for the `kona-preimage` crate. -extern crate std; - use os_pipe::{PipeReader, PipeWriter}; use std::io::Result;