Skip to content

Commit ae0d825

Browse files
committed
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.
1 parent 061d396 commit ae0d825

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+47
-78
lines changed

lightning-invoice/src/de.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#[cfg(feature = "std")]
22
use std::error;
3+
#[cfg(not(feature = "std"))]
34
use core::convert::TryFrom;
45
use core::fmt;
56
use core::fmt::{Display, Formatter};

lightning-invoice/src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use secp256k1::PublicKey;
1919
use alloc::collections::{btree_map, BTreeMap};
2020
use core::ops::Deref;
2121
use core::time::Duration;
22+
#[cfg(not(feature = "std"))]
2223
use core::iter::Iterator;
2324

2425
/// Utility to create an invoice that can be paid to one of multiple nodes, or a "phantom invoice."

lightning/src/blinded_path/payment.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer}
1717
#[allow(unused_imports)]
1818
use crate::prelude::*;
1919

20-
use core::convert::TryFrom;
21-
2220
/// An intermediate node, its outbound channel, and relay parameters.
2321
#[derive(Clone, Debug)]
2422
pub struct ForwardNode {

lightning/src/chain/chaininterface.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
//! disconnections, transaction broadcasting, and feerate information requests.
1515
1616
use core::{cmp, ops::Deref};
17-
use core::convert::TryInto;
17+
18+
use crate::prelude::*;
1819

1920
use bitcoin::blockdata::transaction::Transaction;
2021

lightning/src/chain/channelmonitor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ use crate::prelude::*;
5858

5959
use core::{cmp, mem};
6060
use crate::io::{self, Error};
61-
use core::convert::TryInto;
6261
use core::ops::Deref;
6362
use crate::sync::{Mutex, LockTestExt};
6463

lightning/src/chain/package.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use crate::util::ser::{Readable, Writer, Writeable, RequiredWrapper};
3636

3737
use crate::io;
3838
use core::cmp;
39-
use core::convert::TryInto;
4039
use core::mem;
4140
use core::ops::Deref;
4241

lightning/src/crypto/chacha20.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#[cfg(not(fuzzing))]
1313
mod real_chacha {
1414
use core::cmp;
15-
use core::convert::TryInto;
1615

1716
#[derive(Clone, Copy, PartialEq, Eq)]
1817
#[allow(non_camel_case_types)]
@@ -335,11 +334,10 @@ pub use self::fuzzy_chacha::ChaCha20;
335334

336335
#[cfg(test)]
337336
mod test {
338-
use alloc::vec;
339-
use alloc::vec::{Vec};
340-
use core::convert::TryInto;
341337
use core::iter::repeat;
342338

339+
use crate::prelude::*;
340+
343341
use super::ChaCha20;
344342

345343
#[test]

lightning/src/crypto/poly1305.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// https://github.com/floodyberry/poly1305-donna
99

1010
use core::cmp::min;
11-
use core::convert::TryInto;
11+
12+
use crate::prelude::*;
1213

1314
#[derive(Clone, Copy)]
1415
pub struct Poly1305 {
@@ -206,7 +207,6 @@ impl Poly1305 {
206207
#[cfg(test)]
207208
mod test {
208209
use core::iter::repeat;
209-
use alloc::vec::Vec;
210210

211211
use super::Poly1305;
212212

lightning/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,15 @@ mod io_extras {
165165
}
166166

167167
mod prelude {
168+
#![allow(unused_imports)]
169+
168170
pub use alloc::{vec, vec::Vec, string::String, collections::VecDeque, boxed::Box};
169171

170172
pub use alloc::borrow::ToOwned;
171173
pub use alloc::string::ToString;
172174

173-
pub use core::convert::{TryFrom, TryInto};
175+
pub use core::convert::{AsMut, AsRef, TryFrom, TryInto};
176+
pub use core::default::Default;
174177
pub use core::marker::Sized;
175178

176179
pub(crate) use crate::util::hash_tables::*;

lightning/src/ln/channel.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use crate::util::scid_utils::scid_from_parts;
5050
use crate::io;
5151
use crate::prelude::*;
5252
use core::{cmp,mem,fmt};
53-
use core::convert::TryInto;
5453
use core::ops::Deref;
5554
#[cfg(any(test, fuzzing, debug_assertions))]
5655
use crate::sync::Mutex;

lightning/src/ln/functional_tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ use bitcoin::OutPoint as BitcoinOutPoint;
4949
use bitcoin::secp256k1::Secp256k1;
5050
use bitcoin::secp256k1::{PublicKey,SecretKey};
5151

52-
use regex;
53-
5452
use crate::io;
5553
use crate::prelude::*;
5654
use alloc::collections::BTreeSet;
57-
use core::default::Default;
5855
use core::iter::repeat;
5956
use bitcoin::hashes::Hash;
6057
use crate::sync::{Arc, Mutex, RwLock};

lightning/src/ln/inbound_payment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
//! Utilities to generate inbound payment information in service of invoice creation.
1111
12-
use alloc::string::ToString;
1312
use bitcoin::hashes::{Hash, HashEngine};
1413
use bitcoin::hashes::cmp::fixed_time_eq;
1514
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
@@ -23,7 +22,9 @@ use crate::crypto::utils::hkdf_extract_expand_5x;
2322
use crate::util::errors::APIError;
2423
use crate::util::logger::Logger;
2524

26-
use core::convert::{TryFrom, TryInto};
25+
#[allow(unused_imports)]
26+
use crate::prelude::*;
27+
2728
use core::ops::Deref;
2829

2930
pub(crate) const IV_LEN: usize = 16;

lightning/src/ln/msgs.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ use crate::sign::{NodeSigner, Recipient};
4141
#[allow(unused_imports)]
4242
use crate::prelude::*;
4343

44-
#[cfg(feature = "std")]
45-
use core::convert::TryFrom;
4644
use core::fmt;
4745
use core::fmt::Debug;
4846
use core::ops::Deref;
@@ -3167,7 +3165,6 @@ impl_writeable_msg!(GossipTimestampFilter, {
31673165

31683166
#[cfg(test)]
31693167
mod tests {
3170-
use std::convert::TryFrom;
31713168
use bitcoin::{Transaction, TxIn, ScriptBuf, Sequence, Witness, TxOut};
31723169
use hex::DisplayHex;
31733170
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};

lightning/src/ln/onion_route_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
3939

4040
use crate::io;
4141
use crate::prelude::*;
42-
use core::default::Default;
4342
use bitcoin::hashes::hex::FromHex;
4443

4544
use crate::ln::functional_test_utils::*;

lightning/src/ln/onion_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
3030
use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey};
3131

3232
use crate::io::{Cursor, Read};
33-
use core::convert::{AsMut, TryInto};
3433
use core::ops::Deref;
3534

3635
#[allow(unused_imports)]

lightning/src/ln/peer_handler.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use crate::util::string::PrintableString;
4040
use crate::prelude::*;
4141

4242
use crate::io;
43-
use alloc::collections::VecDeque;
4443
use crate::sync::{Mutex, MutexGuard, FairRwLock};
4544
use core::sync::atomic::{AtomicBool, AtomicU32, AtomicI32, Ordering};
4645
use core::{cmp, hash, fmt, mem};

lightning/src/ln/priv_short_conf_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::util::ser::Writeable;
2626
use crate::util::test_utils;
2727

2828
use crate::prelude::*;
29-
use core::default::Default;
3029

3130
use crate::ln::functional_test_utils::*;
3231

lightning/src/ln/reload_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::util::config::UserConfig;
2727
use bitcoin::hash_types::BlockHash;
2828

2929
use crate::prelude::*;
30-
use core::default::Default;
3130
use crate::sync::Mutex;
3231

3332
use crate::ln::functional_test_utils::*;

lightning/src/ln/script.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ use crate::ln::features::InitFeatures;
1212
use crate::ln::msgs::DecodeError;
1313
use crate::util::ser::{Readable, Writeable, Writer};
1414

15-
use core::convert::TryFrom;
1615
use crate::io;
1716

17+
#[allow(unused_imports)]
18+
use crate::prelude::*;
19+
1820
/// A script pubkey for shutting down a channel as defined by [BOLT #2].
1921
///
2022
/// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md
@@ -167,13 +169,15 @@ impl core::fmt::Display for ShutdownScript{
167169
#[cfg(test)]
168170
mod shutdown_script_tests {
169171
use super::ShutdownScript;
172+
173+
use bitcoin::address::{WitnessProgram, WitnessVersion};
170174
use bitcoin::blockdata::opcodes;
171175
use bitcoin::blockdata::script::{Builder, ScriptBuf};
172176
use bitcoin::secp256k1::Secp256k1;
173177
use bitcoin::secp256k1::{PublicKey, SecretKey};
178+
174179
use crate::ln::features::InitFeatures;
175-
use core::convert::TryFrom;
176-
use bitcoin::address::{WitnessProgram, WitnessVersion};
180+
use crate::prelude::*;
177181

178182
fn pubkey() -> bitcoin::key::PublicKey {
179183
let secp_ctx = Secp256k1::signing_only();

lightning/src/ln/shutdown_tests.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::util::test_utils::OnGetShutdownScriptpubkey;
2525
use crate::util::errors::APIError;
2626
use crate::util::config::UserConfig;
2727
use crate::util::string::UntrustedString;
28+
use crate::prelude::*;
2829

2930
use bitcoin::{Transaction, TxOut};
3031
use bitcoin::blockdata::locktime::absolute::LockTime;
@@ -33,11 +34,6 @@ use bitcoin::blockdata::opcodes;
3334
use bitcoin::network::constants::Network;
3435
use bitcoin::address::{WitnessProgram, WitnessVersion};
3536

36-
use regex;
37-
38-
use core::default::Default;
39-
use std::convert::TryFrom;
40-
4137
use crate::ln::functional_test_utils::*;
4238

4339
#[test]

lightning/src/ln/wire.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ impl Encode for msgs::GossipTimestampFilter {
617617
mod tests {
618618
use super::*;
619619
use crate::prelude::*;
620-
use core::convert::TryInto;
621620
use crate::ln::peer_handler::IgnoringMessageHandler;
622621

623622
// Big-endian wire encoding of Pong message (type = 19, byteslen = 2).

lightning/src/offers/invoice.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
110110
use bitcoin::secp256k1::schnorr::Signature;
111111
use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion};
112112
use bitcoin::key::TweakedPublicKey;
113-
use core::convert::{AsRef, TryFrom};
114113
use core::time::Duration;
115114
use crate::io;
116115
use crate::blinded_path::BlindedPath;
@@ -1453,8 +1452,9 @@ mod tests {
14531452
use bitcoin::secp256k1::{Message, Secp256k1, XOnlyPublicKey, self};
14541453
use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion};
14551454
use bitcoin::key::TweakedPublicKey;
1456-
use core::convert::TryFrom;
1455+
14571456
use core::time::Duration;
1457+
14581458
use crate::blinded_path::{BlindedHop, BlindedPath};
14591459
use crate::sign::KeyMaterial;
14601460
use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
@@ -1463,6 +1463,7 @@ mod tests {
14631463
use crate::offers::invoice_request::InvoiceRequestTlvStreamRef;
14641464
use crate::offers::merkle::{SignError, SignatureTlvStreamRef, TaggedHash, self};
14651465
use crate::offers::offer::{Amount, OfferTlvStreamRef, Quantity};
1466+
use crate::prelude::*;
14661467
#[cfg(not(c_bindings))]
14671468
use {
14681469
crate::offers::offer::OfferBuilder,

lightning/src/offers/invoice_request.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ use bitcoin::blockdata::constants::ChainHash;
6161
use bitcoin::network::constants::Network;
6262
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
6363
use bitcoin::secp256k1::schnorr::Signature;
64-
use core::convert::{AsRef, TryFrom};
6564
use core::ops::Deref;
6665
use crate::sign::EntropySource;
6766
use crate::io;
@@ -1104,7 +1103,6 @@ mod tests {
11041103
use bitcoin::blockdata::constants::ChainHash;
11051104
use bitcoin::network::constants::Network;
11061105
use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey, self};
1107-
use core::convert::TryFrom;
11081106
use core::num::NonZeroU64;
11091107
#[cfg(feature = "std")]
11101108
use core::time::Duration;

lightning/src/offers/merkle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use bitcoin::hashes::{Hash, HashEngine, sha256};
1313
use bitcoin::secp256k1::{Message, PublicKey, Secp256k1, self};
1414
use bitcoin::secp256k1::schnorr::Signature;
15-
use core::convert::AsRef;
1615
use crate::io;
1716
use crate::util::ser::{BigSize, Readable, Writeable, Writer};
1817

lightning/src/offers/offer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
use bitcoin::blockdata::constants::ChainHash;
8080
use bitcoin::network::constants::Network;
8181
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
82-
use core::convert::TryFrom;
8382
use core::hash::{Hash, Hasher};
8483
use core::num::NonZeroU64;
8584
use core::ops::Deref;
@@ -1067,7 +1066,6 @@ mod tests {
10671066
use bitcoin::blockdata::constants::ChainHash;
10681067
use bitcoin::network::constants::Network;
10691068
use bitcoin::secp256k1::Secp256k1;
1070-
use core::convert::TryFrom;
10711069
use core::num::NonZeroU64;
10721070
use core::time::Duration;
10731071
use crate::blinded_path::{BlindedHop, BlindedPath};

lightning/src/offers/parse.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
1212
use bitcoin::bech32;
1313
use bitcoin::secp256k1;
14-
use core::convert::TryFrom;
1514
use crate::io;
1615
use crate::ln::msgs::DecodeError;
1716
use crate::util::ser::SeekReadable;
@@ -28,7 +27,6 @@ pub use sealed::Bech32Encode;
2827
mod sealed {
2928
use bitcoin::bech32;
3029
use bitcoin::bech32::{FromBase32, ToBase32};
31-
use core::convert::TryFrom;
3230
use core::fmt;
3331
use super::Bolt12ParseError;
3432

lightning/src/offers/refund.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
use bitcoin::blockdata::constants::ChainHash;
8585
use bitcoin::network::constants::Network;
8686
use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
87-
use core::convert::TryFrom;
8887
use core::hash::{Hash, Hasher};
8988
use core::ops::Deref;
9089
use core::str::FromStr;
@@ -895,8 +894,9 @@ mod tests {
895894
use bitcoin::blockdata::constants::ChainHash;
896895
use bitcoin::network::constants::Network;
897896
use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey};
898-
use core::convert::TryFrom;
897+
899898
use core::time::Duration;
899+
900900
use crate::blinded_path::{BlindedHop, BlindedPath};
901901
use crate::sign::KeyMaterial;
902902
use crate::ln::channelmanager::PaymentId;
@@ -910,6 +910,7 @@ mod tests {
910910
use crate::offers::test_utils::*;
911911
use crate::util::ser::{BigSize, Writeable};
912912
use crate::util::string::PrintableString;
913+
use crate::prelude::*;
913914

914915
trait ToBytes {
915916
fn to_bytes(&self) -> Vec<u8>;

lightning/src/offers/signer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use bitcoin::hashes::cmp::fixed_time_eq;
1414
use bitcoin::hashes::hmac::{Hmac, HmacEngine};
1515
use bitcoin::hashes::sha256::Hash as Sha256;
1616
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey, self};
17-
use core::convert::TryFrom;
1817
use core::fmt;
1918
use crate::ln::channelmanager::PaymentId;
2019
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN, Nonce};

lightning/src/offers/test_utils.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
1313
use bitcoin::secp256k1::schnorr::Signature;
14-
use core::convert::AsRef;
14+
1515
use core::time::Duration;
1616
use crate::blinded_path::{BlindedHop, BlindedPath};
1717
use crate::sign::EntropySource;
@@ -20,6 +20,9 @@ use crate::ln::features::BlindedHopFeatures;
2020
use crate::offers::invoice::BlindedPayInfo;
2121
use crate::offers::merkle::TaggedHash;
2222

23+
#[allow(unused_imports)]
24+
use crate::prelude::*;
25+
2326
pub(crate) fn fail_sign<T: AsRef<TaggedHash>>(_message: &T) -> Result<Signature, ()> {
2427
Err(())
2528
}

0 commit comments

Comments
 (0)