From: Matt Corallo Date: Thu, 21 Mar 2024 14:27:05 +0000 (+0000) Subject: Use `crate::prelude::*` rather than specific imports X-Git-Tag: v0.0.123-beta~16^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ae0d825d89ca0ac2489737d1b413e778650b093c;p=rust-lightning Use `crate::prelude::*` rather than specific imports New rustc beta now warns on duplicate imports when one of the imports is from a wildcard import or the default prelude. Thus, to avoid this here we prefer to always use `crate::prelude::*` and let it decide if we actually need to import anything. --- diff --git a/lightning-invoice/src/de.rs b/lightning-invoice/src/de.rs index 9284999b1..56e5c53ba 100644 --- a/lightning-invoice/src/de.rs +++ b/lightning-invoice/src/de.rs @@ -1,5 +1,6 @@ #[cfg(feature = "std")] use std::error; +#[cfg(not(feature = "std"))] use core::convert::TryFrom; use core::fmt; use core::fmt::{Display, Formatter}; diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index d45a4e8e6..1d6b9210a 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -19,6 +19,7 @@ use secp256k1::PublicKey; use alloc::collections::{btree_map, BTreeMap}; use core::ops::Deref; use core::time::Duration; +#[cfg(not(feature = "std"))] use core::iter::Iterator; /// Utility to create an invoice that can be paid to one of multiple nodes, or a "phantom invoice." diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index c77e4e33e..3d56020a6 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -17,8 +17,6 @@ use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer} #[allow(unused_imports)] use crate::prelude::*; -use core::convert::TryFrom; - /// An intermediate node, its outbound channel, and relay parameters. #[derive(Clone, Debug)] pub struct ForwardNode { diff --git a/lightning/src/chain/chaininterface.rs b/lightning/src/chain/chaininterface.rs index 1f42dc2fe..2bf6d6130 100644 --- a/lightning/src/chain/chaininterface.rs +++ b/lightning/src/chain/chaininterface.rs @@ -14,7 +14,8 @@ //! disconnections, transaction broadcasting, and feerate information requests. use core::{cmp, ops::Deref}; -use core::convert::TryInto; + +use crate::prelude::*; use bitcoin::blockdata::transaction::Transaction; diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index b878640d4..c2d3a43b1 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -58,7 +58,6 @@ use crate::prelude::*; use core::{cmp, mem}; use crate::io::{self, Error}; -use core::convert::TryInto; use core::ops::Deref; use crate::sync::{Mutex, LockTestExt}; diff --git a/lightning/src/chain/package.rs b/lightning/src/chain/package.rs index 8c833707e..3023be604 100644 --- a/lightning/src/chain/package.rs +++ b/lightning/src/chain/package.rs @@ -36,7 +36,6 @@ use crate::util::ser::{Readable, Writer, Writeable, RequiredWrapper}; use crate::io; use core::cmp; -use core::convert::TryInto; use core::mem; use core::ops::Deref; diff --git a/lightning/src/crypto/chacha20.rs b/lightning/src/crypto/chacha20.rs index d6fd3a7de..0c51d4562 100644 --- a/lightning/src/crypto/chacha20.rs +++ b/lightning/src/crypto/chacha20.rs @@ -12,7 +12,6 @@ #[cfg(not(fuzzing))] mod real_chacha { use core::cmp; - use core::convert::TryInto; #[derive(Clone, Copy, PartialEq, Eq)] #[allow(non_camel_case_types)] @@ -335,11 +334,10 @@ pub use self::fuzzy_chacha::ChaCha20; #[cfg(test)] mod test { - use alloc::vec; - use alloc::vec::{Vec}; - use core::convert::TryInto; use core::iter::repeat; + use crate::prelude::*; + use super::ChaCha20; #[test] diff --git a/lightning/src/crypto/poly1305.rs b/lightning/src/crypto/poly1305.rs index a1b9fbac5..593200210 100644 --- a/lightning/src/crypto/poly1305.rs +++ b/lightning/src/crypto/poly1305.rs @@ -8,7 +8,8 @@ // https://github.com/floodyberry/poly1305-donna use core::cmp::min; -use core::convert::TryInto; + +use crate::prelude::*; #[derive(Clone, Copy)] pub struct Poly1305 { @@ -206,7 +207,6 @@ impl Poly1305 { #[cfg(test)] mod test { use core::iter::repeat; - use alloc::vec::Vec; use super::Poly1305; diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 29fe76b49..3b5a4ebfb 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -165,12 +165,15 @@ mod io_extras { } mod prelude { + #![allow(unused_imports)] + pub use alloc::{vec, vec::Vec, string::String, collections::VecDeque, boxed::Box}; pub use alloc::borrow::ToOwned; pub use alloc::string::ToString; - pub use core::convert::{TryFrom, TryInto}; + pub use core::convert::{AsMut, AsRef, TryFrom, TryInto}; + pub use core::default::Default; pub use core::marker::Sized; pub(crate) use crate::util::hash_tables::*; diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index ed8c861d7..2698abee2 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -50,7 +50,6 @@ use crate::util::scid_utils::scid_from_parts; use crate::io; use crate::prelude::*; use core::{cmp,mem,fmt}; -use core::convert::TryInto; use core::ops::Deref; #[cfg(any(test, fuzzing, debug_assertions))] use crate::sync::Mutex; diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index eee9ef49b..5ea3e6372 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -49,12 +49,9 @@ use bitcoin::OutPoint as BitcoinOutPoint; use bitcoin::secp256k1::Secp256k1; use bitcoin::secp256k1::{PublicKey,SecretKey}; -use regex; - use crate::io; use crate::prelude::*; use alloc::collections::BTreeSet; -use core::default::Default; use core::iter::repeat; use bitcoin::hashes::Hash; use crate::sync::{Arc, Mutex, RwLock}; diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs index eeae514fd..f27d8aab1 100644 --- a/lightning/src/ln/inbound_payment.rs +++ b/lightning/src/ln/inbound_payment.rs @@ -9,7 +9,6 @@ //! Utilities to generate inbound payment information in service of invoice creation. -use alloc::string::ToString; use bitcoin::hashes::{Hash, HashEngine}; use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; @@ -23,7 +22,9 @@ use crate::crypto::utils::hkdf_extract_expand_5x; use crate::util::errors::APIError; use crate::util::logger::Logger; -use core::convert::{TryFrom, TryInto}; +#[allow(unused_imports)] +use crate::prelude::*; + use core::ops::Deref; pub(crate) const IV_LEN: usize = 16; diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 9424d341d..8040d8c42 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -41,8 +41,6 @@ use crate::sign::{NodeSigner, Recipient}; #[allow(unused_imports)] use crate::prelude::*; -#[cfg(feature = "std")] -use core::convert::TryFrom; use core::fmt; use core::fmt::Debug; use core::ops::Deref; @@ -3167,7 +3165,6 @@ impl_writeable_msg!(GossipTimestampFilter, { #[cfg(test)] mod tests { - use std::convert::TryFrom; use bitcoin::{Transaction, TxIn, ScriptBuf, Sequence, Witness, TxOut}; use hex::DisplayHex; use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret}; diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 80c588e25..aeb175bc6 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -39,7 +39,6 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; use crate::io; use crate::prelude::*; -use core::default::Default; use bitcoin::hashes::hex::FromHex; use crate::ln::functional_test_utils::*; diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index 2cbc2895c..f2b5c69e9 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -30,7 +30,6 @@ use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey}; use crate::io::{Cursor, Read}; -use core::convert::{AsMut, TryInto}; use core::ops::Deref; #[allow(unused_imports)] diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index e76da792a..0322de642 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -40,7 +40,6 @@ use crate::util::string::PrintableString; use crate::prelude::*; use crate::io; -use alloc::collections::VecDeque; use crate::sync::{Mutex, MutexGuard, FairRwLock}; use core::sync::atomic::{AtomicBool, AtomicU32, AtomicI32, Ordering}; use core::{cmp, hash, fmt, mem}; diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs index 3d799df8d..6fd8623d3 100644 --- a/lightning/src/ln/priv_short_conf_tests.rs +++ b/lightning/src/ln/priv_short_conf_tests.rs @@ -26,7 +26,6 @@ use crate::util::ser::Writeable; use crate::util::test_utils; use crate::prelude::*; -use core::default::Default; use crate::ln::functional_test_utils::*; diff --git a/lightning/src/ln/reload_tests.rs b/lightning/src/ln/reload_tests.rs index fa216bc15..8b25f7701 100644 --- a/lightning/src/ln/reload_tests.rs +++ b/lightning/src/ln/reload_tests.rs @@ -27,7 +27,6 @@ use crate::util::config::UserConfig; use bitcoin::hash_types::BlockHash; use crate::prelude::*; -use core::default::Default; use crate::sync::Mutex; use crate::ln::functional_test_utils::*; diff --git a/lightning/src/ln/script.rs b/lightning/src/ln/script.rs index dc733dd25..1909eb0c5 100644 --- a/lightning/src/ln/script.rs +++ b/lightning/src/ln/script.rs @@ -12,9 +12,11 @@ use crate::ln::features::InitFeatures; use crate::ln::msgs::DecodeError; use crate::util::ser::{Readable, Writeable, Writer}; -use core::convert::TryFrom; use crate::io; +#[allow(unused_imports)] +use crate::prelude::*; + /// A script pubkey for shutting down a channel as defined by [BOLT #2]. /// /// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md @@ -167,13 +169,15 @@ impl core::fmt::Display for ShutdownScript{ #[cfg(test)] mod shutdown_script_tests { use super::ShutdownScript; + + use bitcoin::address::{WitnessProgram, WitnessVersion}; use bitcoin::blockdata::opcodes; use bitcoin::blockdata::script::{Builder, ScriptBuf}; use bitcoin::secp256k1::Secp256k1; use bitcoin::secp256k1::{PublicKey, SecretKey}; + use crate::ln::features::InitFeatures; - use core::convert::TryFrom; - use bitcoin::address::{WitnessProgram, WitnessVersion}; + use crate::prelude::*; fn pubkey() -> bitcoin::key::PublicKey { let secp_ctx = Secp256k1::signing_only(); diff --git a/lightning/src/ln/shutdown_tests.rs b/lightning/src/ln/shutdown_tests.rs index c6d0cc58b..7f004948f 100644 --- a/lightning/src/ln/shutdown_tests.rs +++ b/lightning/src/ln/shutdown_tests.rs @@ -25,6 +25,7 @@ use crate::util::test_utils::OnGetShutdownScriptpubkey; use crate::util::errors::APIError; use crate::util::config::UserConfig; use crate::util::string::UntrustedString; +use crate::prelude::*; use bitcoin::{Transaction, TxOut}; use bitcoin::blockdata::locktime::absolute::LockTime; @@ -33,11 +34,6 @@ use bitcoin::blockdata::opcodes; use bitcoin::network::constants::Network; use bitcoin::address::{WitnessProgram, WitnessVersion}; -use regex; - -use core::default::Default; -use std::convert::TryFrom; - use crate::ln::functional_test_utils::*; #[test] diff --git a/lightning/src/ln/wire.rs b/lightning/src/ln/wire.rs index 5087df33b..dc4eecde6 100644 --- a/lightning/src/ln/wire.rs +++ b/lightning/src/ln/wire.rs @@ -617,7 +617,6 @@ impl Encode for msgs::GossipTimestampFilter { mod tests { use super::*; use crate::prelude::*; - use core::convert::TryInto; use crate::ln::peer_handler::IgnoringMessageHandler; // Big-endian wire encoding of Pong message (type = 19, byteslen = 2). diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 9b5492704..f2fb38794 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -110,7 +110,6 @@ use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self}; use bitcoin::secp256k1::schnorr::Signature; use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion}; use bitcoin::key::TweakedPublicKey; -use core::convert::{AsRef, TryFrom}; use core::time::Duration; use crate::io; use crate::blinded_path::BlindedPath; @@ -1453,8 +1452,9 @@ mod tests { use bitcoin::secp256k1::{Message, Secp256k1, XOnlyPublicKey, self}; use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion}; use bitcoin::key::TweakedPublicKey; - use core::convert::TryFrom; + use core::time::Duration; + use crate::blinded_path::{BlindedHop, BlindedPath}; use crate::sign::KeyMaterial; use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures}; @@ -1463,6 +1463,7 @@ mod tests { use crate::offers::invoice_request::InvoiceRequestTlvStreamRef; use crate::offers::merkle::{SignError, SignatureTlvStreamRef, TaggedHash, self}; use crate::offers::offer::{Amount, OfferTlvStreamRef, Quantity}; + use crate::prelude::*; #[cfg(not(c_bindings))] use { crate::offers::offer::OfferBuilder, diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index 60df1fe47..5e3ed40ac 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -61,7 +61,6 @@ use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self}; use bitcoin::secp256k1::schnorr::Signature; -use core::convert::{AsRef, TryFrom}; use core::ops::Deref; use crate::sign::EntropySource; use crate::io; @@ -1104,7 +1103,6 @@ mod tests { use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey, self}; - use core::convert::TryFrom; use core::num::NonZeroU64; #[cfg(feature = "std")] use core::time::Duration; diff --git a/lightning/src/offers/merkle.rs b/lightning/src/offers/merkle.rs index 8151631e6..da3fab589 100644 --- a/lightning/src/offers/merkle.rs +++ b/lightning/src/offers/merkle.rs @@ -12,7 +12,6 @@ use bitcoin::hashes::{Hash, HashEngine, sha256}; use bitcoin::secp256k1::{Message, PublicKey, Secp256k1, self}; use bitcoin::secp256k1::schnorr::Signature; -use core::convert::AsRef; use crate::io; use crate::util::ser::{BigSize, Readable, Writeable, Writer}; diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index f9cc07b31..7f48be23e 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -79,7 +79,6 @@ use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self}; -use core::convert::TryFrom; use core::hash::{Hash, Hasher}; use core::num::NonZeroU64; use core::ops::Deref; @@ -1067,7 +1066,6 @@ mod tests { use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::Secp256k1; - use core::convert::TryFrom; use core::num::NonZeroU64; use core::time::Duration; use crate::blinded_path::{BlindedHop, BlindedPath}; diff --git a/lightning/src/offers/parse.rs b/lightning/src/offers/parse.rs index 00c48d9ea..72c4c380d 100644 --- a/lightning/src/offers/parse.rs +++ b/lightning/src/offers/parse.rs @@ -11,7 +11,6 @@ use bitcoin::bech32; use bitcoin::secp256k1; -use core::convert::TryFrom; use crate::io; use crate::ln::msgs::DecodeError; use crate::util::ser::SeekReadable; @@ -28,7 +27,6 @@ pub use sealed::Bech32Encode; mod sealed { use bitcoin::bech32; use bitcoin::bech32::{FromBase32, ToBase32}; - use core::convert::TryFrom; use core::fmt; use super::Bolt12ParseError; diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index 8e6c029f1..73b48521a 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -84,7 +84,6 @@ use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::{PublicKey, Secp256k1, self}; -use core::convert::TryFrom; use core::hash::{Hash, Hasher}; use core::ops::Deref; use core::str::FromStr; @@ -895,8 +894,9 @@ mod tests { use bitcoin::blockdata::constants::ChainHash; use bitcoin::network::constants::Network; use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey}; - use core::convert::TryFrom; + use core::time::Duration; + use crate::blinded_path::{BlindedHop, BlindedPath}; use crate::sign::KeyMaterial; use crate::ln::channelmanager::PaymentId; @@ -910,6 +910,7 @@ mod tests { use crate::offers::test_utils::*; use crate::util::ser::{BigSize, Writeable}; use crate::util::string::PrintableString; + use crate::prelude::*; trait ToBytes { fn to_bytes(&self) -> Vec; diff --git a/lightning/src/offers/signer.rs b/lightning/src/offers/signer.rs index e0abd8276..c5a96cbf1 100644 --- a/lightning/src/offers/signer.rs +++ b/lightning/src/offers/signer.rs @@ -14,7 +14,6 @@ use bitcoin::hashes::cmp::fixed_time_eq; use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey, self}; -use core::convert::TryFrom; use core::fmt; use crate::ln::channelmanager::PaymentId; use crate::ln::inbound_payment::{ExpandedKey, IV_LEN, Nonce}; diff --git a/lightning/src/offers/test_utils.rs b/lightning/src/offers/test_utils.rs index 29bed53d8..b43298030 100644 --- a/lightning/src/offers/test_utils.rs +++ b/lightning/src/offers/test_utils.rs @@ -11,7 +11,7 @@ use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; use bitcoin::secp256k1::schnorr::Signature; -use core::convert::AsRef; + use core::time::Duration; use crate::blinded_path::{BlindedHop, BlindedPath}; use crate::sign::EntropySource; @@ -20,6 +20,9 @@ use crate::ln::features::BlindedHopFeatures; use crate::offers::invoice::BlindedPayInfo; use crate::offers::merkle::TaggedHash; +#[allow(unused_imports)] +use crate::prelude::*; + pub(crate) fn fail_sign>(_message: &T) -> Result { Err(()) } diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs index 6672b5dfc..faf539f86 100644 --- a/lightning/src/onion_message/offers.rs +++ b/lightning/src/onion_message/offers.rs @@ -9,7 +9,6 @@ //! Message handling for BOLT 12 Offers. -use core::convert::TryFrom; use core::fmt; use crate::io::{self, Read}; use crate::ln::msgs::DecodeError; diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs index 045772486..42bf20a78 100644 --- a/lightning/src/routing/gossip.rs +++ b/lightning/src/routing/gossip.rs @@ -38,7 +38,6 @@ use crate::io; use crate::io_extras::{copy, sink}; use crate::prelude::*; use core::{cmp, fmt}; -use core::convert::TryFrom; use crate::sync::{RwLock, RwLockReadGuard, LockTestExt}; #[cfg(feature = "std")] use core::sync::atomic::{AtomicUsize, Ordering}; diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 8d3718226..e8276712e 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -3259,8 +3259,6 @@ mod tests { use crate::prelude::*; use crate::sync::Arc; - use core::convert::TryInto; - fn get_channel_details(short_channel_id: Option, node_id: PublicKey, features: InitFeatures, outbound_capacity_msat: u64) -> channelmanager::ChannelDetails { channelmanager::ChannelDetails { @@ -8344,17 +8342,14 @@ pub(crate) mod bench_utils { use std::time::Duration; use bitcoin::hashes::Hash; - use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; + use bitcoin::secp256k1::SecretKey; use crate::chain::transaction::OutPoint; use crate::routing::scoring::ScoreUpdate; - use crate::sign::{EntropySource, KeysManager}; + use crate::sign::KeysManager; use crate::ln::ChannelId; - use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails}; - use crate::ln::features::Bolt11InvoiceFeatures; - use crate::routing::gossip::NetworkGraph; + use crate::ln::channelmanager::{self, ChannelCounterparty}; use crate::util::config::UserConfig; - use crate::util::ser::ReadableArgs; use crate::util::test_utils::TestLogger; /// Tries to open a network graph file, or panics with a URL to fetch it. diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index bb043164a..4850479b8 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -64,7 +64,6 @@ use crate::util::logger::Logger; use crate::prelude::*; use core::{cmp, fmt}; -use core::convert::TryInto; use core::ops::{Deref, DerefMut}; use core::time::Duration; use crate::io::{self, Read}; diff --git a/lightning/src/routing/utxo.rs b/lightning/src/routing/utxo.rs index ada90345e..e775e2628 100644 --- a/lightning/src/routing/utxo.rs +++ b/lightning/src/routing/utxo.rs @@ -563,7 +563,6 @@ mod tests { use super::*; use crate::routing::gossip::tests::*; use crate::util::test_utils::{TestChainSource, TestLogger}; - use crate::ln::msgs; use bitcoin::secp256k1::{Secp256k1, SecretKey}; diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index a7237493b..c959b115c 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -53,7 +53,6 @@ use crate::offers::invoice::UnsignedBolt12Invoice; use crate::offers::invoice_request::UnsignedInvoiceRequest; use crate::prelude::*; -use core::convert::TryInto; use core::ops::Deref; use core::sync::atomic::{AtomicUsize, Ordering}; #[cfg(taproot)] diff --git a/lightning/src/util/errors.rs b/lightning/src/util/errors.rs index 4ffde9a72..735ce044f 100644 --- a/lightning/src/util/errors.rs +++ b/lightning/src/util/errors.rs @@ -11,7 +11,9 @@ use crate::ln::script::ShutdownScript; -use alloc::string::String; +#[allow(unused_imports)] +use crate::prelude::*; + use core::fmt; /// Indicates an error on the client's part (usually some variant of attempting to use too-low or diff --git a/lightning/src/util/indexed_map.rs b/lightning/src/util/indexed_map.rs index d4c20f722..4f694bd2b 100644 --- a/lightning/src/util/indexed_map.rs +++ b/lightning/src/util/indexed_map.rs @@ -1,10 +1,8 @@ //! This module has a map which can be iterated in a deterministic order. See the [`IndexedMap`]. use crate::prelude::*; -use alloc::vec::Vec; use alloc::slice::Iter; use core::hash::Hash; -use core::cmp::Ord; use core::ops::{Bound, RangeBounds}; /// A map which can be iterated in a deterministic order. diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs index a7b4bda6f..6fd0048da 100644 --- a/lightning/src/util/persist.rs +++ b/lightning/src/util/persist.rs @@ -11,13 +11,11 @@ //! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager use core::cmp; -use core::convert::{TryFrom, TryInto}; use core::ops::Deref; use core::str::FromStr; use bitcoin::{BlockHash, Txid}; use crate::{io, log_error}; -use crate::alloc::string::ToString; use crate::prelude::*; use crate::chain; @@ -837,7 +835,6 @@ impl From for UpdateName { #[cfg(test)] mod tests { use super::*; - use crate::chain::chainmonitor::Persist; use crate::chain::ChannelMonitorUpdateStatus; use crate::events::{ClosureReason, MessageSendEventsProvider}; use crate::ln::functional_test_utils::*; diff --git a/lightning/src/util/scid_utils.rs b/lightning/src/util/scid_utils.rs index 38be0eb88..c9485b60b 100644 --- a/lightning/src/util/scid_utils.rs +++ b/lightning/src/util/scid_utils.rs @@ -76,8 +76,8 @@ pub(crate) mod fake_scid { use crate::sign::EntropySource; use crate::crypto::chacha20::ChaCha20; use crate::util::scid_utils; + use crate::prelude::*; - use core::convert::TryInto; use core::ops::Deref; const TEST_SEGWIT_ACTIVATION_HEIGHT: u32 = 1; diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 7ff6b248c..f88d9f36a 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -19,7 +19,6 @@ use crate::io_extras::{copy, sink}; use core::hash::Hash; use crate::sync::{Mutex, RwLock}; use core::cmp; -use core::convert::TryFrom; use core::ops::Deref; use alloc::collections::BTreeMap; @@ -35,7 +34,6 @@ use bitcoin::{consensus, Witness}; use bitcoin::consensus::Encodable; use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hash_types::{Txid, BlockHash}; -use core::marker::Sized; use core::time::Duration; use crate::chain::ClaimId; use crate::ln::msgs::DecodeError; @@ -1494,10 +1492,10 @@ impl Readable for ClaimId { #[cfg(test)] mod tests { - use core::convert::TryFrom; use bitcoin::hashes::hex::FromHex; use bitcoin::secp256k1::ecdsa; use crate::util::ser::{Readable, Hostname, Writeable}; + use crate::prelude::*; #[test] fn hostname_conversion() { diff --git a/lightning/src/util/string.rs b/lightning/src/util/string.rs index 6949c936e..ab12486a0 100644 --- a/lightning/src/util/string.rs +++ b/lightning/src/util/string.rs @@ -9,12 +9,14 @@ //! Utilities for strings. -use alloc::string::String; use core::fmt; use crate::io::{self, Read}; use crate::ln::msgs; use crate::util::ser::{Writeable, Writer, Readable}; +#[allow(unused_imports)] +use crate::prelude::*; + /// Struct to `Display` fields in a safe way using `PrintableString` #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] pub struct UntrustedString(pub String); diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 15cc07466..ee09119b9 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -59,9 +59,6 @@ use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature}; use bitcoin::secp256k1::schnorr; -#[cfg(any(test, feature = "_test_utils"))] -use regex; - use crate::io; use crate::prelude::*; use core::cell::RefCell; diff --git a/lightning/src/util/transaction_utils.rs b/lightning/src/util/transaction_utils.rs index 8b0ef3da0..59b7be607 100644 --- a/lightning/src/util/transaction_utils.rs +++ b/lightning/src/util/transaction_utils.rs @@ -74,8 +74,8 @@ mod tests { use super::*; use bitcoin::blockdata::locktime::absolute::LockTime; - use bitcoin::blockdata::transaction::{Transaction, TxOut, TxIn, OutPoint}; - use bitcoin::blockdata::script::{ScriptBuf, Builder}; + use bitcoin::blockdata::transaction::{TxIn, OutPoint}; + use bitcoin::blockdata::script::Builder; use bitcoin::hash_types::{PubkeyHash, Txid}; use bitcoin::hashes::Hash; use bitcoin::hashes::hex::FromHex; diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index 6c0de2bfa..c95b3dbef 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -306,7 +306,7 @@ mod tests { use super::*; use core::sync::atomic::{AtomicBool, Ordering}; use core::future::Future as FutureTrait; - use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; + use core::task::{RawWaker, RawWakerVTable}; #[test] fn notifier_pre_notified_future() {