From 46f029e65ccd29aa897e16690e8eef4a7ff259ca Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Wed, 17 Aug 2016 17:54:24 +0400 Subject: [PATCH] Use explicit global namespaces in codegen (#1928) * ipc as a deault feature * first part of purge * second part of ns purge --- db/src/traits.rs | 3 --- ethcore/src/client/chain_notify.rs | 4 +--- ethcore/src/client/traits.rs | 4 +--- ethcore/src/types/account_diff.rs | 6 +++--- ethcore/src/types/block_import_error.rs | 3 --- ethcore/src/types/block_queue_info.rs | 4 ---- ethcore/src/types/block_status.rs | 3 --- ethcore/src/types/blockchain_info.rs | 3 --- ethcore/src/types/call_analytics.rs | 4 ---- ethcore/src/types/executed.rs | 3 --- ethcore/src/types/filter.rs | 3 --- ethcore/src/types/ids.rs | 3 --- ethcore/src/types/log_entry.rs | 3 --- ethcore/src/types/receipt.rs | 3 --- ethcore/src/types/state_diff.rs | 5 ++--- ethcore/src/types/trace_filter.rs | 3 --- ethcore/src/types/trace_types/filter.rs | 3 --- ethcore/src/types/trace_types/flat.rs | 2 -- ethcore/src/types/trace_types/localized.rs | 3 --- ethcore/src/types/trace_types/trace.rs | 3 --- ethcore/src/types/transaction.rs | 3 --- ethcore/src/types/transaction_import.rs | 2 -- ethcore/src/types/tree_route.rs | 3 --- ipc/codegen/src/serialization.rs | 14 +++++++------- ipc/hypervisor/src/service.rs.in | 3 --- ipc/rpc/src/binary.rs | 4 ++-- ipc/tests/binary.rs.in | 2 -- ipc/tests/nested.rs.in | 3 --- ipc/tests/service.rs.in | 3 --- ipc/tests/with_attrs.rs.in | 3 --- sync/src/api.rs | 2 -- 31 files changed, 16 insertions(+), 94 deletions(-) diff --git a/db/src/traits.rs b/db/src/traits.rs index bab132450..fe4cd5d44 100644 --- a/db/src/traits.rs +++ b/db/src/traits.rs @@ -16,9 +16,6 @@ //! Ethcore database trait -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; use std::cell::RefCell; pub type IteratorHandle = u32; diff --git a/ethcore/src/client/chain_notify.rs b/ethcore/src/client/chain_notify.rs index 3269d40b8..897c8cfac 100644 --- a/ethcore/src/client/chain_notify.rs +++ b/ethcore/src/client/chain_notify.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use std::collections::VecDeque; -use std::mem; -use ipc::{IpcConfig, BinaryConvertError}; +use ipc::IpcConfig; use util::H256; /// Represents what has to be handled by actor listening to chain events diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index f7bd225bd..44016b94a 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -33,9 +33,7 @@ use executive::Executed; use env_info::LastHashes; use types::call_analytics::CallAnalytics; use block_import_error::BlockImportError; -use std::mem; -use std::collections::VecDeque; -use ipc::{IpcConfig, BinaryConvertError}; +use ipc::IpcConfig; use types::blockchain_info::BlockChainInfo; use types::block_status::BlockStatus; diff --git a/ethcore/src/types/account_diff.rs b/ethcore/src/types/account_diff.rs index f6b368dae..a33c9ddfe 100644 --- a/ethcore/src/types/account_diff.rs +++ b/ethcore/src/types/account_diff.rs @@ -17,10 +17,10 @@ //! Diff between two accounts. use std::cmp::*; -use std::{fmt, mem}; -use std::collections::{VecDeque, BTreeMap}; +use std::fmt; +use std::collections::BTreeMap; use util::{U256, H256, Uint, Bytes}; -use ipc::binary::{BinaryConvertError, BinaryConvertable}; +use ipc::binary::BinaryConvertable; #[derive(Debug, PartialEq, Eq, Clone, Binary)] /// Diff type for specifying a change (or not). diff --git a/ethcore/src/types/block_import_error.rs b/ethcore/src/types/block_import_error.rs index 8b400613f..355f29152 100644 --- a/ethcore/src/types/block_import_error.rs +++ b/ethcore/src/types/block_import_error.rs @@ -16,9 +16,6 @@ //! Block import error related types -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; use error::{ImportError, BlockError, Error}; use std::convert::From; diff --git a/ethcore/src/types/block_queue_info.rs b/ethcore/src/types/block_queue_info.rs index 714f84ece..d299258ce 100644 --- a/ethcore/src/types/block_queue_info.rs +++ b/ethcore/src/types/block_queue_info.rs @@ -16,10 +16,6 @@ //! Block queue info types -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; - /// Block queue status #[derive(Debug, Binary)] pub struct BlockQueueInfo { diff --git a/ethcore/src/types/block_status.rs b/ethcore/src/types/block_status.rs index ca0f47227..bf8218e47 100644 --- a/ethcore/src/types/block_status.rs +++ b/ethcore/src/types/block_status.rs @@ -16,9 +16,6 @@ //! Block status description module -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; - /// General block status #[derive(Debug, Eq, PartialEq, Binary)] pub enum BlockStatus { diff --git a/ethcore/src/types/blockchain_info.rs b/ethcore/src/types/blockchain_info.rs index 4dce766b3..ef8924aec 100644 --- a/ethcore/src/types/blockchain_info.rs +++ b/ethcore/src/types/blockchain_info.rs @@ -16,10 +16,7 @@ //! Blockhain info type definition -use std::mem; -use std::collections::VecDeque; use util::{U256, H256}; -use ipc::binary::BinaryConvertError; use header::BlockNumber; /// Information about the blockchain gathered together. diff --git a/ethcore/src/types/call_analytics.rs b/ethcore/src/types/call_analytics.rs index c738c15bd..d38be0cc7 100644 --- a/ethcore/src/types/call_analytics.rs +++ b/ethcore/src/types/call_analytics.rs @@ -16,10 +16,6 @@ //! Call analytics related types -use std::mem; -use ipc::binary::{BinaryConvertError}; -use std::collections::VecDeque; - /// Options concerning what analytics we run on the call. #[derive(Eq, PartialEq, Default, Clone, Copy, Debug, Binary)] pub struct CallAnalytics { diff --git a/ethcore/src/types/executed.rs b/ethcore/src/types/executed.rs index 0c7b51f2a..b81707581 100644 --- a/ethcore/src/types/executed.rs +++ b/ethcore/src/types/executed.rs @@ -21,10 +21,7 @@ use util::rlp::*; use trace::{VMTrace, FlatTrace}; use types::log_entry::LogEntry; use types::state_diff::StateDiff; -use ipc::binary::BinaryConvertError; use std::fmt; -use std::mem; -use std::collections::VecDeque; /// The type of the call-like instruction. #[derive(Debug, PartialEq, Clone, Binary)] diff --git a/ethcore/src/types/filter.rs b/ethcore/src/types/filter.rs index a2b13d5f9..91338899f 100644 --- a/ethcore/src/types/filter.rs +++ b/ethcore/src/types/filter.rs @@ -16,13 +16,10 @@ //! Blockchain filter -use std::mem; -use std::collections::VecDeque; use util::{Address, H256, Hashable, H2048}; use util::bloom::Bloomable; use client::BlockID; use log_entry::LogEntry; -use ipc::binary::BinaryConvertError; /// Blockchain Filter. #[derive(Binary)] diff --git a/ethcore/src/types/ids.rs b/ethcore/src/types/ids.rs index d62a1e7db..d248a45bc 100644 --- a/ethcore/src/types/ids.rs +++ b/ethcore/src/types/ids.rs @@ -18,9 +18,6 @@ use util::hash::H256; use header::BlockNumber; -use ipc::binary::BinaryConvertError; -use std::mem; -use std::collections::VecDeque; /// Uniquely identifies block. #[derive(Debug, PartialEq, Copy, Clone, Hash, Eq, Binary)] diff --git a/ethcore/src/types/log_entry.rs b/ethcore/src/types/log_entry.rs index 47600fdbb..5267686bc 100644 --- a/ethcore/src/types/log_entry.rs +++ b/ethcore/src/types/log_entry.rs @@ -16,13 +16,10 @@ //! Log entry type definition. -use std::mem; use std::ops::Deref; -use std::collections::VecDeque; use util::{H256, Address, Bytes, HeapSizeOf, Hashable}; use util::rlp::*; use util::bloom::Bloomable; -use ipc::binary::BinaryConvertError; use basic_types::LogBloom; use header::BlockNumber; use ethjson; diff --git a/ethcore/src/types/receipt.rs b/ethcore/src/types/receipt.rs index 07847d1cb..15a8072f3 100644 --- a/ethcore/src/types/receipt.rs +++ b/ethcore/src/types/receipt.rs @@ -16,15 +16,12 @@ //! Receipt -use std::mem; -use std::collections::VecDeque; use util::{H256, U256, Address}; use util::rlp::*; use util::HeapSizeOf; use basic_types::LogBloom; use header::BlockNumber; use log_entry::{LogEntry, LocalizedLogEntry}; -use ipc::binary::BinaryConvertError; /// Information describing execution of a transaction. #[derive(Default, Debug, Clone, Binary)] diff --git a/ethcore/src/types/state_diff.rs b/ethcore/src/types/state_diff.rs index 1f3563804..ee416d1d0 100644 --- a/ethcore/src/types/state_diff.rs +++ b/ethcore/src/types/state_diff.rs @@ -16,12 +16,11 @@ //! State diff module. -use std::{mem, fmt}; +use std::fmt; use std::ops::*; -use std::collections::{VecDeque, BTreeMap}; +use std::collections::BTreeMap; use util::Address; use account_diff::*; -use ipc::binary::BinaryConvertError; #[derive(Debug, PartialEq, Eq, Clone, Binary)] /// Expression for the delta between two system states. Encoded the diff --git a/ethcore/src/types/trace_filter.rs b/ethcore/src/types/trace_filter.rs index 89f886af4..c17cc9e85 100644 --- a/ethcore/src/types/trace_filter.rs +++ b/ethcore/src/types/trace_filter.rs @@ -16,9 +16,6 @@ //! Trace filter related types -use std::mem; -use ipc::binary::{BinaryConvertError}; -use std::collections::VecDeque; use std::ops::Range; use util::{Address}; use types::ids::BlockID; diff --git a/ethcore/src/types/trace_types/filter.rs b/ethcore/src/types/trace_types/filter.rs index 03100f411..89457bcb3 100644 --- a/ethcore/src/types/trace_types/filter.rs +++ b/ethcore/src/types/trace_types/filter.rs @@ -17,8 +17,6 @@ //! Trace filters type definitions use std::ops::Range; -use std::mem; -use std::collections::VecDeque; use bloomchain::{Filter as BloomFilter, Bloom, Number}; use util::Address; use util::sha3::Hashable; @@ -26,7 +24,6 @@ use util::bloom::Bloomable; use basic_types::LogBloom; use trace::flat::FlatTrace; use types::trace_types::trace::{Action, Res}; -use ipc::binary::BinaryConvertError; /// Addresses filter. /// diff --git a/ethcore/src/types/trace_types/flat.rs b/ethcore/src/types/trace_types/flat.rs index eb5997fec..e5dd9dd8b 100644 --- a/ethcore/src/types/trace_types/flat.rs +++ b/ethcore/src/types/trace_types/flat.rs @@ -17,8 +17,6 @@ //! Flat trace module use std::collections::VecDeque; -use std::mem; -use ipc::binary::BinaryConvertError; use util::rlp::*; use util::HeapSizeOf; use basic_types::LogBloom; diff --git a/ethcore/src/types/trace_types/localized.rs b/ethcore/src/types/trace_types/localized.rs index 334d7b518..f276e9b25 100644 --- a/ethcore/src/types/trace_types/localized.rs +++ b/ethcore/src/types/trace_types/localized.rs @@ -19,9 +19,6 @@ use util::H256; use super::trace::{Action, Res}; use header::BlockNumber; -use ipc::binary::BinaryConvertError; -use std::mem; -use std::collections::VecDeque; /// Localized trace. #[derive(Debug, PartialEq, Binary)] diff --git a/ethcore/src/types/trace_types/trace.rs b/ethcore/src/types/trace_types/trace.rs index 4e339d4bd..f594dd4bb 100644 --- a/ethcore/src/types/trace_types/trace.rs +++ b/ethcore/src/types/trace_types/trace.rs @@ -23,9 +23,6 @@ use util::bloom::Bloomable; use action_params::ActionParams; use basic_types::LogBloom; use types::executed::CallType; -use ipc::binary::BinaryConvertError; -use std::mem; -use std::collections::VecDeque; /// `Call` result. #[derive(Debug, Clone, PartialEq, Default, Binary)] diff --git a/ethcore/src/types/transaction.rs b/ethcore/src/types/transaction.rs index ff6943a8e..4b08a5118 100644 --- a/ethcore/src/types/transaction.rs +++ b/ethcore/src/types/transaction.rs @@ -16,8 +16,6 @@ //! Transaction data structure. -use std::mem; -use std::collections::VecDeque; use util::{H256, Address, U256, H520}; use std::ops::Deref; use util::rlp::*; @@ -29,7 +27,6 @@ use error::*; use evm::Schedule; use header::BlockNumber; use ethjson; -use ipc::binary::BinaryConvertError; use ethstore::ethkey::Signature as EthkeySignature; #[derive(Debug, Clone, PartialEq, Eq, Binary)] diff --git a/ethcore/src/types/transaction_import.rs b/ethcore/src/types/transaction_import.rs index c52a9fb80..c993632b9 100644 --- a/ethcore/src/types/transaction_import.rs +++ b/ethcore/src/types/transaction_import.rs @@ -17,9 +17,7 @@ //! Transaction import result related types use ipc::binary::{BinaryConvertError, BinaryConvertable}; -use std::collections::VecDeque; use error::{TransactionError, Error}; -use std::mem; use util::Populatable; #[derive(Debug, Clone, PartialEq)] diff --git a/ethcore/src/types/tree_route.rs b/ethcore/src/types/tree_route.rs index 7d2da78b8..5d08f5601 100644 --- a/ethcore/src/types/tree_route.rs +++ b/ethcore/src/types/tree_route.rs @@ -16,9 +16,6 @@ //! Tree route info type definition -use std::collections::VecDeque; -use std::mem; -use ipc::BinaryConvertError; use util::H256; /// Represents a tree route between `from` block and `to` block: diff --git a/ipc/codegen/src/serialization.rs b/ipc/codegen/src/serialization.rs index b67a81326..c7adf1011 100644 --- a/ipc/codegen/src/serialization.rs +++ b/ipc/codegen/src/serialization.rs @@ -95,11 +95,11 @@ fn serialize_item( $size_expr } - fn to_bytes(&self, buffer: &mut [u8], length_stack: &mut VecDeque) -> Result<(), BinaryConvertError> { + fn to_bytes(&self, buffer: &mut [u8], length_stack: &mut ::std::collections::VecDeque) -> Result<(), ::ipc::BinaryConvertError> { $write_expr } - fn from_bytes(buffer: &[u8], length_stack: &mut VecDeque) -> Result { + fn from_bytes(buffer: &[u8], length_stack: &mut ::std::collections::VecDeque) -> Result { $read_expr } @@ -210,13 +210,13 @@ fn binary_expr_struct( let field_id = builder.id(field.ident.unwrap()); Some(quote_expr!(cx, match $field_type_ident_qualified::len_params() { - 0 => mem::size_of::<$field_type_ident>(), + 0 => ::std::mem::size_of::<$field_type_ident>(), _ => $x. $field_id .size(), })) }) .unwrap_or_else(|| { quote_expr!(cx, match $field_type_ident_qualified::len_params() { - 0 => mem::size_of::<$field_type_ident>(), + 0 => ::std::mem::size_of::<$field_type_ident>(), _ => $index_ident .size(), }) }) @@ -279,7 +279,7 @@ fn binary_expr_struct( } _ => { write_stmts.push(quote_stmt!(cx, let next_line = offset + match $field_type_ident_qualified::len_params() { - 0 => mem::size_of::<$field_type_ident>(), + 0 => ::std::mem::size_of::<$field_type_ident>(), _ => { let size = $member_expr .size(); length_stack.push_back(size); size }, }).unwrap()); write_stmts.push(quote_stmt!(cx, let $range_ident = offset..next_line; ).unwrap()); @@ -309,7 +309,7 @@ fn binary_expr_struct( }, _ => { map_stmts.push(quote_stmt!(cx, let size = match $field_type_ident_qualified::len_params() { - 0 => mem::size_of::<$field_type_ident>(), + 0 => ::std::mem::size_of::<$field_type_ident>(), _ => length_stack.pop_front().unwrap(), }).unwrap()); map_stmts.push(quote_stmt!(cx, total += size;).unwrap()); @@ -412,7 +412,7 @@ fn binary_expr_enum( arms.iter().map(|x| x.write.clone()).collect::>(), arms.iter().map(|x| x.read.clone()).collect::>()); - read_arms.push(quote_arm!(cx, _ => { Err(BinaryConvertError::variant(buffer[0])) } )); + read_arms.push(quote_arm!(cx, _ => { Err(::ipc::BinaryConvertError::variant(buffer[0])) } )); Ok(BinaryExpressions { size: quote_expr!(cx, 1usize + match *self { $size_arms }), diff --git a/ipc/hypervisor/src/service.rs.in b/ipc/hypervisor/src/service.rs.in index 208e3efcf..3b1a4d145 100644 --- a/ipc/hypervisor/src/service.rs.in +++ b/ipc/hypervisor/src/service.rs.in @@ -17,9 +17,6 @@ use std::sync::{RwLock,Arc}; use ipc::IpcConfig; use std::collections::HashMap; -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; pub type IpcModuleId = u64; diff --git a/ipc/rpc/src/binary.rs b/ipc/rpc/src/binary.rs index 4cc091456..a1f1ed0bb 100644 --- a/ipc/rpc/src/binary.rs +++ b/ipc/rpc/src/binary.rs @@ -707,7 +707,7 @@ pub fn serialize(t: &T) -> Result, BinaryError> { macro_rules! binary_fixed_size { ($target_ty: ty) => { impl BinaryConvertable for $target_ty { - fn from_bytes(bytes: &[u8], _length_stack: &mut VecDeque) -> Result { + fn from_bytes(bytes: &[u8], _length_stack: &mut ::std::collections::VecDeque) -> Result { match bytes.len().cmp(&::std::mem::size_of::<$target_ty>()) { ::std::cmp::Ordering::Equal => (), _ => return Err(BinaryConvertError::size(::std::mem::size_of::<$target_ty>(), bytes.len())), @@ -717,7 +717,7 @@ macro_rules! binary_fixed_size { Ok(res) } - fn to_bytes(&self, buffer: &mut [u8], _length_stack: &mut VecDeque) -> Result<(), BinaryConvertError> { + fn to_bytes(&self, buffer: &mut [u8], _length_stack: &mut ::std::collections::VecDeque) -> Result<(), BinaryConvertError> { let sz = ::std::mem::size_of::<$target_ty>(); let ip: *const $target_ty = self; let ptr: *const u8 = ip as *const _; diff --git a/ipc/tests/binary.rs.in b/ipc/tests/binary.rs.in index e6297e67f..891f70f99 100644 --- a/ipc/tests/binary.rs.in +++ b/ipc/tests/binary.rs.in @@ -16,8 +16,6 @@ use ipc::*; -use std::mem; -use std::collections::VecDeque; use util::Bytes; #[derive(Binary)] diff --git a/ipc/tests/nested.rs.in b/ipc/tests/nested.rs.in index 6b4b2b325..4f0ac4a8a 100644 --- a/ipc/tests/nested.rs.in +++ b/ipc/tests/nested.rs.in @@ -16,9 +16,6 @@ use std::sync::RwLock; use ipc::IpcConfig; -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; pub struct DB { pub writes: RwLock, diff --git a/ipc/tests/service.rs.in b/ipc/tests/service.rs.in index ec403ce6e..9c221d481 100644 --- a/ipc/tests/service.rs.in +++ b/ipc/tests/service.rs.in @@ -16,9 +16,6 @@ use std::sync::RwLock; use ipc::IpcConfig; -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; pub struct Service { pub commits: RwLock, diff --git a/ipc/tests/with_attrs.rs.in b/ipc/tests/with_attrs.rs.in index 240e434c9..bbf5b894a 100644 --- a/ipc/tests/with_attrs.rs.in +++ b/ipc/tests/with_attrs.rs.in @@ -15,9 +15,6 @@ // along with Parity. If not, see . use ipc::IpcConfig; -use std::mem; -use ipc::binary::BinaryConvertError; -use std::collections::VecDeque; pub struct BadlyNamedService; diff --git a/sync/src/api.rs b/sync/src/api.rs index 4603ac52e..608d9d521 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -25,8 +25,6 @@ use sync_io::NetSyncIo; use chain::{ChainSync, SyncStatus}; use std::net::{SocketAddr, AddrParseError}; use ipc::{BinaryConvertable, BinaryConvertError, IpcConfig}; -use std::mem; -use std::collections::VecDeque; use std::str::FromStr; use parking_lot::RwLock;