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

+3
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

+13-13
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

+4-3
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

+2
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

+3-6
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

+7-5
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

-37
This file was deleted.

lightning-invoice/src/utils.rs

+7-3
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

-5
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

+9-4
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

lightning/src/ln/payment_tests.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ use crate::ln::functional_test_utils;
4343
use crate::ln::functional_test_utils::*;
4444
use crate::routing::gossip::NodeId;
4545
#[cfg(feature = "std")]
46-
use {
47-
crate::util::time::tests::SinceEpoch,
48-
std::time::{SystemTime, Instant, Duration}
49-
};
46+
use std::time::{SystemTime, Instant, Duration};
47+
#[cfg(not(feature = "no-std"))]
48+
use crate::util::time::tests::SinceEpoch;
5049

5150
#[test]
5251
fn mpp_failure() {

lightning/src/ln/peer_handler.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use bitcoin::blockdata::constants::ChainHash;
1919
use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey};
2020

21-
use crate::sign::{KeysManager, NodeSigner, Recipient};
21+
use crate::sign::{NodeSigner, Recipient};
2222
use crate::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
2323
use crate::ln::ChannelId;
2424
use crate::ln::features::{InitFeatures, NodeFeatures};
@@ -33,20 +33,27 @@ use crate::ln::wire::{Encode, Type};
3333
#[cfg(not(c_bindings))]
3434
use crate::onion_message::{SimpleArcOnionMessenger, SimpleRefOnionMessenger};
3535
use crate::onion_message::{CustomOnionMessageHandler, OffersMessage, OffersMessageHandler, OnionMessageContents, PendingOnionMessage};
36-
use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, NodeAlias};
36+
use crate::routing::gossip::{NodeId, NodeAlias};
3737
use crate::util::atomic_counter::AtomicCounter;
3838
use crate::util::logger::{Logger, WithContext};
3939
use crate::util::string::PrintableString;
4040

4141
use crate::prelude::*;
4242
use crate::io;
4343
use alloc::collections::VecDeque;
44-
use crate::sync::{Arc, Mutex, MutexGuard, FairRwLock};
44+
use crate::sync::{Mutex, MutexGuard, FairRwLock};
4545
use core::sync::atomic::{AtomicBool, AtomicU32, AtomicI32, Ordering};
4646
use core::{cmp, hash, fmt, mem};
4747
use core::ops::Deref;
4848
use core::convert::Infallible;
49-
#[cfg(feature = "std")] use std::error;
49+
#[cfg(feature = "std")]
50+
use std::error;
51+
#[cfg(not(c_bindings))]
52+
use {
53+
crate::routing::gossip::{NetworkGraph, P2PGossipSync},
54+
crate::sign::KeysManager,
55+
crate::sync::Arc,
56+
};
5057

5158
use bitcoin::hashes::sha256::Hash as Sha256;
5259
use bitcoin::hashes::sha256::HashEngine as Sha256Engine;

lightning/src/ln/reload_tests.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ use crate::chain::channelmonitor::{CLOSED_CHANNEL_UPDATE_ID, ChannelMonitor};
1515
use crate::sign::EntropySource;
1616
use crate::chain::transaction::OutPoint;
1717
use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
18-
use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId, Retry, RecipientOnionFields};
18+
use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId, RecipientOnionFields};
1919
use crate::ln::msgs;
2020
use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
21-
use crate::routing::router::{RouteParameters, PaymentParameters};
2221
use crate::util::test_channel_signer::TestChannelSigner;
2322
use crate::util::test_utils;
2423
use crate::util::errors::APIError;
2524
use crate::util::ser::{Writeable, ReadableArgs};
2625
use crate::util::config::UserConfig;
27-
use crate::util::string::UntrustedString;
2826

2927
use bitcoin::hash_types::BlockHash;
3028

@@ -496,6 +494,9 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
496494

497495
#[cfg(feature = "std")]
498496
fn do_test_data_loss_protect(reconnect_panicing: bool, substantially_old: bool, not_stale: bool) {
497+
use crate::routing::router::{RouteParameters, PaymentParameters};
498+
use crate::ln::channelmanager::Retry;
499+
use crate::util::string::UntrustedString;
499500
// When we get a data_loss_protect proving we're behind, we immediately panic as the
500501
// chain::Watch API requirements have been violated (e.g. the user restored from a backup). The
501502
// panic message informs the user they should force-close without broadcasting, which is tested

lightning/src/onion_message/messenger.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ use crate::blinded_path::BlindedPath;
1919
use crate::blinded_path::message::{advance_path_by_one, ForwardTlvs, ReceiveTlvs};
2020
use crate::blinded_path::utils;
2121
use crate::events::{Event, EventHandler, EventsProvider};
22-
use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient};
22+
use crate::sign::{EntropySource, NodeSigner, Recipient};
2323
#[cfg(not(c_bindings))]
2424
use crate::ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager};
2525
use crate::ln::features::{InitFeatures, NodeFeatures};
2626
use crate::ln::msgs::{self, OnionMessage, OnionMessageHandler, SocketAddress};
2727
use crate::ln::onion_utils;
28-
use crate::ln::peer_handler::IgnoringMessageHandler;
2928
use crate::routing::gossip::{NetworkGraph, NodeId};
3029
pub use super::packet::OnionMessageContents;
3130
use super::packet::ParsedOnionMessageContents;
@@ -37,9 +36,16 @@ use crate::util::ser::Writeable;
3736
use core::fmt;
3837
use core::ops::Deref;
3938
use crate::io;
40-
use crate::sync::{Arc, Mutex};
39+
use crate::sync::Mutex;
4140
use crate::prelude::*;
4241

42+
#[cfg(not(c_bindings))]
43+
use {
44+
crate::sign::KeysManager,
45+
crate::ln::peer_handler::IgnoringMessageHandler,
46+
crate::sync::Arc,
47+
};
48+
4349
pub(super) const MAX_TIMER_TICKS: usize = 2;
4450

4551
/// A sender, receiver and forwarder of [`OnionMessage`]s.
@@ -258,7 +264,7 @@ pub struct PendingOnionMessage<T: OnionMessageContents> {
258264
///
259265
/// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
260266
/// enqueued for sending.
261-
pub type PendingOnionMessage<T: OnionMessageContents> = (T, Destination, Option<BlindedPath>);
267+
pub type PendingOnionMessage<T> = (T, Destination, Option<BlindedPath>);
262268

263269
pub(crate) fn new_pending_onion_message<T: OnionMessageContents>(
264270
contents: T, destination: Destination, reply_path: Option<BlindedPath>

0 commit comments

Comments
 (0)