Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new clippy lints #2429

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion synthesizer/process/src/stack/register_types/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<N: Network> RegisterTypes<N> {
for operand in async_.operands() {
if let Operand::Register(register) = operand {
if let Ok(RegisterType::Future(locator)) = register_types.get_type(stack, register) {
assert!(future_registers.remove(&(register.clone(), locator)));
assert!(future_registers.swap_remove(&(register.clone(), locator)));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do want swap_remove here, because right after this loop we ensure that the future_registers is empty, meaning the order is no longer significant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@d0cd @evan-schott can you confirm swap_remove is the intended behavior? (i understand it was technically swap_remove, want to ensure it truly shouldn't be shift_remove)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that swap_remove is intended since we do not rely on the order of future_registers after the removes are done.

}
}
}
Expand Down
8 changes: 4 additions & 4 deletions utilities/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait FromBytes {
}
}

pub struct ToBytesSerializer<T: ToBytes>(String, Option<usize>, PhantomData<T>);
pub struct ToBytesSerializer<T: ToBytes>(PhantomData<T>);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe share intuition or the clippy lint which led to these suggestions? The change ot FromBytesVisitor makes sense but for ToBytesSerializer and FromBytesDeserializer I don't see why we can remove those elements "for free" and why we put them there in the first place.

Copy link
Collaborator Author

@ljedrz ljedrz Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy just stated that they are never used - I'm not sure why they were put there in the first place either (presumably some feature that was never added in the end), but everything still compiles just fine without them.


impl<T: ToBytes> ToBytesSerializer<T> {
/// Serializes a static-sized object as a byte array (without length encoding).
Expand All @@ -100,7 +100,7 @@ impl<T: ToBytes> ToBytesSerializer<T> {
}
}

pub struct FromBytesDeserializer<T: FromBytes>(String, Option<usize>, PhantomData<T>);
pub struct FromBytesDeserializer<T: FromBytes>(PhantomData<T>);

impl<'de, T: FromBytes> FromBytesDeserializer<T> {
/// Deserializes a static-sized byte array (without length encoding).
Expand Down Expand Up @@ -166,12 +166,12 @@ impl<'de, T: FromBytes> FromBytesDeserializer<T> {
}
}

pub struct FromBytesVisitor<'a>(&'a mut Vec<u8>, SmolStr, Option<usize>);
pub struct FromBytesVisitor<'a>(&'a mut Vec<u8>, SmolStr);

impl<'a> FromBytesVisitor<'a> {
/// Initializes a new `FromBytesVisitor` with the given `buffer` and `name`.
pub fn new(buffer: &'a mut Vec<u8>, name: &str) -> Self {
Self(buffer, SmolStr::new(name), None)
Self(buffer, SmolStr::new(name))
}
}

Expand Down