Skip to content

Commit

Permalink
Merge pull request #3026 from Pana/op/migrateExternCrate
Browse files Browse the repository at this point in the history
migrate extern crate code
  • Loading branch information
Pana authored Jan 2, 2025
2 parents 1c1ed17 + d362ec6 commit 7a06670
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 42 deletions.
16 changes: 9 additions & 7 deletions crates/cfxcore/executor/src/builtin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,20 +512,20 @@ impl Impl for ModexpImpl {

fn read_fr(
reader: &mut io::Chain<&[u8], io::Repeat>,
) -> Result<::bn::Fr, Error> {
) -> Result<crate::bn::Fr, Error> {
let mut buf = [0u8; 32];

reader
.read_exact(&mut buf[..])
.expect("reading from zero-extended memory cannot fail; qed");
::bn::Fr::from_slice(&buf[0..32])
crate::bn::Fr::from_slice(&buf[0..32])
.map_err(|_| Error::from("Invalid field element"))
}

fn read_point(
reader: &mut io::Chain<&[u8], io::Repeat>,
) -> Result<::bn::G1, Error> {
use bn::{AffineG1, Fq, Group, G1};
) -> Result<crate::bn::G1, Error> {
use crate::bn::{AffineG1, Fq, Group, G1};

let mut buf = [0u8; 32];

Expand Down Expand Up @@ -554,7 +554,7 @@ impl Impl for Bn128AddImpl {
fn execute(
&self, input: &[u8], output: &mut BytesRef,
) -> Result<(), Error> {
use bn::AffineG1;
use crate::bn::AffineG1;

let mut padded_input = input.chain(io::repeat(0));
let p1 = read_point(&mut padded_input)?;
Expand Down Expand Up @@ -582,7 +582,7 @@ impl Impl for Bn128MulImpl {
fn execute(
&self, input: &[u8], output: &mut BytesRef,
) -> Result<(), Error> {
use bn::AffineG1;
use crate::bn::AffineG1;

let mut padded_input = input.chain(io::repeat(0));
let p = read_point(&mut padded_input)?;
Expand Down Expand Up @@ -631,7 +631,9 @@ impl Bn128PairingImpl {
fn execute_with_error(
&self, input: &[u8], output: &mut BytesRef,
) -> Result<(), Error> {
use bn::{pairing, AffineG1, AffineG2, Fq, Fq2, Group, Gt, G1, G2};
use crate::bn::{
pairing, AffineG1, AffineG2, Fq, Fq2, Group, Gt, G1, G2,
};

let elements = input.len() / 192; // (a, b_a, b_b - each 64-byte affine coordinates)
let ret_val = if input.len() == 0 {
Expand Down
3 changes: 1 addition & 2 deletions crates/cfxcore/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
#[macro_use]
extern crate log;
extern crate substrate_bn as bn;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate cfx_util_macros;
extern crate sha3_macro;
use substrate_bn as bn;

/// Ethereum Builtins: Implements Ethereum's builtin contracts, ranging from
/// address `0x1` to `0x9`.
Expand Down
11 changes: 0 additions & 11 deletions crates/cfxcore/packing-pool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
extern crate cfx_math;
extern crate cfx_types;
extern crate heap_map;
extern crate malloc_size_of;
extern crate malloc_size_of_derive;
extern crate primitives;
extern crate rand;
extern crate rand_xorshift;
extern crate treap_map;
extern crate typenum;

mod key_mng;
mod mock_tx;
mod packing_batch;
Expand Down
6 changes: 3 additions & 3 deletions crates/cfxcore/packing-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ where
mod pool_tests {
use std::{collections::HashSet, sync::atomic::AtomicUsize};

use rand::SeedableRng;
use rand_xorshift::XorShiftRng;

use crate::{
mock_tx::MockTransaction, rand::SeedableRng,
transaction::PackingPoolTransaction, PackingBatch, PackingPool,
PackingPoolConfig, SampleTag,
mock_tx::MockTransaction, transaction::PackingPoolTransaction,
PackingBatch, PackingPool, PackingPoolConfig, SampleTag,
};

fn default_pool(
Expand Down
5 changes: 1 addition & 4 deletions crates/dbs/db/src/rocksdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/

extern crate core;
extern crate kvdb_rocksdb;

use self::kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig};
use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig};
use std::{io, path::Path, str::FromStr, sync::Arc};

pub struct SystemDB {
Expand Down
1 change: 0 additions & 1 deletion crates/dbs/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![allow(clippy::mut_from_ref, clippy::cast_ref_to_mut, clippy::drop_ref)]
#![allow(deprecated)]

//extern crate futures;
#[macro_use]
extern crate cfx_util_macros;
#[macro_use]
Expand Down
2 changes: 0 additions & 2 deletions crates/pos/common/num-variants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#![forbid(unsafe_code)]
#![warn(missing_docs)]

extern crate proc_macro;

use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::{
Expand Down
2 changes: 0 additions & 2 deletions crates/pos/crypto/crypto-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
#![forbid(unsafe_code)]

extern crate proc_macro;

mod hasher;
mod unions;

Expand Down
2 changes: 0 additions & 2 deletions crates/util/hibitset/src/iter/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ impl<T> BitParIter<T> {
/// # Examples
///
/// ```
/// # extern crate rayon;
/// # extern crate hibitset;
/// # use hibitset::{BitSet, BitSetLike};
/// # use rayon::iter::ParallelIterator;
/// # fn main() {
Expand Down
7 changes: 0 additions & 7 deletions crates/util/hibitset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@
#![deny(missing_docs)]
#![allow(clippy::all)]

extern crate atom;
extern crate malloc_size_of;
#[cfg(test)]
extern crate rand;
#[cfg(feature = "parallel")]
extern crate rayon;

mod atomic;
mod iter;
mod ops;
Expand Down
1 change: 0 additions & 1 deletion crates/util/link-cut-tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ pub type CaterpillarMinLinkCutTree = MutexLinkCutTree<Caterpillar>;

#[cfg(test)]
mod tests {
extern crate rand;
use super::{
CaterpillarMinLinkCutTree, DefaultMinLinkCutTree,
DeltaAndPreferredChild, Link, MutexLinkCutTree, SizeMinLinkCutTree,
Expand Down

0 comments on commit 7a06670

Please sign in to comment.