units, consensus_encoding: fix up lints
What changed, and why it matters
This commit is a routine code cleanup that fixes compiler/style lints. It removes an unused helper constructor in a test file and makes a few type names explicit instead of relying on type inference. There is no security-relevant change.
No security action needed. Treat as normal maintenance/lint cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff removes an unused CompositeDataDecoder::new() method from consensus_encoding/tests/composition.rs and replaces implicit Default::default() calls with explicit type annotations (encoding::Decoder4::default() and <encoding::ArrayDecoder<1>>::default()) in p2p/src/message.rs. It also reformats one test assertion. These are purely lint-driven refactorings with no functional or security behavior change.
Changed components
consensus_encoding/tests/composition.rsp2p/src/message.rsInspect captured patch +6 / −13
diff --git a/consensus_encoding/tests/composition.rs b/consensus_encoding/tests/composition.rs
index 2ed79aa0..6231f3bb 100644
--- a/consensus_encoding/tests/composition.rs
+++ b/consensus_encoding/tests/composition.rs
@@ -51,12 +51,6 @@ struct CompositeDataDecoder {
inner: Decoder2<ArrayDecoder<4>, ArrayDecoder<2>>,
}
-impl CompositeDataDecoder {
- fn new() -> Self {
- Self { inner: Decoder2::new(ArrayDecoder::<4>::new(), ArrayDecoder::<2>::new()) }
- }
-}
-
impl Decoder for CompositeDataDecoder {
type Output = CompositeData;
type Error = CompositeError;
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index 0ad20f63..b6a01a1e 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -1328,9 +1328,7 @@ enum DecoderState {
}
impl Default for DecoderState {
- fn default() -> Self {
- Self::ReadingHeader { header_decoder: Default::default() }
- }
+ fn default() -> Self { Self::ReadingHeader { header_decoder: encoding::Decoder4::default() } }
}
/// Decoder for [`V1NetworkMessage`].
@@ -1683,9 +1681,7 @@ enum V2NetworkMessageDecoderState {
}
impl Default for V2NetworkMessageDecoderState {
- fn default() -> Self {
- Self::ShortId(Default::default())
- }
+ fn default() -> Self { Self::ShortId(<encoding::ArrayDecoder<1>>::default()) }
}
/// Decoder for [`V2NetworkMessage`].
@@ -2502,7 +2498,10 @@ mod test {
// Test serializing.
let cs = CommandString("Andrew".into());
- assert_eq!(encoding::encode_to_vec(&cs), [0x41u8, 0x6e, 0x64, 0x72, 0x65, 0x77, 0, 0, 0, 0, 0, 0]);
+ assert_eq!(
+ encoding::encode_to_vec(&cs),
+ [0x41u8, 0x6e, 0x64, 0x72, 0x65, 0x77, 0, 0, 0, 0, 0, 0]
+ );
// Test deserializing
let cs: Result<CommandString, _> =
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.