Skip to content

Commit

Permalink
Merge pull request #5678 from stacks-network/clippy/warn-asbytes
Browse files Browse the repository at this point in the history
chore: add allow(clippy::needless_as_bytes) for some Clarity codecs
  • Loading branch information
kantai authored Jan 14, 2025
2 parents aab9162 + 5b96659 commit 11823df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions clarity/src/vm/representations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ guarded_string!(
);

impl StacksMessageCodec for ClarityName {
#[allow(clippy::needless_as_bytes)] // as_bytes isn't necessary, but verbosity is preferable in the codec impls
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), codec_error> {
// ClarityName can't be longer than vm::representations::MAX_STRING_LEN, which itself is
// a u8, so we should be good here.
Expand Down Expand Up @@ -124,6 +125,7 @@ impl StacksMessageCodec for ClarityName {
}

impl StacksMessageCodec for ContractName {
#[allow(clippy::needless_as_bytes)] // as_bytes isn't necessary, but verbosity is preferable in the codec impls
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), codec_error> {
if self.as_bytes().len() < CONTRACT_MIN_NAME_LENGTH
|| self.as_bytes().len() > CONTRACT_MAX_NAME_LENGTH
Expand Down
1 change: 1 addition & 0 deletions libsigner/src/v0/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ pub struct PeerInfo {
}

impl StacksMessageCodec for PeerInfo {
#[allow(clippy::needless_as_bytes)] // as_bytes isn't necessary, but verbosity is preferable in the codec impls
fn consensus_serialize<W: Write>(&self, fd: &mut W) -> Result<(), CodecError> {
write_next(fd, &self.burn_block_height)?;
write_next(fd, self.stacks_tip_consensus_hash.as_bytes())?;
Expand Down
4 changes: 2 additions & 2 deletions pox-locking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use clarity::vm::costs::LimitedCostTracker;
use clarity::vm::errors::Error as ClarityError;
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier, ResponseData, TupleData};
use clarity::vm::Value;
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
use slog::slog_debug;
use slog::slog_error;
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
use stacks_common::debug;
use stacks_common::types::StacksEpochId;
use stacks_common::{error, test_debug};
Expand Down
4 changes: 2 additions & 2 deletions pox-locking/src/events_24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use clarity::vm::contexts::GlobalContext;
use clarity::vm::errors::Error as ClarityError;
use clarity::vm::types::{PrincipalData, QualifiedContractIdentifier, TupleData};
use clarity::vm::Value;
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
use slog::slog_debug;
use slog::slog_error;
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
use stacks_common::debug;
use stacks_common::{error, test_debug};

Expand Down

0 comments on commit 11823df

Please sign in to comment.