Skip to content

Commit a314993

Browse files
committed
clippy: fix unnested_or_patterns pattern
Neat! I didn't know about this syntax. Simplifies a lot of opcode matching.
1 parent c009837 commit a314993

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/opcodes.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -792,16 +792,13 @@ impl All {
792792
use self::all::*;
793793
match (self, ctx) {
794794
// 3 opcodes illegal in all contexts
795-
(OP_VERIF, _) | (OP_VERNOTIF, _) | (OP_INVALIDOPCODE, _) => Class::IllegalOp,
795+
(OP_VERIF | OP_VERNOTIF | OP_INVALIDOPCODE, _) => Class::IllegalOp,
796796

797797
// 15 opcodes illegal in Legacy context
798-
(OP_CAT, ctx) | (OP_SUBSTR, ctx)
799-
| (OP_LEFT, ctx) | (OP_RIGHT, ctx)
800-
| (OP_INVERT, ctx)
801-
| (OP_AND, ctx) | (OP_OR, ctx) | (OP_XOR, ctx)
802-
| (OP_2MUL, ctx) | (OP_2DIV, ctx)
803-
| (OP_MUL, ctx) | (OP_DIV, ctx) | (OP_MOD, ctx)
804-
| (OP_LSHIFT, ctx) | (OP_RSHIFT, ctx) if ctx == ClassifyContext::Legacy => Class::IllegalOp,
798+
(OP_CAT | OP_SUBSTR | OP_LEFT | OP_RIGHT
799+
| OP_INVERT | OP_AND | OP_OR | OP_XOR
800+
| OP_2MUL | OP_2DIV | OP_MUL | OP_DIV
801+
| OP_MOD | OP_LSHIFT | OP_RSHIFT, ClassifyContext::Legacy) => Class::IllegalOp,
805802

806803
// 87 opcodes of SuccessOp class only in TapScript context
807804
(op, ClassifyContext::TapScript)
@@ -820,16 +817,13 @@ impl All {
820817
(OP_RETURN, _) => Class::ReturnOp,
821818

822819
// 4 opcodes operating equally to `OP_RETURN` only in Legacy context
823-
(OP_RESERVED, ctx)
824-
| (OP_RESERVED1, ctx) | (OP_RESERVED2, ctx)
825-
| (OP_VER, ctx) if ctx == ClassifyContext::Legacy => Class::ReturnOp,
820+
(OP_RESERVED | OP_RESERVED1 | OP_RESERVED2 | OP_VER, ClassifyContext::Legacy) => Class::ReturnOp,
826821

827822
// 71 opcodes operating equally to `OP_RETURN` only in Legacy context
828823
(op, ClassifyContext::Legacy) if op.code >= OP_CHECKSIGADD.code => Class::ReturnOp,
829824

830825
// 2 opcodes operating equally to `OP_RETURN` only in TapScript context
831-
(OP_CHECKMULTISIG, ClassifyContext::TapScript)
832-
| (OP_CHECKMULTISIGVERIFY, ClassifyContext::TapScript) => Class::ReturnOp,
826+
(OP_CHECKMULTISIG | OP_CHECKMULTISIGVERIFY, ClassifyContext::TapScript) => Class::ReturnOp,
833827

834828
// 1 opcode of PushNum class
835829
(OP_PUSHNUM_NEG1, _) => Class::PushNum(-1),

0 commit comments

Comments
 (0)