Skip to content

Commit 81d5ae6

Browse files
committed
Remove explicit return statement
Clippy emits a bunch of warnings of the form: warning: unneeded `return` statement As suggested, remove the explicit return statement.
1 parent 03c6587 commit 81d5ae6

File tree

9 files changed

+27
-48
lines changed

9 files changed

+27
-48
lines changed

src/descriptor/tr.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,10 @@ where
360360
let right = parse_tr_script_spend(&args[1])?;
361361
Ok(TapTree::Tree(Arc::new(left), Arc::new(right)))
362362
}
363-
_ => {
364-
return Err(Error::Unexpected(
365-
"unknown format for script spending paths while parsing taproot descriptor"
366-
.to_string(),
367-
));
368-
}
363+
_ => Err(Error::Unexpected(
364+
"unknown format for script spending paths while parsing taproot descriptor"
365+
.to_string(),
366+
)),
369367
}
370368
}
371369

@@ -460,7 +458,7 @@ fn parse_tr_tree(s: &str) -> Result<expression::Tree, Error> {
460458
}
461459
}
462460

463-
let ret = if s.len() > 3 && &s[..3] == "tr(" && s.as_bytes()[s.len() - 1] == b')' {
461+
if s.len() > 3 && &s[..3] == "tr(" && s.as_bytes()[s.len() - 1] == b')' {
464462
let rest = &s[3..s.len() - 1];
465463
if !rest.contains(',') {
466464
let internal_key = expression::Tree {
@@ -497,12 +495,11 @@ fn parse_tr_tree(s: &str) -> Result<expression::Tree, Error> {
497495
}
498496
} else {
499497
Err(Error::Unexpected("invalid taproot descriptor".to_string()))
500-
};
501-
return ret;
498+
}
502499
}
503500

504501
fn split_once(inp: &str, delim: char) -> Option<(&str, &str)> {
505-
let ret = if inp.is_empty() {
502+
if inp.is_empty() {
506503
None
507504
} else {
508505
let mut found = inp.len();
@@ -518,8 +515,7 @@ fn split_once(inp: &str, delim: char) -> Option<(&str, &str)> {
518515
} else {
519516
Some((&inp[..found], &inp[found + 1..]))
520517
}
521-
};
522-
return ret;
518+
}
523519
}
524520

525521
impl<Pk: MiniscriptKey> Liftable<Pk> for TapTree<Pk> {

src/interpreter/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub(super) fn from_txdata<'txin>(
255255
Some(tap_script),
256256
))
257257
} else {
258-
return Err(Error::ControlBlockVerificationError);
258+
Err(Error::ControlBlockVerificationError)
259259
}
260260
}
261261
}

src/interpreter/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -980,20 +980,20 @@ where
980980
//terminate the next() function in the subsequent call
981981
self.public_key = None;
982982
self.stack.push(stack::Element::Satisfied);
983-
return Some(Ok(SatisfiedConstraint::PublicKey { key_sig }));
983+
Some(Ok(SatisfiedConstraint::PublicKey { key_sig }))
984984
} else {
985-
return Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(*pk))));
985+
Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(*pk))))
986986
}
987987
} else {
988-
return Some(Err(Error::UnexpectedStackEnd));
988+
Some(Err(Error::UnexpectedStackEnd))
989989
}
990990
} else {
991991
//All the script has been executed.
992992
//Check that the stack must contain exactly 1 satisfied element
993993
if self.stack.pop() == Some(stack::Element::Satisfied) && self.stack.is_empty() {
994-
return None;
994+
None
995995
} else {
996-
return Some(Err(Error::ScriptSatisfactionError));
996+
Some(Err(Error::ScriptSatisfactionError))
997997
}
998998
}
999999
}

