From 54fa6280cfe2ef4e7c2cd16ef3b1c0cf446bd26f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 25 Sep 2022 14:24:13 +0000 Subject: [PATCH] Don't make references to `std` in `lightning-invoice` in bindings As we support `no-std` for `lightning-invoice` builds, we should support them in `c_bindings` as well, which we add a test for in CI here. --- .github/workflows/build.yml | 2 ++ lightning-invoice/src/payment.rs | 2 +- lightning-invoice/src/utils.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be52e057..49b857c3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,6 +127,8 @@ jobs: cargo test --verbose --color always --no-default-features --features no-std # check if there is a conflict between no-std and the default std feature cargo test --verbose --color always --features no-std + # check if there is a conflict between no-std and the c_bindings cfg + RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std # check no-std compatibility across dependencies cd .. cd no-std-check diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index a1c0db58..ee85fab0 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -1913,7 +1913,7 @@ mod tests { #[cfg(c_bindings)] impl lightning::util::ser::Writeable for TestScorer { - fn write(&self, _: &mut W) -> Result<(), std::io::Error> { unreachable!(); } + fn write(&self, _: &mut W) -> Result<(), lightning::io::Error> { unreachable!(); } } impl Score for TestScorer { diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index 5faecbfa..d7185c99 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -559,7 +559,7 @@ impl<'a, S: Score> ScorerAccountingForInFlightHtlcs<'a, S> { #[cfg(c_bindings)] impl<'a, S:Score> lightning::util::ser::Writeable for ScorerAccountingForInFlightHtlcs<'a, S> { - fn write(&self, writer: &mut W) -> Result<(), std::io::Error> { self.scorer.write(writer) } + fn write(&self, writer: &mut W) -> Result<(), lightning::io::Error> { self.scorer.write(writer) } } impl<'a, S: Score> Score for ScorerAccountingForInFlightHtlcs<'a, S> { -- 2.30.2