Skip to content

Commit afc5f0c

Browse files
rustfmt: skip all macros due to bug in rustfmt (see issues 3068, 3858)
1 parent a640cdd commit afc5f0c

24 files changed

+163
-0
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
190190
let fee_est = Arc::new(FuzzEstimator{});
191191
let broadcast = Arc::new(TestBroadcaster{});
192192

193+
#[cfg_attr(rustfmt, rustfmt_skip)]
193194
macro_rules! make_node {
194195
($node_id: expr) => { {
195196
let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new($node_id.to_string(), out.clone()));
@@ -206,6 +207,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
206207
} }
207208
}
208209

210+
#[cfg_attr(rustfmt, rustfmt_skip)]
209211
macro_rules! reload_node {
210212
($ser: expr, $node_id: expr, $old_monitors: expr) => { {
211213
let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new($node_id.to_string(), out.clone()));
@@ -244,6 +246,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
244246
}
245247

246248
let mut channel_txn = Vec::new();
249+
#[cfg_attr(rustfmt, rustfmt_skip)]
247250
macro_rules! make_channel {
248251
($source: expr, $dest: expr, $chan_id: expr) => { {
249252
$source.create_channel($dest.get_our_node_id(), 10000000, 42, 0, None).unwrap();
@@ -307,6 +310,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
307310
} }
308311
}
309312

313+
#[cfg_attr(rustfmt, rustfmt_skip)]
310314
macro_rules! confirm_txn {
311315
($node: expr) => { {
312316
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
@@ -324,6 +328,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
324328
} }
325329
}
326330

331+
#[cfg_attr(rustfmt, rustfmt_skip)]
327332
macro_rules! lock_fundings {
328333
($nodes: expr) => { {
329334
let mut node_events = Vec::new();
@@ -386,6 +391,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
386391
let mut node_c_ser = VecWriter(Vec::new());
387392
nodes[2].write(&mut node_c_ser).unwrap();
388393

394+
#[cfg_attr(rustfmt, rustfmt_skip)]
389395
macro_rules! test_return {
390396
() => { {
391397
assert_eq!(nodes[0].list_channels().len(), 1);
@@ -395,7 +401,9 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
395401
} }
396402
}
397403

404+
398405
let mut read_pos = 0;
406+
#[cfg_attr(rustfmt, rustfmt_skip)]
399407
macro_rules! get_slice {
400408
($len: expr) => {
401409
{
@@ -410,6 +418,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
410418
}
411419

412420
loop {
421+
#[cfg_attr(rustfmt, rustfmt_skip)]
413422
macro_rules! send_payment {
414423
($source: expr, $dest: expr) => { {
415424
let payment_hash = Sha256::hash(&[payment_id; 1]);
@@ -496,6 +505,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
496505
} }
497506
}
498507

508+
#[cfg_attr(rustfmt, rustfmt_skip)]
499509
macro_rules! process_msg_events {
500510
($node: expr, $corrupt_forward: expr) => { {
501511
let events = if $node == 1 {
@@ -569,6 +579,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
569579
} }
570580
}
571581

582+
#[cfg_attr(rustfmt, rustfmt_skip)]
572583
macro_rules! drain_msg_events_on_disconnect {
573584
($counterparty_id: expr) => { {
574585
if $counterparty_id == 0 {
@@ -622,6 +633,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
622633
} }
623634
}
624635

636+
#[cfg_attr(rustfmt, rustfmt_skip)]
625637
macro_rules! process_events {
626638
($node: expr, $fail: expr) => { {
627639
// In case we get 256 payments we may have a hash collision, resulting in the

fuzz/src/full_stack.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
303303
input: input.clone(),
304304
});
305305

306+
#[cfg_attr(rustfmt, rustfmt_skip)]
306307
macro_rules! get_slice {
307308
($len: expr) => {
308309
match input.get_slice($len as usize) {
@@ -312,6 +313,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
312313
}
313314
}
314315

316+
#[cfg_attr(rustfmt, rustfmt_skip)]
315317
macro_rules! get_pubkey {
316318
() => {
317319
match PublicKey::from_slice(get_slice!(33)) {

fuzz/src/msg_targets/utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl Writer for VecWriter {
2323
// Tests a message that must survive roundtrip exactly, though may not empty the read buffer
2424
// entirely
2525
#[macro_export]
26+
#[cfg_attr(rustfmt, rustfmt_skip)]
2627
macro_rules! test_msg {
2728
($MsgType: path, $data: ident) => {
2829
{
@@ -43,6 +44,7 @@ macro_rules! test_msg {
4344
// Tests a message that may lose data on roundtrip, but shoulnd't lose data compared to our
4445
// re-serialization.
4546
#[macro_export]
47+
#[cfg_attr(rustfmt, rustfmt_skip)]
4648
macro_rules! test_msg_simple {
4749
($MsgType: path, $data: ident) => {
4850
{
@@ -64,6 +66,7 @@ macro_rules! test_msg_simple {
6466
// Tests a message that must survive roundtrip exactly, and must exactly empty the read buffer and
6567
// split it back out on re-serialization.
6668
#[macro_export]
69+
#[cfg_attr(rustfmt, rustfmt_skip)]
6770
macro_rules! test_msg_exact {
6871
($MsgType: path, $data: ident) => {
6972
{
@@ -81,6 +84,7 @@ macro_rules! test_msg_exact {
8184
// Tests a message that must survive roundtrip exactly, modulo one "hole" which may be set to 0s on
8285
// re-serialization.
8386
#[macro_export]
87+
#[cfg_attr(rustfmt, rustfmt_skip)]
8488
macro_rules! test_msg_hole {
8589
($MsgType: path, $data: ident, $hole: expr, $hole_len: expr) => {
8690
{

fuzz/src/peer_crypt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fn slice_to_be16(v: &[u8]) -> u16 {
1414
#[inline]
1515
pub fn do_test(data: &[u8]) {
1616
let mut read_pos = 0;
17+
#[cfg_attr(rustfmt, rustfmt_skip)]
1718
macro_rules! get_slice {
1819
($len: expr) => {
1920
{

fuzz/src/router.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
101101
data: data.to_vec(),
102102
read_pos: AtomicUsize::new(0),
103103
});
104+
#[cfg_attr(rustfmt, rustfmt_skip)]
104105
macro_rules! get_slice_nonadvancing {
105106
($len: expr) => {
106107
match input.get_slice_nonadvancing($len as usize) {
@@ -109,6 +110,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
109110
}
110111
}
111112
}
113+
#[cfg_attr(rustfmt, rustfmt_skip)]
112114
macro_rules! get_slice {
113115
($len: expr) => {
114116
match input.get_slice($len as usize) {
@@ -118,6 +120,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
118120
}
119121
}
120122

123+
#[cfg_attr(rustfmt, rustfmt_skip)]
121124
macro_rules! decode_msg {
122125
($MsgType: path, $len: expr) => {{
123126
let mut reader = ::std::io::Cursor::new(get_slice!($len));
@@ -135,6 +138,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
135138
}}
136139
}
137140

141+
#[cfg_attr(rustfmt, rustfmt_skip)]
138142
macro_rules! decode_msg_with_len16 {
139143
($MsgType: path, $begin_len: expr, $excess: expr) => {
140144
{
@@ -144,6 +148,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
144148
}
145149
}
146150

151+
#[cfg_attr(rustfmt, rustfmt_skip)]
147152
macro_rules! get_pubkey {
148153
() => {
149154
match PublicKey::from_slice(get_slice!(33)) {

lightning-net-tokio/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ impl Connection {
141141
PeerDisconnected
142142
};
143143
let disconnect_type = loop {
144+
#[cfg_attr(rustfmt, rustfmt_skip)]
144145
macro_rules! shutdown_socket {
145146
($err: expr, $need_disconnect: expr) => { {
146147
println!("Disconnecting peer due to {}!", $err);
147148
break $need_disconnect;
148149
} }
149150
}
150151

152+
#[cfg_attr(rustfmt, rustfmt_skip)]
151153
macro_rules! prepare_read_write_call {
152154
() => { {
153155
let mut us_lock = us.lock().unwrap();

lightning/src/chain/keysinterface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ impl KeysInterface for KeysManager {
587587
sha.input(&b"commitment seed"[..]);
588588
Sha256::from_engine(sha).into_inner()
589589
};
590+
#[cfg_attr(rustfmt, rustfmt_skip)]
590591
macro_rules! key_step {
591592
($info: expr, $prev_key: expr) => {{
592593
let mut sha = Sha256::engine();

lightning/src/ln/chan_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ mod tests {
734734
let mut secrets: Vec<[u8; 32]> = Vec::new();
735735
let mut monitor;
736736

737+
#[cfg_attr(rustfmt, rustfmt_skip)]
737738
macro_rules! test_secrets {
738739
() => {
739740
let mut idx = 281474976710655;

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
234234
nodes[0].node.channel_monitor_updated(&outpoint, latest_update);
235235
check_added_monitors!(nodes[0], 0);
236236

237+
#[cfg_attr(rustfmt, rustfmt_skip)]
237238
macro_rules! disconnect_reconnect_peers { () => { {
238239
nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
239240
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
@@ -358,6 +359,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
358359
let as_commitment_update;
359360
let bs_second_commitment_update;
360361

362+
#[cfg_attr(rustfmt, rustfmt_skip)]
361363
macro_rules! handle_bs_raa { () => {
362364
nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack);
363365
as_commitment_update = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
@@ -369,6 +371,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
369371
check_added_monitors!(nodes[0], 1);
370372
} }
371373

374+
#[cfg_attr(rustfmt, rustfmt_skip)]
372375
macro_rules! handle_initial_raa { () => {
373376
nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), &initial_revoke_and_ack);
374377
bs_second_commitment_update = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());

lightning/src/ln/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ impl fmt::Debug for ChannelError {
405405
}
406406
}
407407

408+
#[cfg_attr(rustfmt, rustfmt_skip)]
408409
macro_rules! secp_check {
409410
($res: expr, $err: expr) => {
410411
match $res {
@@ -838,6 +839,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
838839

839840
log_trace!(self, "Building commitment transaction number {} (really {} xor {}) for {}, generated by {} with fee {}...", commitment_number, (INITIAL_COMMITMENT_NUMBER - commitment_number), self.get_commitment_transaction_number_obscure_factor(), if local { "us" } else { "remote" }, if generated_by_local { "us" } else { "remote" }, feerate_per_kw);
840841

842+
#[cfg_attr(rustfmt, rustfmt_skip)]
841843
macro_rules! get_htlc_in_commitment {
842844
($htlc: expr, $offered: expr) => {
843845
HTLCOutputInCommitment {
@@ -850,6 +852,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
850852
}
851853
}
852854

855+
#[cfg_attr(rustfmt, rustfmt_skip)]
853856
macro_rules! add_htlc_output {
854857
($htlc: expr, $outbound: expr, $source: expr, $state_name: expr) => {
855858
if $outbound == local { // "offered HTLC output"
@@ -2897,6 +2900,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
28972900
}
28982901
}
28992902

2903+
#[cfg_attr(rustfmt, rustfmt_skip)]
29002904
macro_rules! propose_new_feerate {
29012905
($new_feerate: expr) => {
29022906
let closing_tx_max_weight = Self::get_closing_transaction_weight(&self.get_closing_scriptpubkey(), self.their_shutdown_scriptpubkey.as_ref().unwrap());
@@ -4491,6 +4495,7 @@ mod tests {
44914495
let mut unsigned_tx: (Transaction, Vec<HTLCOutputInCommitment>);
44924496

44934497
let mut localtx;
4498+
#[cfg_attr(rustfmt, rustfmt_skip)]
44944499
macro_rules! test_commitment {
44954500
( $their_sig_hex: expr, $our_sig_hex: expr, $tx_hex: expr, {
44964501
$( { $htlc_idx: expr, $their_htlc_sig_hex: expr, $our_htlc_sig_hex: expr, $htlc_tx_hex: expr } ), *

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ pub enum PaymentSendFailure {
519519
PartialFailure(Vec<Result<(), APIError>>),
520520
}
521521

522+
#[cfg_attr(rustfmt, rustfmt_skip)]
522523
macro_rules! handle_error {
523524
($self: ident, $internal: expr, $their_node_id: expr) => {
524525
match $internal {
@@ -562,6 +563,7 @@ macro_rules! handle_error {
562563
}
563564
}
564565

566+
#[cfg_attr(rustfmt, rustfmt_skip)]
565567
macro_rules! break_chan_entry {
566568
($self: ident, $res: expr, $channel_state: expr, $entry: expr) => {
567569
match $res {
@@ -581,6 +583,7 @@ macro_rules! break_chan_entry {
581583
}
582584
}
583585

586+
#[cfg_attr(rustfmt, rustfmt_skip)]
584587
macro_rules! try_chan_entry {
585588
($self: ident, $res: expr, $channel_state: expr, $entry: expr) => {
586589
match $res {
@@ -619,6 +622,7 @@ macro_rules! try_chan_entry {
619622
}
620623
}
621624

625+
#[cfg_attr(rustfmt, rustfmt_skip)]
622626
macro_rules! handle_monitor_err {
623627
($self: ident, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa: expr, $resend_commitment: expr) => {
624628
handle_monitor_err!($self, $err, $channel_state, $entry, $action_type, $resend_raa, $resend_commitment, Vec::new(), Vec::new())
@@ -669,6 +673,7 @@ macro_rules! handle_monitor_err {
669673
}
670674
}
671675

676+
#[cfg_attr(rustfmt, rustfmt_skip)]
672677
macro_rules! return_monitor_err {
673678
($self: ident, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa: expr, $resend_commitment: expr) => {
674679
return handle_monitor_err!($self, $err, $channel_state, $entry, $action_type, $resend_raa, $resend_commitment);
@@ -679,6 +684,7 @@ macro_rules! return_monitor_err {
679684
}
680685

681686
// Does not break in case of TemporaryFailure!
687+
#[cfg_attr(rustfmt, rustfmt_skip)]
682688
macro_rules! maybe_break_monitor_err {
683689
($self: ident, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa: expr, $resend_commitment: expr) => {
684690
match (handle_monitor_err!($self, $err, $channel_state, $entry, $action_type, $resend_raa, $resend_commitment), $err) {
@@ -938,6 +944,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
938944
}
939945

940946
fn decode_update_add_htlc_onion(&self, msg: &msgs::UpdateAddHTLC) -> (PendingHTLCStatus, MutexGuard<ChannelHolder<ChanSigner>>) {
947+
#[cfg_attr(rustfmt, rustfmt_skip)]
941948
macro_rules! return_malformed_err {
942949
($msg: expr, $err_code: expr) => {
943950
{
@@ -981,6 +988,8 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
981988
}
982989

983990
let mut channel_state = None;
991+
992+
#[cfg_attr(rustfmt, rustfmt_skip)]
984993
macro_rules! return_err {
985994
($msg: expr, $err_code: expr, $data: expr) => {
986995
{
@@ -2161,6 +2170,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
21612170
}
21622171
htlc_failures.append(&mut pending_failures);
21632172

2173+
#[cfg_attr(rustfmt, rustfmt_skip)]
21642174
macro_rules! handle_cs { () => {
21652175
if let Some(update) = commitment_update {
21662176
pending_msg_events.push(events::MessageSendEvent::UpdateHTLCs {
@@ -2169,6 +2179,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
21692179
});
21702180
}
21712181
} }
2182+
#[cfg_attr(rustfmt, rustfmt_skip)]
21722183
macro_rules! handle_raa { () => {
21732184
if let Some(revoke_and_ack) = raa {
21742185
pending_msg_events.push(events::MessageSendEvent::SendRevokeAndACK {
@@ -2802,6 +2813,7 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
28022813
msg
28032814
});
28042815
}
2816+
#[cfg_attr(rustfmt, rustfmt_skip)]
28052817
macro_rules! send_raa { () => {
28062818
if let Some(msg) = revoke_and_ack {
28072819
channel_state.pending_msg_events.push(events::MessageSendEvent::SendRevokeAndACK {
@@ -2810,6 +2822,8 @@ impl<ChanSigner: ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref> ChannelMan
28102822
});
28112823
}
28122824
} }
2825+
2826+
#[cfg_attr(rustfmt, rustfmt_skip)]
28132827
macro_rules! send_cu { () => {
28142828
if let Some(updates) = commitment_update {
28152829
channel_state.pending_msg_events.push(events::MessageSendEvent::UpdateHTLCs {

0 commit comments

Comments
 (0)