Skip to content

Commit 098d6dc

Browse files
committed
modernize rustfmt::skip syntax and run cargo fmt
Weird that this only has an effect on a couple files, which aren't checked in the Github CI. Same story with 12.x.
1 parent ba3df7e commit 098d6dc

File tree

8 files changed

+40
-36
lines changed

8 files changed

+40
-36
lines changed

contrib/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rustc --version
1111
if [ "$DO_FMT" = true ]
1212
then
1313
rustup component add rustfmt
14-
cargo fmt -- --check
14+
cargo fmt --check
1515
fi
1616

1717
cp Cargo-recent.lock Cargo.lock

examples/sign_multisig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ fn spending_transaction() -> bitcoin::Transaction {
105105
}
106106
}
107107

108+
#[rustfmt::skip]
108109
fn list_of_three_arbitrary_public_keys() -> Vec<bitcoin::PublicKey> {
109-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
110110
vec![
111111
bitcoin::PublicKey::from_slice(&[2; 33]).expect("key 1"),
112112
bitcoin::PublicKey::from_slice(&[

examples/verify_tx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ fn main() {
116116
}
117117

118118
/// Returns an arbitrary transaction.
119+
#[rustfmt::skip]
119120
fn hard_coded_transaction() -> bitcoin::Transaction {
120121
// tx `f27eba163c38ad3f34971198687a3f1882b7ec818599ffe469a8440d82261c98`
121-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
122122
let tx_bytes = vec![
123123
0x01, 0x00, 0x00, 0x00, 0x02, 0xc5, 0x11, 0x1d, 0xb7, 0x93, 0x50, 0xc1,
124124
0x70, 0x28, 0x41, 0x39, 0xe8, 0xe3, 0x4e, 0xb0, 0xed, 0xba, 0x64, 0x7b,

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,10 @@ impl<E> TranslateErr<E> {
394394
match self {
395395
Self::TranslatorErr(v) => v,
396396
Self::OuterError(ref e) => {
397-
panic!("Unexpected Miniscript error when translating: {}\nMessage: {}", e, msg)
397+
panic!(
398+
"Unexpected Miniscript error when translating: {}\nMessage: {}",
399+
e, msg
400+
)
398401
}
399402
}
400403
}

src/miniscript/decode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ use sync::Arc;
1818
use crate::miniscript::lex::{Token as Tk, TokenIter};
1919
use crate::miniscript::limits::MAX_PUBKEYS_PER_MULTISIG;
2020
use crate::miniscript::ScriptContext;
21-
use crate::{prelude::*, Miniscript};
21+
use crate::prelude::*;
2222
#[cfg(doc)]
2323
use crate::Descriptor;
24-
use crate::{bitcoin, hash256, AbsLockTime, Error, MiniscriptKey, ToPublicKey};
25-
24+
use crate::{bitcoin, hash256, AbsLockTime, Error, Miniscript, MiniscriptKey, ToPublicKey};
2625

2726
/// Trait for parsing keys from byte slices
2827
pub trait ParseableKey: Sized + ToPublicKey + private::Sealed {

src/miniscript/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ mod private {
6666
phantom: PhantomData<Ctx>,
6767
}
6868
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
69-
7069
/// Add type information(Type and Extdata) to Miniscript based on
7170
/// `AstElem` fragment. Dependent on display and clone because of Error
7271
/// Display code of type_check.
@@ -98,7 +97,12 @@ mod private {
9897
ty: types::Type,
9998
ext: types::extra_props::ExtData,
10099
) -> Miniscript<Pk, Ctx> {
101-
Miniscript { node, ty, ext, phantom: PhantomData }
100+
Miniscript {
101+
node,
102+
ty,
103+
ext,
104+
phantom: PhantomData,
105+
}
102106
}
103107
}
104108
}
@@ -156,7 +160,6 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> fmt::Display for Miniscript<Pk, Ctx>
156160
}
157161

158162
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
159-
160163
/// Extracts the `AstElem` representing the root of the miniscript
161164
pub fn into_inner(self) -> Terminal<Pk, Ctx> {
162165
self.node
@@ -495,12 +498,11 @@ mod tests {
495498
use sync::Arc;
496499

497500
use super::{Miniscript, ScriptContext, Segwitv0, Tap};
498-
use crate::miniscript::types;
499-
use crate::miniscript::Terminal;
501+
use crate::miniscript::{types, Terminal};
500502
use crate::policy::Liftable;
501-
use crate::{prelude::*, Error};
503+
use crate::prelude::*;
502504
use crate::test_utils::{StrKeyTranslator, StrXOnlyKeyTranslator};
503-
use crate::{hex_script, ExtParams, Satisfier, ToPublicKey, TranslatePk};
505+
use crate::{hex_script, Error, ExtParams, Satisfier, ToPublicKey, TranslatePk};
504506

505507
type Segwitv0Script = Miniscript<bitcoin::PublicKey, Segwitv0>;
506508
type Tapscript = Miniscript<bitcoin::secp256k1::XOnlyPublicKey, Tap>;

src/miniscript/ms_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mod tests {
6868
}
6969

7070
#[test]
71-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
71+
#[rustfmt::skip]
7272
fn invalid_tests_from_alloy() {
7373
invalid_ms("or_b(or_i(0,sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))");
7474
invalid_ms("or_b(s:pk_h(A),after(500000001))");
@@ -5646,7 +5646,7 @@ mod tests {
56465646
invalid_ms("c:or_b(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),pk_k(A))");
56475647
}
56485648
#[test]
5649-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
5649+
#[rustfmt::skip]
56505650
fn mall_8f1e8_tests_from_alloy() {
56515651
ms_test("or_d(or_d(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(500000001))", "Bf");
56525652
ms_test("andor(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),or_d(multi(2,A,B,C),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))", "B");
@@ -9143,7 +9143,7 @@ mod tests {
91439143

91449144
}
91459145
#[test]
9146-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
9146+
#[rustfmt::skip]
91479147
fn main_tests_from_alloy() {
91489148
ms_test("or_d(or_d(multi(2,A,B,C),or_d(multi(2,D,E,F),multi(2,G,I,J))),multi(2,K,L,M))", "Bdusem");
91499149
ms_test("andor(multi(2,A,B,C),or_d(multi(2,D,E,F),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),c:pk_h(G))", "Bdusem");
@@ -15044,7 +15044,7 @@ mod tests {
1504415044
}
1504515045

1504615046
#[test]
15047-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
15047+
#[rustfmt::skip]
1504815048
fn malleable_tests_from_alloy() {
1504915049
ms_test("and_v(v:after(500000001),or_d(j:multi(2,A,B,C),multi(2,D,E,F)))", "usB");
1505015050
ms_test("or_b(j:multi(2,A,B,C),a:andor(multi(2,D,E,F),multi(2,G,I,J),multi(2,K,L,M)))", "dBesu");
@@ -22076,8 +22076,8 @@ mod tests {
2207622076
// This does not actually test timelock mixing. See: https://github.com/rust-bitcoin/rust-miniscript/issues/514
2207722077
// for details
2207822078
#[test]
22079+
#[rustfmt::skip]
2207922080
fn conflict_tests_from_alloy() {
22080-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
2208122081
{
2208222082
ms_test("andor(multi(2,A,B,C),andor(multi(2,D,E,F),after(500000001),n:after(1)),0)","Bedsm");
2208322083
ms_test("and_v(v:after(500000001),or_d(multi(2,A,B,C),and_b(multi(2,D,E,F),a:after(1))))","Busm");

src/miniscript/types/extra_props.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Property for ExtData {
168168
timelock_info: TimelockInfo::default(),
169169
exec_stack_elem_count_sat: Some(1),
170170
exec_stack_elem_count_dissat: None,
171-
tree_height : 0,
171+
tree_height: 0,
172172
}
173173
}
174174

@@ -184,7 +184,7 @@ impl Property for ExtData {
184184
timelock_info: TimelockInfo::default(),
185185
exec_stack_elem_count_sat: None,
186186
exec_stack_elem_count_dissat: Some(1),
187-
tree_height : 0,
187+
tree_height: 0,
188188
}
189189
}
190190

@@ -408,7 +408,7 @@ impl Property for ExtData {
408408
timelock_info: self.timelock_info,
409409
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
410410
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
411-
tree_height : self.tree_height + 1,
411+
tree_height: self.tree_height + 1,
412412
})
413413
}
414414

@@ -424,7 +424,7 @@ impl Property for ExtData {
424424
timelock_info: self.timelock_info,
425425
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
426426
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
427-
tree_height : self.tree_height + 1,
427+
tree_height: self.tree_height + 1,
428428
})
429429
}
430430

@@ -440,7 +440,7 @@ impl Property for ExtData {
440440
timelock_info: self.timelock_info,
441441
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
442442
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
443-
tree_height : self.tree_height + 1,
443+
tree_height: self.tree_height + 1,
444444
})
445445
}
446446

@@ -459,7 +459,7 @@ impl Property for ExtData {
459459
// Even all V types push something onto the stack and then remove them
460460
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
461461
exec_stack_elem_count_dissat: Some(1),
462-
tree_height : self.tree_height + 1,
462+
tree_height: self.tree_height + 1,
463463
})
464464
}
465465

@@ -476,7 +476,7 @@ impl Property for ExtData {
476476
timelock_info: self.timelock_info,
477477
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
478478
exec_stack_elem_count_dissat: None,
479-
tree_height : self.tree_height + 1,
479+
tree_height: self.tree_height + 1,
480480
})
481481
}
482482

@@ -492,7 +492,7 @@ impl Property for ExtData {
492492
timelock_info: self.timelock_info,
493493
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
494494
exec_stack_elem_count_dissat: Some(1),
495-
tree_height : self.tree_height + 1,
495+
tree_height: self.tree_height + 1,
496496
})
497497
}
498498

