Skip to content

Commit b809ab5

Browse files
committed
Merge #501: Remove unreachable statement
fb4c33b Use if let and panic (Tobin C. Harding) Pull request description: Use if let and panic Clippy emits: ``` warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` ``` The code in question is functionally asserting that the `witness` argument does not contain variant `Threshold`, the same can be achieved using an `if let` and a `panic`. ACKs for top commit: apoelstra: ACK fb4c33b Tree-SHA512: 8fc07b7ee7eb7eb47fe13f37f7f39a440eefc9620f8e573d5de535bf90dd5e9f6bb4f404698d2290fe4eafa8be8476a51208fe068df752892b36bf1e55acd09f
2 parents 4e5a386 + fb4c33b commit b809ab5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/policy/semantic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
223223
// a normalized policy
224224
pub(crate) fn satisfy_constraint(self, witness: &Policy<Pk>, available: bool) -> Policy<Pk> {
225225
debug_assert!(self.clone().normalized() == self);
226-
match *witness {
227-
// only for internal purposes, safe to use unreachable!
228-
Policy::Threshold(..) => unreachable!(),
229-
_ => {}
230-
};
226+
if let Policy::Threshold { .. } = *witness {
227+
// We can't debug_assert on Policy::Threshold.
228+
panic!("should be unreachable")
229+
}
230+
231231
let ret = match self {
232232
Policy::Threshold(k, subs) => {
233233
let mut ret_subs = vec![];

0 commit comments

Comments
 (0)