Skip to content

Commit 89b53b9

Browse files
committed
digest: enable and fix workspace-level lints
1 parent 6514b1f commit 89b53b9

8 files changed

Lines changed: 30 additions & 11 deletions

File tree

digest/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ zeroize = ["dep:zeroize", "block-buffer?/zeroize"]
3636
alloc = []
3737
dev = ["blobby"]
3838

39+
[lints]
40+
workspace = true
41+
3942
[package.metadata.docs.rs]
4043
all-features = true

digest/src/block_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub trait VariableOutputCore: UpdateCore + OutputSizeUser + BufferKindUser + Siz
9696

9797
/// Initialize hasher state for given output size.
9898
///
99+
/// # Errors
99100
/// Returns [`InvalidOutputSize`] if `output_size` is not valid for
100101
/// the algorithm, e.g. if it's bigger than the [`OutputSize`]
101102
/// associated type.

digest/src/dev.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Development-related functionality
22
3+
#![allow(clippy::missing_errors_doc)]
4+
35
pub use blobby;
46

57
mod fixed;

digest/src/digest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<D: FixedOutput + Default + Update + HashMarker> Digest for D {
114114
where
115115
Self: Reset,
116116
{
117-
Reset::reset(self)
117+
Reset::reset(self);
118118
}
119119

120120
#[inline]
@@ -148,6 +148,7 @@ pub trait DynDigest {
148148
/// Retrieve result and consume boxed hasher instance
149149
#[cfg(feature = "alloc")]
150150
#[allow(clippy::boxed_local)]
151+
#[must_use]
151152
fn finalize(mut self: Box<Self>) -> Box<[u8]> {
152153
let mut result = vec![0; self.output_size()];
153154
self.finalize_into_reset(&mut result).unwrap();
@@ -156,11 +157,13 @@ pub trait DynDigest {
156157

157158
/// Write result into provided array and consume the hasher instance.
158159
///
160+
/// # Errors
159161
/// Returns error if buffer length is not equal to `output_size`.
160162
fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>;
161163

162164
/// Write result into provided array and reset the hasher instance.
163165
///
166+
/// # Errors
164167
/// Returns error if buffer length is not equal to `output_size`.
165168
fn finalize_into_reset(&mut self, out: &mut [u8]) -> Result<(), InvalidBufferSize>;
166169

digest/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
html_logo_url = "https://github.com/RustCrypto/media/6ee8e381/logo.svg",
77
html_favicon_url = "https://github.com/RustCrypto/media/6ee8e381/logo.svg"
88
)]
9-
#![warn(missing_docs, rust_2018_idioms, missing_debug_implementations)]
9+
#![allow(clippy::unwrap_used)] // TODO
1010

1111
//! ## Structure
1212
//!

digest/src/mac.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,47 @@ pub trait Mac: OutputSizeUser + Sized {
3636
Self: Reset;
3737

3838
/// Check if tag/code value is correct for the processed input.
39+
///
40+
/// # Errors
41+
/// Returns [`MacError`] if `tag` is not valid.
3942
fn verify(self, tag: &Output<Self>) -> Result<(), MacError>;
4043

4144
/// Check if tag/code value is correct for the processed input and reset
4245
/// [`Mac`] instance.
46+
///
47+
/// # Errors
48+
/// Returns [`MacError`] if `tag` is not valid.
4349
fn verify_reset(&mut self, tag: &Output<Self>) -> Result<(), MacError>
4450
where
4551
Self: FixedOutputReset;
4652

4753
/// Check truncated tag correctness using all bytes
4854
/// of calculated tag.
4955
///
50-
/// Returns `Error` if `tag` is not valid or not equal in length
51-
/// to MAC's output.
56+
/// # Errors
57+
/// Returns [`MacError`] if `tag` is not valid or not equal in length to this MAC's output.
5258
fn verify_slice(self, tag: &[u8]) -> Result<(), MacError>;
5359

5460
/// Check truncated tag correctness using all bytes
5561
/// of calculated tag and reset [`Mac`] instance.
5662
///
57-
/// Returns `Error` if `tag` is not valid or not equal in length
58-
/// to MAC's output.
63+
/// # Errors
64+
/// Returns [`MacError`] if `tag` is not valid or not equal in length to MAC's output.
5965
fn verify_slice_reset(&mut self, tag: &[u8]) -> Result<(), MacError>
6066
where
6167
Self: FixedOutputReset;
6268

6369
/// Check truncated tag correctness using left side bytes
6470
/// (i.e. `tag[..n]`) of calculated tag.
6571
///
72+
/// # Errors
6673
/// Returns `Error` if `tag` is not valid or empty.
6774
fn verify_truncated_left(self, tag: &[u8]) -> Result<(), MacError>;
6875

6976
/// Check truncated tag correctness using right side bytes
7077
/// (i.e. `tag[n..]`) of calculated tag.
7178
///
79+
/// # Errors
7280
/// Returns `Error` if `tag` is not valid or empty.
7381
fn verify_truncated_right(self, tag: &[u8]) -> Result<(), MacError>;
7482
}
@@ -103,7 +111,7 @@ impl<T: Update + FixedOutput + MacMarker> Mac for T {
103111
where
104112
Self: Reset,
105113
{
106-
Reset::reset(self)
114+
Reset::reset(self);
107115
}
108116

109117
#[inline]
@@ -236,7 +244,7 @@ impl<T: OutputSizeUser> Drop for CtOutput<T> {
236244
#[cfg(feature = "zeroize")]
237245
{
238246
use zeroize::Zeroize;
239-
self.bytes.zeroize()
247+
self.bytes.zeroize();
240248
}
241249
}
242250
}

digest/src/xof_fixed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<T: ExtendableOutput + Reset, S: ArraySize> Reset for XofFixedWrapper<T, S>
8383

8484
impl<T: ExtendableOutput + Update, S: ArraySize> Update for XofFixedWrapper<T, S> {
8585
fn update(&mut self, data: &[u8]) {
86-
self.hash.update(data)
86+
self.hash.update(data);
8787
}
8888
}
8989

digest/tests/dummy_fixed.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Tests against a pseudo-hash.
2+
13
#![cfg(feature = "block-api")]
24

35
mod block_api {
@@ -13,7 +15,7 @@ mod block_api {
1315
};
1416

1517
/// Core of primitive XOR hasher for testing purposes
16-
#[derive(Clone, Default, Debug)]
18+
#[derive(Clone, Copy, Default, Debug)]
1719
pub struct FixedHashCore {
1820
state: u64,
1921
}
@@ -41,7 +43,7 @@ mod block_api {
4143
impl UpdateCore for FixedHashCore {
4244
fn update_blocks(&mut self, blocks: &[Block<Self>]) {
4345
for block in blocks {
44-
self.state ^= u64::from_le_bytes(block.0)
46+
self.state ^= u64::from_le_bytes(block.0);
4547
}
4648
}
4749
}

0 commit comments

Comments
 (0)