Skip to content

Commit 594fda4

Browse files
committed
modernize rustfmt::skip syntax and run cargo fmt
1 parent 9f1af3b commit 594fda4

File tree

9 files changed

+56
-49
lines changed

9 files changed

+56
-49
lines changed

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
@@ -117,9 +117,9 @@ fn main() {
117117
}
118118

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

src/miniscript/decode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use crate::miniscript::ScriptContext;
3232
use crate::prelude::*;
3333
use crate::{bitcoin, hash256, Error, Miniscript, MiniscriptKey, ToPublicKey};
3434

35-
3635
/// Trait for parsing keys from byte slices
3736
pub trait ParseableKey: Sized + ToPublicKey + private::Sealed {
3837
/// Parse a key from slice

src/miniscript/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ mod private {
7777
phantom: PhantomData<Ctx>,
7878
}
7979
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
80-
8180
/// Add type information(Type and Extdata) to Miniscript based on
8281
/// `AstElem` fragment. Dependent on display and clone because of Error
8382
/// Display code of type_check.
@@ -109,7 +108,12 @@ mod private {
109108
ty: types::Type,
110109
ext: types::extra_props::ExtData,
111110
) -> Miniscript<Pk, Ctx> {
112-
Miniscript { node, ty, ext, phantom: PhantomData }
111+
Miniscript {
112+
node,
113+
ty,
114+
ext,
115+
phantom: PhantomData,
116+
}
113117
}
114118
}
115119
}
@@ -167,7 +171,6 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> fmt::Display for Miniscript<Pk, Ctx>
167171
}
168172

