Skip to content

Commit 15b7f66

Browse files
authored
Merge pull request #2788 from tnull/2023-12-enforce-no-warnings-ci
Deny warnings in CI
2 parents 4deb263 + 2d6464c commit 15b7f66

File tree

18 files changed

+85
-98
lines changed

18 files changed

+85
-98
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
run: |
4040
sudo apt-get -y install shellcheck
4141
shellcheck ci/ci-tests.sh
42+
- name: Set RUSTFLAGS to deny warnings
43+
if: "matrix.toolchain == '1.63.0'"
44+
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
4245
- name: Run CI script
4346
shell: bash # Default on Winblows is powershell
4447
run: CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh

ci/ci-tests.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ if [[ "$HOST_PLATFORM" != *windows* ]]; then
9494

9595
DOWNLOAD_ELECTRS_AND_BITCOIND
9696

97-
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-blocking
98-
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-blocking
99-
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async
100-
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async
101-
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async-https
102-
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async-https
103-
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features electrum
104-
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features electrum
97+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-blocking
98+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-blocking
99+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async
100+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async
101+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async-https
102+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async-https
103+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features electrum
104+
RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features electrum
105105

106106
popd
107107
fi
@@ -125,7 +125,7 @@ popd
125125
echo -e "\n\nBuilding with all Log-Limiting features"
126126
pushd lightning
127127
grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
128-
cargo check --verbose --color always --features "$FEATURE"
128+
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
129129
done
130130
popd
131131

@@ -138,9 +138,9 @@ done
138138

139139
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
140140
# check if there is a conflict between no-std and the c_bindings cfg
141-
RUSTFLAGS="--cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
141+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
142142
done
143-
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always
143+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
144144

145145
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
146146
pushd lightning
@@ -174,5 +174,5 @@ if [ -f "$(which arm-none-eabi-gcc)" ]; then
174174
fi
175175

176176
echo -e "\n\nTest cfg-flag builds"
177-
RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
178-
RUSTFLAGS="$RUSTFLAGS --cfg=async_signing" cargo test --verbose --color always -p lightning
177+
RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
178+
RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning

