Skip to content

Commit cd32708

Browse files
committed
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.
1 parent fb3a86f commit cd32708

31 files changed

+74
-14
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
22

3+
#[allow(unused_imports)]
4+
use crate::prelude::*;
5+
36
use crate::blinded_path::{BlindedHop, BlindedPath};
47
use crate::blinded_path::utils;
58
use crate::io;
69
use crate::io::Cursor;
710
use crate::ln::onion_utils;
811
use crate::onion_message::packet::ControlTlvs;
9-
use crate::prelude::*;
1012
use crate::sign::{NodeSigner, Recipient};
1113
use crate::crypto::streams::ChaChaPolyReadAdapter;
1214
use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Writeable, Writer};

lightning/src/blinded_path/payment.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use crate::ln::channelmanager::CounterpartyForwardingInfo;
1212
use crate::ln::features::BlindedHopFeatures;
1313
use crate::ln::msgs::DecodeError;
1414
use crate::offers::invoice::BlindedPayInfo;
15-
use crate::prelude::*;
1615
use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer};
1716

17+
#[allow(unused_imports)]
18+
use crate::prelude::*;
19+
1820
use core::convert::TryFrom;
1921

2022
/// An intermediate node, its outbound channel, and relay parameters.

lightning/src/blinded_path/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ use crate::crypto::streams::ChaChaPolyWriteAdapter;
2323
use crate::util::ser::{Readable, Writeable};
2424

2525
use crate::io;
26+
27+
#[allow(unused_imports)]
2628
use crate::prelude::*;
2729

2830
// TODO: DRY with onion_utils::construct_onion_keys_callback

lightning/src/chain/channelmonitor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ use crate::util::byte_utils;
5353
use crate::events::{ClosureReason, Event, EventHandler};
5454
use crate::events::bump_transaction::{AnchorDescriptor, BumpTransactionEvent};
5555

56+
#[allow(unused_imports)]
5657
use crate::prelude::*;
58+
5759
use core::{cmp, mem};
5860
use crate::io::{self, Error};
5961
use core::convert::TryInto;
@@ -4765,6 +4767,8 @@ mod tests {
47654767
use crate::sync::{Arc, Mutex};
47664768
use crate::io;
47674769
use crate::ln::features::ChannelTypeFeatures;
4770+
4771+
#[allow(unused_imports)]
47684772
use crate::prelude::*;
47694773

47704774
use std::str::FromStr;

lightning/src/chain/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::ln::ChannelId;
2121
use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
2222
use crate::chain::transaction::{OutPoint, TransactionData};
2323

24+
#[allow(unused_imports)]
2425
use crate::prelude::*;
2526

2627
pub mod chaininterface;

lightning/src/chain/package.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ use crate::util::logger::Logger;
3535
use crate::util::ser::{Readable, Writer, Writeable, RequiredWrapper};
3636

3737
use crate::io;
38-
use crate::prelude::*;
3938
use core::cmp;
4039
use core::convert::TryInto;
4140
use core::mem;
4241
use core::ops::Deref;
4342

43+
#[allow(unused_imports)]
44+
use crate::prelude::*;
45+
4446
use super::chaininterface::LowerBoundedFeeEstimator;
4547

4648
const MAX_ALLOC_SIZE: usize = 64*1024;

lightning/src/events/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ use bitcoin::hashes::Hash;
3838
use bitcoin::hashes::sha256::Hash as Sha256;
3939
use bitcoin::secp256k1::PublicKey;
4040
use crate::io;
41-
use crate::prelude::*;
4241
use core::time::Duration;
4342
use core::ops::Deref;
4443
use crate::sync::Arc;
4544

45+
#[allow(unused_imports)]
46+
use crate::prelude::*;
47+
4648
/// Some information provided on receipt of payment depends on whether the payment received is a
4749
/// spontaneous payment or a "conventional" lightning payment that's paying an invoice.
4850
#[derive(Clone, Debug, PartialEq, Eq)]

lightning/src/ln/chan_utils.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use bitcoin::{secp256k1, Sequence, Witness};
3737
use bitcoin::PublicKey as BitcoinPublicKey;
3838

3939
use crate::io;
40-
use crate::prelude::*;
4140
use core::cmp;
4241
use crate::ln::chan_utils;
4342
use crate::util::transaction_utils::sort_outputs;
@@ -48,6 +47,9 @@ use crate::ln::features::ChannelTypeFeatures;
4847
use crate::crypto::utils::{sign, sign_with_aux_rand};
4948
use super::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcKey, HtlcBasepoint, RevocationKey, RevocationBasepoint};
5049

50+
#[allow(unused_imports)]
51+
use crate::prelude::*;
52+
5153
/// Maximum number of one-way in-flight HTLC (protocol-level value).
5254
pub const MAX_HTLCS: u16 = 483;
5355
/// 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(
18121814
mod tests {
18131815
use super::{CounterpartyCommitmentSecrets, ChannelPublicKeys};
18141816
use crate::chain;
1815-
use crate::prelude::*;
18161817
use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment};
18171818
use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1};
18181819
use crate::util::test_utils;
@@ -1825,6 +1826,9 @@ mod tests {
18251826
use bitcoin::PublicKey as BitcoinPublicKey;
18261827
use crate::ln::features::ChannelTypeFeatures;
18271828

1829+
#[allow(unused_imports)]
1830+
use crate::prelude::*;
1831+
18281832
struct TestCommitmentTxBuilder {
18291833
commitment_number: u64,
18301834
holder_funding_pubkey: PublicKey,

lightning/src/ln/features.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@
7878
//! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md
7979
//! [messages]: crate::ln::msgs
8080
81-
use crate::{io, io_extras};
81+
#[allow(unused_imports)]
8282
use crate::prelude::*;
83+
84+
use crate::{io, io_extras};
8385
use core::{cmp, fmt};
8486
use core::borrow::Borrow;
8587
use core::hash::{Hash, Hasher};
@@ -91,6 +93,7 @@ use crate::ln::msgs::DecodeError;
9193
use crate::util::ser::{Readable, WithoutLength, Writeable, Writer};
9294

9395
mod sealed {
96+
#[allow(unused_imports)]
9497
use crate::prelude::*;
9598
use crate::ln::features::Features;
9699

lightning/src/ln/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ impl From<PaymentPreimage> for PaymentHash {
126126
#[derive(Hash, Copy, Clone, PartialEq, Eq, Debug, Ord, PartialOrd)]
127127
pub struct PaymentSecret(pub [u8; 32]);
128128

129+
#[allow(unused_imports)]
129130
use crate::prelude::*;
131+
130132
use bitcoin::bech32;
131133
use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, WriteBase32, u5};
132134

0 commit comments

Comments
 (0)