From: Matt Corallo Date: Thu, 21 Mar 2024 15:18:22 +0000 (+0000) Subject: Allow(unused_imports) on prelude imports X-Git-Tag: v0.0.123-beta~16^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=cd327089a8c719844b776601e9ccd0728777ac28;p=rust-lightning Allow(unused_imports) on prelude imports New rustc now warns on duplicate imports when one of the imports is from a wildcard import or the default prelude. Thus, because we often don't actually use the imports from our prelude (as they exist to duplicate the `std` default prelude), we have to mark most of our `crate::prelude` imports with `#[allow(unused_imports)]`, which we do here. --- diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index 3a5541fa1..bdcbd7726 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -1,12 +1,14 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey}; +#[allow(unused_imports)] +use crate::prelude::*; + use crate::blinded_path::{BlindedHop, BlindedPath}; use crate::blinded_path::utils; use crate::io; use crate::io::Cursor; use crate::ln::onion_utils; use crate::onion_message::packet::ControlTlvs; -use crate::prelude::*; use crate::sign::{NodeSigner, Recipient}; use crate::crypto::streams::ChaChaPolyReadAdapter; use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Writeable, Writer}; diff --git a/lightning/src/blinded_path/payment.rs b/lightning/src/blinded_path/payment.rs index 6467af568..c77e4e33e 100644 --- a/lightning/src/blinded_path/payment.rs +++ b/lightning/src/blinded_path/payment.rs @@ -12,9 +12,11 @@ use crate::ln::channelmanager::CounterpartyForwardingInfo; use crate::ln::features::BlindedHopFeatures; use crate::ln::msgs::DecodeError; use crate::offers::invoice::BlindedPayInfo; -use crate::prelude::*; 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. diff --git a/lightning/src/blinded_path/utils.rs b/lightning/src/blinded_path/utils.rs index d4894a86a..7e43f3145 100644 --- a/lightning/src/blinded_path/utils.rs +++ b/lightning/src/blinded_path/utils.rs @@ -23,6 +23,8 @@ use crate::crypto::streams::ChaChaPolyWriteAdapter; use crate::util::ser::{Readable, Writeable}; use crate::io; + +#[allow(unused_imports)] use crate::prelude::*; // TODO: DRY with onion_utils::construct_onion_keys_callback diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 4352076e9..b878640d4 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -53,7 +53,9 @@ use crate::util::byte_utils; use crate::events::{ClosureReason, Event, EventHandler}; use crate::events::bump_transaction::{AnchorDescriptor, BumpTransactionEvent}; +#[allow(unused_imports)] use crate::prelude::*; + use core::{cmp, mem}; use crate::io::{self, Error}; use core::convert::TryInto; @@ -4765,6 +4767,8 @@ mod tests { use crate::sync::{Arc, Mutex}; use crate::io; use crate::ln::features::ChannelTypeFeatures; + + #[allow(unused_imports)] use crate::prelude::*; use std::str::FromStr; diff --git a/lightning/src/chain/mod.rs b/lightning/src/chain/mod.rs index 356520b5c..e22ccca98 100644 --- a/lightning/src/chain/mod.rs +++ b/lightning/src/chain/mod.rs @@ -21,6 +21,7 @@ use crate::ln::ChannelId; use crate::sign::ecdsa::WriteableEcdsaChannelSigner; use crate::chain::transaction::{OutPoint, TransactionData}; +#[allow(unused_imports)] use crate::prelude::*; pub mod chaininterface; diff --git a/lightning/src/chain/package.rs b/lightning/src/chain/package.rs index e304b16ef..8c833707e 100644 --- a/lightning/src/chain/package.rs +++ b/lightning/src/chain/package.rs @@ -35,12 +35,14 @@ use crate::util::logger::Logger; use crate::util::ser::{Readable, Writer, Writeable, RequiredWrapper}; use crate::io; -use crate::prelude::*; use core::cmp; use core::convert::TryInto; use core::mem; use core::ops::Deref; +#[allow(unused_imports)] +use crate::prelude::*; + use super::chaininterface::LowerBoundedFeeEstimator; const MAX_ALLOC_SIZE: usize = 64*1024; diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index b43f2f937..f6e7f7164 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -38,11 +38,13 @@ use bitcoin::hashes::Hash; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::PublicKey; use crate::io; -use crate::prelude::*; use core::time::Duration; use core::ops::Deref; use crate::sync::Arc; +#[allow(unused_imports)] +use crate::prelude::*; + /// Some information provided on receipt of payment depends on whether the payment received is a /// spontaneous payment or a "conventional" lightning payment that's paying an invoice. #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 18c4d8340..c002dfaea 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -37,7 +37,6 @@ use bitcoin::{secp256k1, Sequence, Witness}; use bitcoin::PublicKey as BitcoinPublicKey; use crate::io; -use crate::prelude::*; use core::cmp; use crate::ln::chan_utils; use crate::util::transaction_utils::sort_outputs; @@ -48,6 +47,9 @@ use crate::ln::features::ChannelTypeFeatures; use crate::crypto::utils::{sign, sign_with_aux_rand}; use super::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcKey, HtlcBasepoint, RevocationKey, RevocationBasepoint}; +#[allow(unused_imports)] +use crate::prelude::*; + /// Maximum number of one-way in-flight HTLC (protocol-level value). pub const MAX_HTLCS: u16 = 483; /// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor variant. @@ -1812,7 +1814,6 @@ pub fn get_commitment_transaction_number_obscure_factor( mod tests { use super::{CounterpartyCommitmentSecrets, ChannelPublicKeys}; use crate::chain; - use crate::prelude::*; use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment}; use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1}; use crate::util::test_utils; @@ -1825,6 +1826,9 @@ mod tests { use bitcoin::PublicKey as BitcoinPublicKey; use crate::ln::features::ChannelTypeFeatures; + #[allow(unused_imports)] + use crate::prelude::*; + struct TestCommitmentTxBuilder { commitment_number: u64, holder_funding_pubkey: PublicKey, diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 04ce90445..ff91654a3 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -78,8 +78,10 @@ //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md //! [messages]: crate::ln::msgs -use crate::{io, io_extras}; +#[allow(unused_imports)] use crate::prelude::*; + +use crate::{io, io_extras}; use core::{cmp, fmt}; use core::borrow::Borrow; use core::hash::{Hash, Hasher}; @@ -91,6 +93,7 @@ use crate::ln::msgs::DecodeError; use crate::util::ser::{Readable, WithoutLength, Writeable, Writer}; mod sealed { + #[allow(unused_imports)] use crate::prelude::*; use crate::ln::features::Features; diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index 25b32c4c7..26a384dff 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -126,7 +126,9 @@ impl From for PaymentHash { #[derive(Hash, Copy, Clone, PartialEq, Eq, Debug, Ord, PartialOrd)] pub struct PaymentSecret(pub [u8; 32]); +#[allow(unused_imports)] use crate::prelude::*; + use bitcoin::bech32; use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, WriteBase32, u5}; diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 19fbbae31..9424d341d 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -38,7 +38,9 @@ use crate::ln::onion_utils; use crate::onion_message; use crate::sign::{NodeSigner, Recipient}; +#[allow(unused_imports)] use crate::prelude::*; + #[cfg(feature = "std")] use core::convert::TryFrom; use core::fmt; @@ -1673,11 +1675,13 @@ pub struct FinalOnionHopData { mod fuzzy_internal_msgs { use bitcoin::secp256k1::PublicKey; use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay}; - use crate::prelude::*; use crate::ln::{PaymentPreimage, PaymentSecret}; use crate::ln::features::BlindedHopFeatures; use super::{FinalOnionHopData, TrampolineOnionPacket}; + #[allow(unused_imports)] + use crate::prelude::*; + // These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize // them from untrusted input): diff --git a/lightning/src/ln/onion_payment.rs b/lightning/src/ln/onion_payment.rs index a5560e280..aa8ee0ce9 100644 --- a/lightning/src/ln/onion_payment.rs +++ b/lightning/src/ln/onion_payment.rs @@ -20,7 +20,9 @@ use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING}; use crate::sign::{NodeSigner, Recipient}; use crate::util::logger::Logger; +#[allow(unused_imports)] use crate::prelude::*; + use core::ops::Deref; /// Invalid inbound onion payment. diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index a946dae67..2cbc2895c 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -30,10 +30,12 @@ use bitcoin::secp256k1::ecdh::SharedSecret; use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey}; use crate::io::{Cursor, Read}; -use crate::prelude::*; use core::convert::{AsMut, TryInto}; use core::ops::Deref; +#[allow(unused_imports)] +use crate::prelude::*; + pub(crate) struct OnionKeys { #[cfg(test)] pub(crate) shared_secret: SharedSecret, @@ -1240,10 +1242,12 @@ mod tests { use crate::ln::features::{ChannelFeatures, NodeFeatures}; use crate::ln::msgs; use crate::ln::PaymentHash; - use crate::prelude::*; use crate::routing::router::{Path, Route, RouteHop}; use crate::util::ser::{VecWriter, Writeable, Writer}; + #[allow(unused_imports)] + use crate::prelude::*; + use bitcoin::hashes::hex::FromHex; use bitcoin::secp256k1::Secp256k1; use bitcoin::secp256k1::{PublicKey, SecretKey}; diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index cfa32a009..e76da792a 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -36,7 +36,9 @@ use crate::util::atomic_counter::AtomicCounter; use crate::util::logger::{Level, Logger, WithContext}; use crate::util::string::PrintableString; +#[allow(unused_imports)] use crate::prelude::*; + use crate::io; use alloc::collections::VecDeque; use crate::sync::{Mutex, MutexGuard, FairRwLock}; @@ -2648,11 +2650,13 @@ mod tests { use bitcoin::blockdata::constants::ChainHash; use bitcoin::secp256k1::{PublicKey, SecretKey}; - use crate::prelude::*; use crate::sync::{Arc, Mutex}; use core::convert::Infallible; use core::sync::atomic::{AtomicBool, Ordering}; + #[allow(unused_imports)] + use crate::prelude::*; + #[derive(Clone)] struct FileDescriptor { fd: u16, diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index fc8371023..9b5492704 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -1,4 +1,4 @@ -// This file is Copyright its original authors, visible in version control + // This file is Copyright its original authors, visible in version control // history. // // This file is licensed under the Apache License, Version 2.0 //! +#[allow(unused)] use crate::prelude::*; use crate::util::base32; use bitcoin::hashes::{sha256d, Hash}; diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index dce160a7c..312fe7d9f 100644 --- a/lightning/src/util/ser_macros.rs +++ b/lightning/src/util/ser_macros.rs @@ -1112,8 +1112,10 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable { #[cfg(test)] mod tests { - use crate::io::{self, Cursor}; + #[allow(unused_imports)] use crate::prelude::*; + + use crate::io::{self, Cursor}; use crate::ln::msgs::DecodeError; use crate::util::ser::{Writeable, HighZeroBytesDroppedBigSize, VecWriter}; use bitcoin::hashes::hex::FromHex; diff --git a/lightning/src/util/test_channel_signer.rs b/lightning/src/util/test_channel_signer.rs index bfa3e32c9..43ac9ff87 100644 --- a/lightning/src/util/test_channel_signer.rs +++ b/lightning/src/util/test_channel_signer.rs @@ -14,7 +14,9 @@ use crate::ln::{msgs, PaymentPreimage}; use crate::sign::{InMemorySigner, ChannelSigner}; use crate::sign::ecdsa::{EcdsaChannelSigner, WriteableEcdsaChannelSigner}; +#[allow(unused_imports)] use crate::prelude::*; + use core::cmp; use crate::sync::{Mutex, Arc}; #[cfg(test)] use crate::sync::MutexGuard; diff --git a/lightning/src/util/transaction_utils.rs b/lightning/src/util/transaction_utils.rs index 12b504a69..8b0ef3da0 100644 --- a/lightning/src/util/transaction_utils.rs +++ b/lightning/src/util/transaction_utils.rs @@ -14,7 +14,9 @@ use bitcoin::consensus::encode::VarInt; use crate::ln::msgs::MAX_VALUE_MSAT; +#[allow(unused_imports)] use crate::prelude::*; + use crate::io_extras::sink; use core::cmp::Ordering; diff --git a/lightning/src/util/wakers.rs b/lightning/src/util/wakers.rs index b2c9d21b9..6c0de2bfa 100644 --- a/lightning/src/util/wakers.rs +++ b/lightning/src/util/wakers.rs @@ -17,6 +17,7 @@ use alloc::sync::Arc; use core::mem; use crate::sync::Mutex; +#[allow(unused_imports)] use crate::prelude::*; #[cfg(feature = "std")]