169173
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
170-
171174
/// Extracts the `AstElem` representing the root of the miniscript
172175
pub fn into_inner(self) -> Terminal<Pk, Ctx> {
173176
self.node
@@ -360,8 +363,8 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
360363
T: Translator<Pk, Q, FuncError>,
361364
{
362365
let inner = self.node.real_translate_pk(t)?;
363-
let ms = Miniscript::from_ast(inner)
364-
.expect("Translator should not change the type of the AST");
366+
let ms =
367+
Miniscript::from_ast(inner).expect("Translator should not change the type of the AST");
365368
Ok(ms)
366369
}
367370
}
@@ -503,12 +506,11 @@ mod tests {
503506
use sync::Arc;
504507

505508
use super::{Miniscript, ScriptContext, Segwitv0, Tap};
506-
use crate::miniscript::types;
507-
use crate::miniscript::Terminal;
509+
use crate::miniscript::{types, Terminal};
508510
use crate::policy::Liftable;
509-
use crate::{prelude::*, Error};
511+
use crate::prelude::*;
510512
use crate::test_utils::{StrKeyTranslator, StrXOnlyKeyTranslator};
511-
use crate::{hex_script, DummyKey, ExtParams, Satisfier, ToPublicKey, TranslatePk};
513+
use crate::{hex_script, DummyKey, Error, ExtParams, Satisfier, ToPublicKey, TranslatePk};
512514

513515
type Segwitv0Script = Miniscript<bitcoin::PublicKey, Segwitv0>;
514516
type Tapscript = Miniscript<bitcoin::secp256k1::XOnlyPublicKey, Tap>;
@@ -1143,7 +1145,8 @@ mod tests {
11431145

11441146
#[test]
11451147
fn test_script_parse_dos() {
1146-
let mut script = bitcoin::blockdata::script::Builder::new().push_opcode(bitcoin::blockdata::opcodes::OP_TRUE);
1148+
let mut script = bitcoin::blockdata::script::Builder::new()
1149+
.push_opcode(bitcoin::blockdata::opcodes::OP_TRUE);
11471150
for _ in 0..10000 {
11481151
script = script.push_opcode(bitcoin::blockdata::opcodes::all::OP_0NOTEQUAL);
11491152
}

src/miniscript/ms_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
}
8080

8181
#[test]
82-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
82+
#[rustfmt::skip]
8383
fn invalid_tests_from_alloy() {
8484
invalid_ms("or_b(or_i(0,sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))");
8585
invalid_ms("or_b(s:pk_h(A),after(500000001))");
@@ -5657,7 +5657,7 @@ mod tests {
56575657
invalid_ms("c:or_b(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),pk_k(A))");
56585658
}
56595659
#[test]
5660-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
5660+
#[rustfmt::skip]
56615661
fn mall_8f1e8_tests_from_alloy() {
56625662
ms_test("or_d(or_d(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(500000001))", "Bf");
56635663
ms_test("andor(sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc),or_d(multi(2,A,B,C),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),after(1))", "B");
@@ -9154,7 +9154,7 @@ mod tests {
91549154

91559155
}
91569156
#[test]
9157-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
9157+
#[rustfmt::skip]
91589158
fn main_tests_from_alloy() {
91599159
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");
91609160
ms_test("andor(multi(2,A,B,C),or_d(multi(2,D,E,F),sha256(926a54995ca48600920a19bf7bc502ca5f2f7d07e6f804c4f00ebf0325084dbc)),c:pk_h(G))", "Bdusem");
@@ -15055,7 +15055,7 @@ mod tests {
1505515055
}
1505615056

1505715057
#[test]
15058-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
15058+
#[rustfmt::skip]
1505915059
fn malleable_tests_from_alloy() {
1506015060
ms_test("and_v(v:after(500000001),or_d(j:multi(2,A,B,C),multi(2,D,E,F)))", "usB");
1506115061
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");
@@ -22085,8 +22085,8 @@ mod tests {
2208522085
}
2208622086

2208722087
#[test]
22088+
#[rustfmt::skip]
2208822089
fn conflict_tests_from_alloy() {
22089-
#[cfg_attr(feature="cargo-fmt", rustfmt_skip)]
2209022090
{
2209122091
ms_test("andor(multi(2,A,B,C),andor(multi(2,D,E,F),after(500000001),n:after(1)),0)","Bedsm");
2209222092
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
@@ -166,7 +166,7 @@ impl Property for ExtData {
166166
timelock_info: TimelockInfo::default(),
167167
exec_stack_elem_count_sat: Some(1),
168168
exec_stack_elem_count_dissat: None,
169-
tree_height : 0,
169+
tree_height: 0,
170170
}
171171
}
172172

@@ -182,7 +182,7 @@ impl Property for ExtData {
182182
timelock_info: TimelockInfo::default(),
183183
exec_stack_elem_count_sat: None,
184184
exec_stack_elem_count_dissat: Some(1),
185-
tree_height : 0,
185+
tree_height: 0,
186186
}
187187
}
188188

@@ -406,7 +406,7 @@ impl Property for ExtData {
406406
timelock_info: self.timelock_info,
407407
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
408408
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
409-
tree_height : self.tree_height + 1,
409+
tree_height: self.tree_height + 1,
410410
})
411411
}
412412

@@ -422,7 +422,7 @@ impl Property for ExtData {
422422
timelock_info: self.timelock_info,
423423
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
424424
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
425-
tree_height : self.tree_height + 1,
425+
tree_height: self.tree_height + 1,
426426
})
427427
}
428428

@@ -438,7 +438,7 @@ impl Property for ExtData {
438438
timelock_info: self.timelock_info,
439439
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
440440
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
441-
tree_height : self.tree_height + 1,
441+
tree_height: self.tree_height + 1,
442442
})
443443
}
444444

@@ -457,7 +457,7 @@ impl Property for ExtData {
457457
// Even all V types push something onto the stack and then remove them
458458
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
459459
exec_stack_elem_count_dissat: Some(1),
460-
tree_height : self.tree_height + 1,
460+
tree_height: self.tree_height + 1,
461461
})
462462
}
463463

@@ -474,7 +474,7 @@ impl Property for ExtData {
474474
timelock_info: self.timelock_info,
475475
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
476476
exec_stack_elem_count_dissat: None,
477-
tree_height : self.tree_height + 1,
477+
tree_height: self.tree_height + 1,
478478
})
479479
}
480480