@@ -509,7 +509,7 @@ impl Property for ExtData {
509509
// Technically max(1, self.exec_stack_elem_count_sat), same rationale as cast_dupif
510510
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
511511
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
512-
tree_height : self.tree_height + 1,
512+
tree_height: self.tree_height + 1,
513513
})
514514
}
515515

@@ -550,7 +550,7 @@ impl Property for ExtData {
550550
l.exec_stack_elem_count_dissat,
551551
r.exec_stack_elem_count_dissat.map(|x| x + 1),
552552
),
553-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
553+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
554554
})
555555
}
556556

@@ -578,7 +578,7 @@ impl Property for ExtData {
578578
r.exec_stack_elem_count_sat,
579579
),
580580
exec_stack_elem_count_dissat: None,
581-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
581+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
582582
})
583583
}
584584

@@ -627,7 +627,7 @@ impl Property for ExtData {
627627
l.exec_stack_elem_count_dissat,
628628
r.exec_stack_elem_count_dissat.map(|x| x + 1),
629629
),
630-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
630+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
631631
})
632632
}
633633

@@ -665,7 +665,7 @@ impl Property for ExtData {
665665
l.exec_stack_elem_count_dissat,
666666
r.exec_stack_elem_count_dissat.map(|x| x + 1),
667667
),
668-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
668+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
669669
};
670670
Ok(res)
671671
}
@@ -697,7 +697,7 @@ impl Property for ExtData {
697697
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
698698
),
699699
exec_stack_elem_count_dissat: None,
700-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
700+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
701701
})
702702
}
703703

@@ -744,7 +744,7 @@ impl Property for ExtData {
744744
l.exec_stack_elem_count_dissat,
745745
r.exec_stack_elem_count_dissat,
746746
),
747-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
747+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
748748
})
749749
}
750750

@@ -790,7 +790,7 @@ impl Property for ExtData {
790790
a.exec_stack_elem_count_dissat,
791791
c.exec_stack_elem_count_dissat,
792792
),
793-
tree_height : cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1,
793+
tree_height: cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1,
794794
})
795795
}
796796

@@ -916,7 +916,7 @@ impl Property for ExtData {
916916
timelock_info: TimelockInfo::combine_threshold(k, timelocks),
917917
exec_stack_elem_count_sat,
918918
exec_stack_elem_count_dissat,
919-
tree_height : max_child_height + 1,
919+
tree_height: max_child_height + 1,
920920
})
921921
}
922922

0 commit comments

Comments
 (0)