From 5be4534eaf66736af679ccd0baa3026181f17bac Mon Sep 17 00:00:00 2001 From: Jacinta Ferrant Date: Tue, 3 Oct 2023 15:11:40 -0700 Subject: [PATCH] CRC: revert needless return changes for clarity Signed-off-by: Jacinta Ferrant --- pox-locking/src/pox_1.rs | 17 +++++++++------- pox-locking/src/pox_2.rs | 43 ++++++++++++++++++++++++---------------- pox-locking/src/pox_3.rs | 43 ++++++++++++++++++++++++---------------- 3 files changed, 62 insertions(+), 41 deletions(-) diff --git a/pox-locking/src/pox_1.rs b/pox-locking/src/pox_1.rs index a737c8547..95e44809d 100644 --- a/pox-locking/src/pox_1.rs +++ b/pox-locking/src/pox_1.rs @@ -119,6 +119,7 @@ pub fn pox_lock_v1( } /// Handle special cases when calling into the PoX v1 contract +#[allow(clippy::needless_return)] pub fn handle_contract_call( global_context: &mut GlobalContext, _sender_opt: Option<&PrincipalData>, @@ -171,18 +172,20 @@ pub fn handle_contract_call( }), )); } - Ok(()) + return Ok(()); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(LockingError::PoxAlreadyLocked) => { // the caller tried to lock tokens into both pox-1 and pox-2 - Err(ClarityError::Runtime( + return Err(ClarityError::Runtime( RuntimeErrorType::PoxAlreadyLocked, None, - )) + )); } Err(e) => { panic!( diff --git a/pox-locking/src/pox_2.rs b/pox-locking/src/pox_2.rs index a7b7e78d4..34c2f3a95 100644 --- a/pox-locking/src/pox_2.rs +++ b/pox-locking/src/pox_2.rs @@ -272,6 +272,7 @@ fn pox_lock_v2( } /// Handle responses from stack-stx and delegate-stack-stx -- functions that *lock up* STX +#[allow(clippy::needless_return)] fn handle_stack_lockup_pox_v2( global_context: &mut GlobalContext, function_name: &str, @@ -310,18 +311,20 @@ fn handle_stack_lockup_pox_v2( locked_address: stacker, contract_identifier: boot_code_id("pox-2", global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(LockingError::PoxAlreadyLocked) => { // the caller tried to lock tokens into both pox-1 and pox-2 - Err(ClarityError::Runtime( + return Err(ClarityError::Runtime( RuntimeErrorType::PoxAlreadyLocked, None, - )) + )); } Err(e) => { panic!( @@ -334,6 +337,7 @@ fn handle_stack_lockup_pox_v2( /// Handle responses from stack-extend and delegate-stack-extend -- functions that *extend /// already-locked* STX. +#[allow(clippy::needless_return)] fn handle_stack_lockup_extension_pox_v2( global_context: &mut GlobalContext, function_name: &str, @@ -375,12 +379,14 @@ fn handle_stack_lockup_extension_pox_v2( locked_address: stacker, contract_identifier: boot_code_id("pox-2", global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(e) => { // Error results *other* than a DefunctPoxContract panic, because // those errors should have been caught by the PoX contract before @@ -395,6 +401,7 @@ fn handle_stack_lockup_extension_pox_v2( /// Handle responses from stack-increase and delegate-stack-increase -- functions that *increase /// already-locked* STX amounts. +#[allow(clippy::needless_return)] fn handle_stack_lockup_increase_pox_v2( global_context: &mut GlobalContext, function_name: &str, @@ -435,12 +442,14 @@ fn handle_stack_lockup_increase_pox_v2( contract_identifier: boot_code_id("pox-2", global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(e) => { // Error results *other* than a DefunctPoxContract panic, because // those errors should have been caught by the PoX contract before diff --git a/pox-locking/src/pox_3.rs b/pox-locking/src/pox_3.rs index 97b8f31c3..cccfbb264 100644 --- a/pox-locking/src/pox_3.rs +++ b/pox-locking/src/pox_3.rs @@ -153,6 +153,7 @@ pub fn pox_lock_increase_v3( /////////////// PoX-3 ////////////////////////////////////////// /// Handle responses from stack-stx and delegate-stack-stx in pox-3 -- functions that *lock up* STX +#[allow(clippy::needless_return)] fn handle_stack_lockup_pox_v3( global_context: &mut GlobalContext, function_name: &str, @@ -193,18 +194,20 @@ fn handle_stack_lockup_pox_v3( locked_address: stacker, contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(LockingError::PoxAlreadyLocked) => { // the caller tried to lock tokens into multiple pox contracts - Err(ClarityError::Runtime( + return Err(ClarityError::Runtime( RuntimeErrorType::PoxAlreadyLocked, None, - )) + )); } Err(e) => { panic!( @@ -217,6 +220,7 @@ fn handle_stack_lockup_pox_v3( /// Handle responses from stack-extend and delegate-stack-extend in pox-3 -- functions that *extend /// already-locked* STX. +#[allow(clippy::needless_return)] fn handle_stack_lockup_extension_pox_v3( global_context: &mut GlobalContext, function_name: &str, @@ -258,12 +262,14 @@ fn handle_stack_lockup_extension_pox_v3( locked_address: stacker, contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(e) => { // Error results *other* than a DefunctPoxContract panic, because // those errors should have been caught by the PoX contract before @@ -278,6 +284,7 @@ fn handle_stack_lockup_extension_pox_v3( /// Handle responses from stack-increase and delegate-stack-increase in PoX-3 -- functions /// that *increase already-locked* STX amounts. +#[allow(clippy::needless_return)] fn handle_stack_lockup_increase_pox_v3( global_context: &mut GlobalContext, function_name: &str, @@ -317,12 +324,14 @@ fn handle_stack_lockup_increase_pox_v3( contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet), })); - Ok(Some(event)) + return Ok(Some(event)); + } + Err(LockingError::DefunctPoxContract) => { + return Err(ClarityError::Runtime( + RuntimeErrorType::DefunctPoxContract, + None, + )); } - Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime( - RuntimeErrorType::DefunctPoxContract, - None, - )), Err(e) => { // Error results *other* than a DefunctPoxContract panic, because // those errors should have been caught by the PoX contract before