@@ -490,7 +490,7 @@ impl Property for ExtData {
490490
timelock_info: self.timelock_info,
491491
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
492492
exec_stack_elem_count_dissat: Some(1),
493-
tree_height : self.tree_height + 1,
493+
tree_height: self.tree_height + 1,
494494
})
495495
}
496496

@@ -507,7 +507,7 @@ impl Property for ExtData {
507507
// Technically max(1, self.exec_stack_elem_count_sat), same rationale as cast_dupif
508508
exec_stack_elem_count_sat: self.exec_stack_elem_count_sat,
509509
exec_stack_elem_count_dissat: self.exec_stack_elem_count_dissat,
510-
tree_height : self.tree_height + 1,
510+
tree_height: self.tree_height + 1,
511511
})
512512
}
513513

@@ -548,7 +548,7 @@ impl Property for ExtData {
548548
l.exec_stack_elem_count_dissat,
549549
r.exec_stack_elem_count_dissat.map(|x| x + 1),
550550
),
551-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
551+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
552552
})
553553
}
554554

@@ -576,7 +576,7 @@ impl Property for ExtData {
576576
r.exec_stack_elem_count_sat,
577577
),
578578
exec_stack_elem_count_dissat: None,
579-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
579+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
580580
})
581581
}
582582

@@ -625,7 +625,7 @@ impl Property for ExtData {
625625
l.exec_stack_elem_count_dissat,
626626
r.exec_stack_elem_count_dissat.map(|x| x + 1),
627627
),
628-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
628+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
629629
})
630630
}
631631

@@ -663,7 +663,7 @@ impl Property for ExtData {
663663
l.exec_stack_elem_count_dissat,
664664
r.exec_stack_elem_count_dissat.map(|x| x + 1),
665665
),
666-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
666+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
667667
};
668668
Ok(res)
669669
}
@@ -695,7 +695,7 @@ impl Property for ExtData {
695695
opt_max(r.exec_stack_elem_count_sat, l.exec_stack_elem_count_dissat),
696696
),
697697
exec_stack_elem_count_dissat: None,
698-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
698+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
699699
})
700700
}
701701

@@ -743,7 +743,7 @@ impl Property for ExtData {
743743
l.exec_stack_elem_count_dissat,
744744
r.exec_stack_elem_count_dissat,
745745
),
746-
tree_height : cmp::max(l.tree_height, r.tree_height) + 1,
746+
tree_height: cmp::max(l.tree_height, r.tree_height) + 1,
747747
})
748748
}
749749

@@ -789,7 +789,7 @@ impl Property for ExtData {
789789
a.exec_stack_elem_count_dissat,
790790
c.exec_stack_elem_count_dissat,
791791
),
792-
tree_height : cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1,
792+
tree_height: cmp::max(a.tree_height, cmp::max(b.tree_height, c.tree_height)) + 1,
793793
})
794794
}
795795

@@ -915,7 +915,7 @@ impl Property for ExtData {
915915
timelock_info: TimelockInfo::combine_threshold(k, timelocks),
916916
exec_stack_elem_count_sat,
917917
exec_stack_elem_count_dissat,
918-
tree_height : max_child_height + 1,
918+
tree_height: max_child_height + 1,
919919
})
920920
}
921921

src/policy/compiler.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> AstElemExt<Pk, Ctx> {
506506
let ext = types::ExtData::type_check(&ast, |_| None)?;
507507
let comp_ext_data = CompilerExtData::type_check(&ast, lookup_ext)?;
508508
Ok(AstElemExt {
509-
ms: Arc::new(
510-
Miniscript::from_components_unchecked(ast, ty, ext)
511-
),
509+
ms: Arc::new(Miniscript::from_components_unchecked(ast, ty, ext)),
512510
comp_ext_data,
513511
})
514512
}
@@ -531,9 +529,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> AstElemExt<Pk, Ctx> {
531529
let ext = types::ExtData::type_check(&ast, |_| None)?;
532530
let comp_ext_data = CompilerExtData::type_check(&ast, lookup_ext)?;
533531
Ok(AstElemExt {
534-
ms: Arc::new(
535-
Miniscript::from_components_unchecked(ast, ty, ext)
536-
),
532+
ms: Arc::new(Miniscript::from_components_unchecked(ast, ty, ext)),
537533
comp_ext_data,
538534
})
539535
}
@@ -1002,9 +998,7 @@ where
1002998