lightning-background-processor/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ use lightning::chain::chainmonitor::{ChainMonitor, Persist};
2727
use lightning::sign::{EntropySource, NodeSigner, SignerProvider};
2828
use lightning::events::{Event, PathFailure};
2929
#[cfg(feature = "std")]
30-
use lightning::events::{EventHandler, EventsProvider};
30+
use lightning::events::EventHandler;
31+
#[cfg(any(feature = "std", feature = "futures"))]
32+
use lightning::events::EventsProvider;
33+
3134
use lightning::ln::channelmanager::ChannelManager;
3235
use lightning::ln::msgs::OnionMessageHandler;
3336
use lightning::ln::peer_handler::APeerManager;
@@ -727,8 +730,6 @@ async fn process_onion_message_handler_events_async<
727730
where
728731
PM::Target: APeerManager + Send + Sync,
729732
{
730-
use lightning::events::EventsProvider;
731-
732733
let events = core::cell::RefCell::new(Vec::new());
733734
peer_manager.onion_message_handler().process_pending_events(&|e| events.borrow_mut().push(e));
734735

lightning-block-sync/src/convert.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,12 @@ impl TryInto<BlockHash> for JsonResponse {
247247
/// The REST `getutxos` endpoint retuns a whole pile of data we don't care about and one bit we do
248248
/// - whether the `hit bitmap` field had any entries. Thus we condense the result down into only
249249
/// that.
250+
#[cfg(feature = "rest-client")]
250251
pub(crate) struct GetUtxosResponse {
251252
pub(crate) hit_bitmap_nonempty: bool
252253
}
253254

255+
#[cfg(feature = "rest-client")]
254256
impl TryInto<GetUtxosResponse> for JsonResponse {
255257
type Error = std::io::Error;
256258

lightning-invoice/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ mod de;
7777
mod ser;
7878
mod tb;
7979

80+
#[allow(unused_imports)]
8081
mod prelude {
8182
#[cfg(feature = "hashbrown")]
8283
extern crate hashbrown;
@@ -92,10 +93,6 @@ mod prelude {
9293

9394
use crate::prelude::*;
9495

95-
/// Sync compat for std/no_std
96-
#[cfg(not(feature = "std"))]
97-
mod sync;
98-
9996
/// Errors that indicate what is wrong with the invoice. They have some granularity for debug
10097
/// reasons, but should generally result in an "invalid BOLT11 invoice" message for the user.
10198
#[allow(missing_docs)]
@@ -2049,7 +2046,7 @@ mod test {
20492046
use lightning::routing::router::RouteHintHop;
20502047
use secp256k1::Secp256k1;
20512048
use secp256k1::{SecretKey, PublicKey};
2052-
use std::time::{UNIX_EPOCH, Duration};
2049+
use std::time::Duration;
20532050

20542051
let secp_ctx = Secp256k1::new();
20552052

@@ -2138,7 +2135,7 @@ mod test {
21382135
assert_eq!(invoice.currency(), Currency::BitcoinTestnet);
21392136
#[cfg(feature = "std")]
21402137
assert_eq!(
2141-
invoice.timestamp().duration_since(UNIX_EPOCH).unwrap().as_secs(),
2138+
invoice.timestamp().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(),
21422139
1234567
21432140
);
21442141
assert_eq!(invoice.payee_pub_key(), Some(&public_key));

lightning-invoice/src/payment.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ mod tests {
8585
use super::*;
8686
use crate::{InvoiceBuilder, Currency};
8787
use bitcoin::hashes::sha256::Hash as Sha256;
88-
use lightning::events::Event;
89-
use lightning::ln::channelmanager::{Retry, PaymentId};
90-
use lightning::ln::msgs::ChannelMessageHandler;
9188
use lightning::ln::PaymentSecret;
92-
use lightning::ln::functional_test_utils::*;
9389
use lightning::routing::router::Payee;
9490
use secp256k1::{SecretKey, PublicKey, Secp256k1};
95-
use std::time::{SystemTime, Duration};
91+
use core::time::Duration;
92+
#[cfg(feature = "std")]
93+
use std::time::SystemTime;
9694

9795
fn duration_since_epoch() -> Duration {
9896
#[cfg(feature = "std")]
@@ -171,6 +169,10 @@ mod tests {
171169
#[test]
172170
#[cfg(feature = "std")]
173171
fn payment_metadata_end_to_end() {
172+
use lightning::events::Event;
173+
use lightning::ln::channelmanager::{Retry, PaymentId};
174+
use lightning::ln::msgs::ChannelMessageHandler;
175+
use lightning::ln::functional_test_utils::*;
174176
// Test that a payment metadata read from an invoice passed to `pay_invoice` makes it all
175177
// the way out through the `PaymentClaimable` event.
176178
let chanmon_cfgs = create_chanmon_cfgs(2);

lightning-invoice/src/sync.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

lightning-invoice/src/utils.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,14 +816,15 @@ impl<'a, 'b, L: Deref> WithChannelDetails<'a, 'b, L> where L::Target: Logger {
816816

817817
#[cfg(test)]
818818
mod test {
819-
use core::cell::RefCell;
820819
use core::time::Duration;
821820
use crate::{Currency, Description, Bolt11InvoiceDescription, SignOrCreationError, CreationError};
822821
use bitcoin::hashes::{Hash, sha256};
823822
use bitcoin::hashes::sha256::Hash as Sha256;
824823
use lightning::sign::PhantomKeysManager;
825-
use lightning::events::{MessageSendEvent, MessageSendEventsProvider, Event, EventsProvider};
826-
use lightning::ln::{PaymentPreimage, PaymentHash};
824+
use lightning::events::{MessageSendEvent, MessageSendEventsProvider};
825+
use lightning::ln::PaymentHash;
826+
#[cfg(feature = "std")]
827+
use lightning::ln::PaymentPreimage;
827828
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY_DELTA, PaymentId, RecipientOnionFields, Retry};
828829
use lightning::ln::functional_test_utils::*;
829830
use lightning::ln::msgs::ChannelMessageHandler;
@@ -1294,6 +1295,9 @@ mod test {
12941295

12951296
#[cfg(feature = "std")]
12961297
fn do_test_multi_node_receive(user_generated_pmt_hash: bool) {
1298+
use lightning::events::{Event, EventsProvider};
1299+
use core::cell::RefCell;
1300+
12971301
let mut chanmon_cfgs = create_chanmon_cfgs(3);
12981302
let seed_1 = [42u8; 32];
12991303
let seed_2 = [43u8; 32];

lightning-persister/src/fs_store.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,6 @@ mod tests {
381381
use lightning::util::persist::read_channel_monitors;
382382
use std::fs;
383383
use std::str::FromStr;
384-
#[cfg(target_os = "windows")]
385-
use {
386-
lightning::get_event_msg,
387-
lightning::ln::msgs::ChannelMessageHandler,
388-
};
389384

390385
impl Drop for FilesystemStore {
391386
fn drop(&mut self) {

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, Ch
4747
use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
4848
#[cfg(any(feature = "_test_utils", test))]
4949
use crate::ln::features::Bolt11InvoiceFeatures;
50-
use crate::routing::gossip::NetworkGraph;
51-
use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
52-
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
50+
use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
5351
use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundOnionErr, NextPacketDetails};
5452
use crate::ln::msgs;
5553
use crate::ln::onion_utils;
@@ -66,7 +64,7 @@ use crate::offers::offer::{DerivedMetadata, Offer, OfferBuilder};
6664
use crate::offers::parse::Bolt12SemanticError;
6765
use crate::offers::refund::{Refund, RefundBuilder};
6866
use crate::onion_message::{Destination, MessageRouter, OffersMessage, OffersMessageHandler, PendingOnionMessage, new_pending_onion_message};
69-
use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider};
67+
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
7068
use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
7169
use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
7270
use crate::util::wakers::{Future, Notifier};
@@ -75,6 +73,13 @@ use crate::util::string::UntrustedString;
7573
use crate::util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
7674
use crate::util::logger::{Level, Logger, WithContext};
7775
use crate::util::errors::APIError;
76+
#[cfg(not(c_bindings))]
77+
use {
78+
crate::routing::router::DefaultRouter,
79+
crate::routing::gossip::NetworkGraph,
80+
crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters},
81+
crate::sign::KeysManager,
82+
};
7883

7984
use alloc::collections::{btree_map, BTreeMap};
8085

0 commit comments

Comments
 (0)