Skip to content

Commit 9307678

Browse files
committed
Bump workspace to rust edition 2018
Mostly motivated by the need of async/await.
1 parent e61f3a2 commit 9307678

Some content is hidden

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

68 files changed

+833
-828
lines changed

fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "lightning-fuzz"
33
version = "0.0.1"
44
authors = ["Automatically generated"]
55
publish = false
6+
edition = "2018"
67
# Because the function is unused it gets dropped before we link lightning, so
78
# we have to duplicate build.rs here. Note that this is only required for
89
# fuzzing mode.

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
88
keywords = [ "lightning", "bitcoin", "invoice", "BOLT11" ]
99
readme = "README.md"
1010
repository = "https://github.com/lightningdevkit/rust-lightning/"
11+
edition = "2018"
1112

1213
[package.metadata.docs.rs]
1314
all-features = true

lightning-invoice/fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "lightning-invoice-fuzz"
33
version = "0.0.1"
44
authors = ["Automatically generated"]
55
publish = false
6+
edition = "2018"
67

78
[package.metadata]
89
cargo-fuzz = true

lightning-invoice/src/de.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl FromStr for SiPrefix {
197197
type Err = ParseError;
198198

199199
fn from_str(currency_prefix: &str) -> Result<Self, ParseError> {
200-
use SiPrefix::*;
200+
use crate::SiPrefix::*;
201201
match currency_prefix {
202202
"m" => Ok(Milli),
203203
"u" => Ok(Micro),
@@ -715,15 +715,15 @@ impl From<ParseError> for ParseOrSemanticError {
715715
}
716716
}
717717

718-
impl From<::SemanticError> for ParseOrSemanticError {
718+
impl From<crate::SemanticError> for ParseOrSemanticError {
719719
fn from(e: SemanticError) -> Self {
720720
ParseOrSemanticError::SemanticError(e)
721721
}
722722
}
723723

724724
#[cfg(test)]
725725
mod test {
726-
use de::ParseError;
726+
use crate::de::ParseError;
727727
use secp256k1::PublicKey;
728728
use bech32::u5;
729729
use bitcoin_hashes::hex::FromHex;
@@ -749,7 +749,7 @@ mod test {
749749

750750
#[test]
751751
fn test_parse_currency_prefix() {
752-
use Currency;
752+
use crate::Currency;
753753

754754
assert_eq!("bc".parse::<Currency>(), Ok(Currency::Bitcoin));
755755
assert_eq!("tb".parse::<Currency>(), Ok(Currency::BitcoinTestnet));
@@ -761,7 +761,7 @@ mod test {
761761

762762
#[test]
763763
fn test_parse_int_from_bytes_be() {
764-
use de::parse_int_be;
764+
use crate::de::parse_int_be;
765765

766766
assert_eq!(parse_int_be::<u32, u8>(&[1, 2, 3, 4], 256), Some(16909060));
767767
assert_eq!(parse_int_be::<u32, u8>(&[1, 3], 32), Some(35));
@@ -771,7 +771,7 @@ mod test {
771771

772772
#[test]
773773
fn test_parse_sha256_hash() {
774-
use Sha256;
774+
use crate::Sha256;
775775
use bech32::FromBase32;
776776

777777
let input = from_bech32(
@@ -794,7 +794,7 @@ mod test {
794794

795795
#[test]
796796
fn test_parse_description() {
797-
use ::Description;
797+
use crate::Description;
798798
use bech32::FromBase32;
799799

800800
let input = from_bech32("xysxxatsyp3k7enxv4js".as_bytes());
@@ -804,7 +804,7 @@ mod test {
804804

805805
#[test]
806806
fn test_parse_payee_pub_key() {
807-
use ::PayeePubKey;
807+
use crate::PayeePubKey;
808808
use bech32::FromBase32;
809809

810810
let input = from_bech32("q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv66".as_bytes());
@@ -828,7 +828,7 @@ mod test {
828828

829829
#[test]
830830
fn test_parse_expiry_time() {
831-
use ::ExpiryTime;
831+
use crate::ExpiryTime;
832832
use bech32::FromBase32;
833833

834834
let input = from_bech32("pu".as_bytes());
@@ -841,7 +841,7 @@ mod test {
841841

842842
#[test]
843843
fn test_parse_min_final_cltv_expiry() {
844-
use ::MinFinalCltvExpiry;
844+
use crate::MinFinalCltvExpiry;
845845
use bech32::FromBase32;
846846

847847
let input = from_bech32("pr".as_bytes());
@@ -852,7 +852,7 @@ mod test {
852852

853853
#[test]
854854
fn test_parse_fallback() {
855-
use Fallback;
855+
use crate::Fallback;
856856
use bech32::FromBase32;
857857

858858
let cases = vec![
@@ -911,9 +911,9 @@ mod test {
911911
fn test_parse_route() {
912912
use lightning::routing::gossip::RoutingFees;
913913
use lightning::routing::router::{RouteHint, RouteHintHop};
914-
use ::PrivateRoute;
914+
use crate::PrivateRoute;
915915
use bech32::FromBase32;
916-
use de::parse_int_be;
916+
use crate::de::parse_int_be;
917917

918918
let input = from_bech32(
919919
"q20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqa\
@@ -968,8 +968,8 @@ mod test {
968968
fn test_payment_secret_and_features_de_and_ser() {
969969
use lightning::ln::features::InvoiceFeatures;
970970
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
971-
use TaggedField::*;
972-
use {SiPrefix, SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart,
971+
use crate::TaggedField::*;
972+
use crate::{SiPrefix, SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart,
973973
Currency, Sha256, PositiveTimestamp};
974974

975975
// Feature bits 9, 15, and 99 are set.
@@ -988,8 +988,8 @@ mod test {
988988
PaymentHash(Sha256(sha256::Hash::from_hex(
989989
"0001020304050607080900010203040506070809000102030405060708090102"
990990
).unwrap())).into(),
991-
Description(::Description::new("coffee beans".to_owned()).unwrap()).into(),
992-
PaymentSecret(::PaymentSecret([17; 32])).into(),
991+
Description(crate::Description::new("coffee beans".to_owned()).unwrap()).into(),
992+
PaymentSecret(crate::PaymentSecret([17; 32])).into(),
993993
Features(expected_features).into()]}
994994
},
995995
hash: [0xb1, 0x96, 0x46, 0xc3, 0xbc, 0x56, 0x76, 0x1d, 0x20, 0x65, 0x6e, 0x0e, 0x32,
@@ -1013,9 +1013,9 @@ mod test {
10131013

10141014
#[test]
10151015
fn test_raw_signed_invoice_deserialization() {
1016-
use TaggedField::*;
1016+
use crate::TaggedField::*;
10171017
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
1018-
use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
1018+
use crate::{SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
10191019
PositiveTimestamp};
10201020

10211021
assert_eq!(
@@ -1036,7 +1036,7 @@ mod test {
10361036
"0001020304050607080900010203040506070809000102030405060708090102"
10371037
).unwrap())).into(),
10381038
Description(
1039-
::Description::new(
1039+
crate::Description::new(
10401040
"Please consider supporting this project".to_owned()
10411041
).unwrap()
10421042
).into(),

lightning-invoice/src/lib.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mod prelude {
8686
pub use alloc::string::ToString;
8787
}
8888

89-
use prelude::*;
89+
use crate::prelude::*;
9090

9191
/// Sync compat for std/no_std
9292
#[cfg(feature = "std")]
@@ -135,7 +135,7 @@ pub enum ParseOrSemanticError {
135135
ParseError(ParseError),
136136

137137
/// The invoice could be decoded but violates the BOLT11 standard
138-
SemanticError(::SemanticError),
138+
SemanticError(crate::SemanticError),
139139
}
140140

141141
/// The number of bits used to represent timestamps as defined in BOLT 11.
@@ -360,7 +360,7 @@ impl SiPrefix {
360360
/// (C-not exported) As we don't yet support a slice of enums, and also because this function
361361
/// isn't the most critical to expose.
362362
pub fn values_desc() -> &'static [SiPrefix] {
363-
use SiPrefix::*;
363+
use crate::SiPrefix::*;
364364
static VALUES: [SiPrefix; 4] = [Milli, Micro, Nano, Pico];
365365
&VALUES
366366
}
@@ -1562,15 +1562,15 @@ mod test {
15621562
#[test]
15631563
fn test_system_time_bounds_assumptions() {
15641564
assert_eq!(
1565-
::PositiveTimestamp::from_unix_timestamp(::MAX_TIMESTAMP + 1),
1566-
Err(::CreationError::TimestampOutOfBounds)
1565+
crate::PositiveTimestamp::from_unix_timestamp(crate::MAX_TIMESTAMP + 1),
1566+
Err(crate::CreationError::TimestampOutOfBounds)
15671567
);
15681568
}
15691569

15701570
#[test]
15711571
fn test_calc_invoice_hash() {
1572-
use ::{RawInvoice, RawHrp, RawDataPart, Currency, PositiveTimestamp};
1573-
use ::TaggedField::*;
1572+
use crate::{RawInvoice, RawHrp, RawDataPart, Currency, PositiveTimestamp};
1573+
use crate::TaggedField::*;
15741574

15751575
let invoice = RawInvoice {
15761576
hrp: RawHrp {
@@ -1581,10 +1581,10 @@ mod test {
15811581
data: RawDataPart {
15821582
timestamp: PositiveTimestamp::from_unix_timestamp(1496314658).unwrap(),
15831583
tagged_fields: vec![
1584-
PaymentHash(::Sha256(sha256::Hash::from_hex(
1584+
PaymentHash(crate::Sha256(sha256::Hash::from_hex(
15851585
"0001020304050607080900010203040506070809000102030405060708090102"
15861586
).unwrap())).into(),
1587-
Description(::Description::new(
1587+
Description(crate::Description::new(
15881588
"Please consider supporting this project".to_owned()
15891589
).unwrap()).into(),
15901590
],
@@ -1602,11 +1602,11 @@ mod test {
16021602

16031603
#[test]
16041604
fn test_check_signature() {
1605-
use TaggedField::*;
1605+
use crate::TaggedField::*;
16061606
use secp256k1::Secp256k1;
16071607
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
16081608
use secp256k1::{SecretKey, PublicKey};
1609-
use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
1609+
use crate::{SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
16101610
PositiveTimestamp};
16111611

16121612
let invoice = SignedRawInvoice {
@@ -1623,7 +1623,7 @@ mod test {
16231623
"0001020304050607080900010203040506070809000102030405060708090102"
16241624
).unwrap())).into(),
16251625
Description(
1626-
::Description::new(
1626+
crate::Description::new(
16271627
"Please consider supporting this project".to_owned()
16281628
).unwrap()
16291629
).into(),
@@ -1659,7 +1659,7 @@ mod test {
16591659
).unwrap();
16601660
let public_key = PublicKey::from_secret_key(&Secp256k1::new(), &private_key);
16611661

1662-
assert_eq!(invoice.recover_payee_pub_key(), Ok(::PayeePubKey(public_key)));
1662+
assert_eq!(invoice.recover_payee_pub_key(), Ok(crate::PayeePubKey(public_key)));
16631663

16641664
let (raw_invoice, _, _) = invoice.into_parts();
16651665
let new_signed = raw_invoice.sign::<_, ()>(|hash| {
@@ -1671,11 +1671,11 @@ mod test {
16711671

16721672
#[test]
16731673
fn test_check_feature_bits() {
1674-
use TaggedField::*;
1674+
use crate::TaggedField::*;
16751675
use lightning::ln::features::InvoiceFeatures;
16761676
use secp256k1::Secp256k1;
16771677
use secp256k1::SecretKey;
1678-
use {RawInvoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp, Invoice,
1678+
use crate::{RawInvoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp, Invoice,
16791679
SemanticError};
16801680

16811681
let private_key = SecretKey::from_slice(&[42; 32]).unwrap();
@@ -1693,7 +1693,7 @@ mod test {
16931693
"0001020304050607080900010203040506070809000102030405060708090102"
16941694
).unwrap())).into(),
16951695
Description(
1696-
::Description::new(
1696+
crate::Description::new(
16971697
"Please consider supporting this project".to_owned()
16981698
).unwrap()
16991699
).into(),
@@ -1765,7 +1765,7 @@ mod test {
17651765

17661766
#[test]
17671767
fn test_builder_amount() {
1768-
use ::*;
1768+
use crate::*;
17691769

17701770
let builder = InvoiceBuilder::new(Currency::Bitcoin)
17711771
.description("Test".into())
@@ -1792,7 +1792,7 @@ mod test {
17921792

17931793
#[test]
17941794
fn test_builder_fail() {
1795-
use ::*;
1795+
use crate::*;
17961796
use lightning::routing::router::RouteHintHop;
17971797
use std::iter::FromIterator;
17981798
use secp256k1::PublicKey;
@@ -1846,7 +1846,7 @@ mod test {
18461846

18471847
#[test]
18481848
fn test_builder_ok() {
1849-
use ::*;
1849+
use crate::*;
18501850
use lightning::routing::router::RouteHintHop;
18511851
use secp256k1::Secp256k1;
18521852
use secp256k1::{SecretKey, PublicKey};
@@ -1966,7 +1966,7 @@ mod test {
19661966

19671967
#[test]
19681968
fn test_default_values() {
1969-
use ::*;
1969+
use crate::*;
19701970
use secp256k1::Secp256k1;
19711971
use secp256k1::SecretKey;
19721972

@@ -1992,7 +1992,7 @@ mod test {
19921992

19931993
#[test]
19941994
fn test_expiration() {
1995-
use ::*;
1995+
use crate::*;
19961996
use secp256k1::Secp256k1;
19971997
use secp256k1::SecretKey;
19981998

lightning-invoice/src/payment.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ use lightning::util::errors::APIError;
150150
use lightning::util::events::{Event, EventHandler};
151151
use lightning::util::logger::Logger;
152152
use lightning::util::ser::Writeable;
153-
use time_utils::Time;
153+
use crate::time_utils::Time;
154154
use crate::sync::Mutex;
155155

156156
use secp256k1::PublicKey;
@@ -762,7 +762,7 @@ impl lightning::util::ser::Readable for InFlightHtlcs {
762762
mod tests {
763763
use super::*;
764764
use crate::{InvoiceBuilder, Currency};
765-
use utils::{ScorerAccountingForInFlightHtlcs, create_invoice_from_channelmanager_and_duration_since_epoch};
765+
use crate::utils::{ScorerAccountingForInFlightHtlcs, create_invoice_from_channelmanager_and_duration_since_epoch};
766766
use bitcoin_hashes::sha256::Hash as Sha256;
767767
use lightning::ln::PaymentPreimage;
768768
use lightning::ln::channelmanager;
@@ -780,8 +780,8 @@ mod tests {
780780
use std::collections::VecDeque;
781781
use std::ops::DerefMut;
782782
use std::time::{SystemTime, Duration};
783-
use time_utils::tests::SinceEpoch;
784-
use DEFAULT_EXPIRY_TIME;
783+
use crate::time_utils::tests::SinceEpoch;
784+
use crate::DEFAULT_EXPIRY_TIME;
785785
use lightning::util::errors::APIError::{ChannelUnavailable, MonitorUpdateInProgress};
786786

787787
fn invoice(payment_preimage: PaymentPreimage) -> Invoice {

0 commit comments

Comments
 (0)