1003999
let ast = Terminal::Thresh(k, sub_ast);
10041000
let ast_ext = AstElemExt {
1005-
ms: Arc::new(
1006-
Miniscript::from_ast(ast).map_err(|_| CompilerError::LimitsExceeded)?,
1007-
),
1001+
ms: Arc::new(Miniscript::from_ast(ast).map_err(|_| CompilerError::LimitsExceeded)?),
10081002
comp_ext_data: CompilerExtData::threshold(k, n, |i| Ok(sub_ext_data[i]))
10091003
.expect("threshold subs, which we just compiled, typeck"),
10101004
};

src/policy/concrete.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,9 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
675675
Policy::Threshold(_, ref subs) | Policy::And(ref subs) => {
676676
subs.iter().all(|sub| sub.real_for_each_key(&mut *pred))
677677
}
678-
Policy::Or(ref subs) => subs.iter().all(|(_, sub)| sub.real_for_each_key(&mut *pred)),
678+
Policy::Or(ref subs) => subs
679+
.iter()
680+
.all(|(_, sub)| sub.real_for_each_key(&mut *pred)),
679681
}
680682
}
681683

@@ -1350,15 +1352,19 @@ mod compiler_tests {
13501352

13511353
#[cfg(test)]
13521354
mod tests {
1353-
use super::*;
13541355
use std::str::FromStr;
13551356

1357+
use super::*;
1358+
13561359
#[test]
13571360
fn for_each_key() {
13581361
let liquid_pol = Policy::<String>::from_str(
13591362
"or(and(older(4096),thresh(2,pk(A),pk(B),pk(C))),thresh(11,pk(F1),pk(F2),pk(F3),pk(F4),pk(F5),pk(F6),pk(F7),pk(F8),pk(F9),pk(F10),pk(F11),pk(F12),pk(F13),pk(F14)))").unwrap();
13601363
let mut count = 0;
1361-
assert!(liquid_pol.for_each_key(|_| { count +=1; true }));
1364+
assert!(liquid_pol.for_each_key(|_| {
1365+
count += 1;
1366+
true
1367+
}));
13621368
assert_eq!(count, 17);
13631369
}
13641370
}

src/policy/semantic.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
9191
| Policy::Hash160(..)
9292
| Policy::After(..)
9393
| Policy::Older(..) => true,
94-
Policy::Threshold(_, ref subs) => subs.iter().all(|sub| sub.real_for_each_key(&mut *pred)),
94+
Policy::Threshold(_, ref subs) => {
95+
subs.iter().all(|sub| sub.real_for_each_key(&mut *pred))
96+
}
9597
}
9698
}
9799

@@ -1004,7 +1006,10 @@ mod tests {
10041006
let liquid_pol = StringPolicy::from_str(
10051007
"or(and(older(4096),thresh(2,pk(A),pk(B),pk(C))),thresh(11,pk(F1),pk(F2),pk(F3),pk(F4),pk(F5),pk(F6),pk(F7),pk(F8),pk(F9),pk(F10),pk(F11),pk(F12),pk(F13),pk(F14)))").unwrap();
10061008
let mut count = 0;
1007-
assert!(liquid_pol.for_each_key(|_| { count +=1; true }));
1009+
assert!(liquid_pol.for_each_key(|_| {
1010+
count += 1;
1011+
true
1012+
}));
10081013
assert_eq!(count, 17);
10091014
}
10101015
}

0 commit comments

Comments
 (0)