src/interpreter/stack.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ impl<'txin> Stack<'txin> {
154154
self.push(Element::Satisfied);
155155
Some(Ok(SatisfiedConstraint::PublicKey { key_sig }))
156156
}
157-
Err(e) => return Some(Err(e)),
157+
Err(e) => Some(Err(e)),
158158
}
159159
}
160160
Element::Satisfied => {
161-
return Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(*pk))));
161+
Some(Err(Error::PkEvaluationError(PkEvalErrInner::from(*pk))))
162162
}
163163
}
164164
} else {
@@ -212,12 +212,10 @@ impl<'txin> Stack<'txin> {
212212
key_sig,
213213
}))
214214
}
215-
Err(e) => return Some(Err(e)),
215+
Err(e) => Some(Err(e)),
216216
}
217217
}
218-
Element::Satisfied => {
219-
return Some(Err(Error::PkEvaluationError(pk.into())))
220-
}
218+
Element::Satisfied => Some(Err(Error::PkEvaluationError(pk.into()))),
221219
}
222220
} else {
223221
Some(Err(Error::UnexpectedStackEnd))
@@ -383,10 +381,10 @@ impl<'txin> Stack<'txin> {
383381
if let Element::Push(sigser) = witness_sig {
384382
let key_sig = verify_sersig(verify_sig, pk, sigser);
385383
match key_sig {
386-
Ok(key_sig) => return Some(Ok(SatisfiedConstraint::PublicKey { key_sig })),
384+
Ok(key_sig) => Some(Ok(SatisfiedConstraint::PublicKey { key_sig })),
387385
Err(..) => {
388386
self.push(witness_sig);
389-
return None;
387+
None
390388
}
391389
}
392390
} else {

src/miniscript/context.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,7 @@ impl ScriptContext for Segwitv0 {
484484
}
485485
Ok(())
486486
}
487-
Terminal::MultiA(..) => {
488-
return Err(ScriptContextError::MultiANotAllowed);
489-
}
487+
Terminal::MultiA(..) => Err(ScriptContextError::MultiANotAllowed),
490488
_ => Ok(()),
491489
}
492490
}
@@ -593,9 +591,7 @@ impl ScriptContext for Tap {
593591
}
594592
Ok(())
595593
}
596-
Terminal::Multi(..) => {
597-
return Err(ScriptContextError::TaprootMultiDisabled);
598-
}
594+
Terminal::Multi(..) => Err(ScriptContextError::TaprootMultiDisabled),
599595
_ => Ok(()),
600596
}
601597
}
@@ -703,7 +699,7 @@ impl ScriptContext for BareCtx {
703699
}
704700
Ok(())
705701
}
706-
Terminal::MultiA(..) => return Err(ScriptContextError::MultiANotAllowed),
702+
Terminal::MultiA(..) => Err(ScriptContextError::MultiANotAllowed),
707703
_ => Ok(()),
708704
}
709705
}

src/miniscript/types/correctness.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,10 @@ impl Correctness {
9999
/// in the given `Type`. This returns `true` on same arguments
100100
/// `a.is_subtype(a)` is `true`.
101101
pub fn is_subtype(&self, other: Self) -> bool {
102-
if self.base == other.base
102+
self.base == other.base
103103
&& self.input.is_subtype(other.input)
104104
&& self.dissatisfiable >= other.dissatisfiable
105105
&& self.unit >= other.unit
106-
{
107-
return true;
108-
}
109-
return false;
110106
}
111107
}
112108

src/miniscript/types/malleability.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@ impl Malleability {
7171
/// in the given `Type`. This returns `true` on same arguments
7272
/// `a.is_subtype(a)` is `true`.
7373
pub fn is_subtype(&self, other: Self) -> bool {
74-
if self.dissat.is_subtype(other.dissat)
74+
self.dissat.is_subtype(other.dissat)
7575
&& self.safe >= other.safe
7676
&& self.non_malleable >= other.non_malleable
77-
{
78-
return true;
79-
}
80-
return false;
8177
}
8278
}
8379

src/miniscript/types/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ impl Type {
239239
/// in the given `Type`. This returns `true` on same arguments
240240
/// `a.is_subtype(a)` is `true`.
241241
pub fn is_subtype(&self, other: Self) -> bool {
242-
if self.corr.is_subtype(other.corr) && self.mall.is_subtype(other.mall) {
243-
return true;
244-
}
245-
return false;
242+
self.corr.is_subtype(other.corr) && self.mall.is_subtype(other.mall)
246243
}
247244
}
248245
/// Trait representing a type property, which defines how the property

src/psbt/finalizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn get_descriptor(psbt: &Psbt, index: usize) -> Result<Descriptor<PublicKey>, In
202202
}
203203
} else if script_pubkey.is_p2sh() {
204204
match &inp.redeem_script {
205-
&None => return Err(InputError::MissingRedeemScript),
205+
&None => Err(InputError::MissingRedeemScript),
206206
&Some(ref redeem_script) => {
207207
if redeem_script.to_p2sh() != *script_pubkey {
208208
return Err(InputError::InvalidRedeemScript {

0 commit comments

Comments
 (0)