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 #1710

Merged
merged 1 commit into from
Nov 13, 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 .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.81.0
toolchain: 1.82.0
components: clippy
- run: cargo clippy --all --all-features --tests -- -D warnings

Expand Down
2 changes: 1 addition & 1 deletion aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ pub struct Payload<'msg, 'aad> {
}

#[cfg(feature = "alloc")]
impl<'msg, 'aad> From<&'msg [u8]> for Payload<'msg, 'aad> {
impl<'msg> From<&'msg [u8]> for Payload<'msg, '_> {
fn from(msg: &'msg [u8]) -> Self {
Self { msg, aad: b"" }
}
Expand Down
20 changes: 10 additions & 10 deletions cipher/src/block/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ pub(super) struct BlockCtx<'inp, 'out, BS: BlockSizes> {
pub block: InOut<'inp, 'out, Block<Self>>,
}

impl<'inp, 'out, BS: BlockSizes> BlockSizeUser for BlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockSizeUser for BlockCtx<'_, '_, BS> {
type BlockSize = BS;
}

impl<'inp, 'out, BS: BlockSizes> BlockCipherEncClosure for BlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockCipherEncClosure for BlockCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockCipherEncBackend<BlockSize = BS>>(self, backend: &B) {
backend.encrypt_block(self.block);
}
}

impl<'inp, 'out, BS: BlockSizes> BlockCipherDecClosure for BlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockCipherDecClosure for BlockCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockCipherDecBackend<BlockSize = BS>>(self, backend: &B) {
backend.decrypt_block(self.block);
}
}

impl<'inp, 'out, BS: BlockSizes> BlockModeEncClosure for BlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockModeEncClosure for BlockCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockModeEncBackend<BlockSize = BS>>(self, backend: &mut B) {
backend.encrypt_block(self.block);
}
}

impl<'inp, 'out, BS: BlockSizes> BlockModeDecClosure for BlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockModeDecClosure for BlockCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockModeDecBackend<BlockSize = BS>>(self, backend: &mut B) {
backend.decrypt_block(self.block);
Expand All @@ -47,11 +47,11 @@ pub(super) struct BlocksCtx<'inp, 'out, BS: BlockSizes> {
pub blocks: InOutBuf<'inp, 'out, Block<Self>>,
}

impl<'inp, 'out, BS: BlockSizes> BlockSizeUser for BlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockSizeUser for BlocksCtx<'_, '_, BS> {
type BlockSize = BS;
}

impl<'inp, 'out, BS: BlockSizes> BlockCipherEncClosure for BlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockCipherEncClosure for BlocksCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockCipherEncBackend<BlockSize = BS>>(self, backend: &B) {
if B::ParBlocksSize::USIZE > 1 {
Expand All @@ -68,7 +68,7 @@ impl<'inp, 'out, BS: BlockSizes> BlockCipherEncClosure for BlocksCtx<'inp, 'out,
}
}

impl<'inp, 'out, BS: BlockSizes> BlockCipherDecClosure for BlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockCipherDecClosure for BlocksCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockCipherDecBackend<BlockSize = BS>>(self, backend: &B) {
if B::ParBlocksSize::USIZE > 1 {
Expand All @@ -85,7 +85,7 @@ impl<'inp, 'out, BS: BlockSizes> BlockCipherDecClosure for BlocksCtx<'inp, 'out,
}
}

impl<'inp, 'out, BS: BlockSizes> BlockModeEncClosure for BlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockModeEncClosure for BlocksCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockModeEncBackend<BlockSize = BS>>(self, backend: &mut B) {
if B::ParBlocksSize::USIZE > 1 {
Expand All @@ -102,7 +102,7 @@ impl<'inp, 'out, BS: BlockSizes> BlockModeEncClosure for BlocksCtx<'inp, 'out, B
}
}

impl<'inp, 'out, BS: BlockSizes> BlockModeDecClosure for BlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockModeDecClosure for BlocksCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: BlockModeDecBackend<BlockSize = BS>>(self, backend: &mut B) {
if B::ParBlocksSize::USIZE > 1 {
Expand Down
16 changes: 8 additions & 8 deletions cipher/src/stream/core_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ impl_counter! { u32 u64 u128 }
struct WriteBlockCtx<'a, BS: BlockSizes> {
block: &'a mut Block<Self>,
}
impl<'a, BS: BlockSizes> BlockSizeUser for WriteBlockCtx<'a, BS> {
impl<BS: BlockSizes> BlockSizeUser for WriteBlockCtx<'_, BS> {
type BlockSize = BS;
}
impl<'a, BS: BlockSizes> StreamCipherClosure for WriteBlockCtx<'a, BS> {
impl<BS: BlockSizes> StreamCipherClosure for WriteBlockCtx<'_, BS> {
#[inline(always)]
fn call<B: StreamCipherBackend<BlockSize = BS>>(self, backend: &mut B) {
backend.gen_ks_block(self.block);
Expand All @@ -203,10 +203,10 @@ impl<'a, BS: BlockSizes> StreamCipherClosure for WriteBlockCtx<'a, BS> {
struct WriteBlocksCtx<'a, BS: BlockSizes> {
blocks: &'a mut [Block<Self>],
}
impl<'a, BS: BlockSizes> BlockSizeUser for WriteBlocksCtx<'a, BS> {
impl<BS: BlockSizes> BlockSizeUser for WriteBlocksCtx<'_, BS> {
type BlockSize = BS;
}
impl<'a, BS: BlockSizes> StreamCipherClosure for WriteBlocksCtx<'a, BS> {
impl<BS: BlockSizes> StreamCipherClosure for WriteBlocksCtx<'_, BS> {
#[inline(always)]
fn call<B: StreamCipherBackend<BlockSize = BS>>(self, backend: &mut B) {
if B::ParBlocksSize::USIZE > 1 {
Expand All @@ -227,11 +227,11 @@ struct ApplyBlockCtx<'inp, 'out, BS: BlockSizes> {
block: InOut<'inp, 'out, Block<Self>>,
}

impl<'inp, 'out, BS: BlockSizes> BlockSizeUser for ApplyBlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockSizeUser for ApplyBlockCtx<'_, '_, BS> {
type BlockSize = BS;
}

impl<'inp, 'out, BS: BlockSizes> StreamCipherClosure for ApplyBlockCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> StreamCipherClosure for ApplyBlockCtx<'_, '_, BS> {
#[inline(always)]
fn call<B: StreamCipherBackend<BlockSize = BS>>(mut self, backend: &mut B) {
let mut t = Default::default();
Expand All @@ -244,11 +244,11 @@ struct ApplyBlocksCtx<'inp, 'out, BS: BlockSizes> {
blocks: InOutBuf<'inp, 'out, Block<Self>>,
}

impl<'inp, 'out, BS: BlockSizes> BlockSizeUser for ApplyBlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> BlockSizeUser for ApplyBlocksCtx<'_, '_, BS> {
type BlockSize = BS;
}

impl<'inp, 'out, BS: BlockSizes> StreamCipherClosure for ApplyBlocksCtx<'inp, 'out, BS> {
impl<BS: BlockSizes> StreamCipherClosure for ApplyBlocksCtx<'_, '_, BS> {
#[inline(always)]
#[allow(clippy::needless_range_loop)]
fn call<B: StreamCipherBackend<BlockSize = BS>>(self, backend: &mut B) {
Expand Down
3 changes: 1 addition & 2 deletions cipher/src/stream/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ impl<T: StreamCipherCore> StreamCipherCoreWrapper<T> {
};

let bs = T::BlockSize::USIZE;
// TODO: use div_ceil on 1.73+ MSRV bump
let blocks = (data_len + bs - 1) / bs;
let blocks = data_len.div_ceil(bs);
if blocks > rem_blocks {
Err(StreamCipherError)
} else {
Expand Down
8 changes: 4 additions & 4 deletions password-hash/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ impl<'a> Ident<'a> {
}
}

impl<'a> AsRef<str> for Ident<'a> {
impl AsRef<str> for Ident<'_> {
fn as_ref(&self) -> &str {
self.as_str()
}
}

impl<'a> Deref for Ident<'a> {
impl Deref for Ident<'_> {
type Target = str;

fn deref(&self) -> &str {
Expand All @@ -115,13 +115,13 @@ impl<'a> TryFrom<&'a str> for Ident<'a> {
}
}

impl<'a> fmt::Display for Ident<'a> {
impl fmt::Display for Ident<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self)
}
}

impl<'a> fmt::Debug for Ident<'a> {
impl fmt::Debug for Ident<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Ident").field(&self.as_ref()).finish()
}
Expand Down
2 changes: 1 addition & 1 deletion password-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a> TryFrom<&'a str> for PasswordHash<'a> {
}
}

impl<'a> fmt::Display for PasswordHash<'a> {
impl fmt::Display for PasswordHash<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}{}", PASSWORD_HASH_SEPARATOR, self.algorithm)?;

Expand Down
6 changes: 3 additions & 3 deletions password-hash/src/salt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'a> Salt<'a> {
}
}

impl<'a> AsRef<str> for Salt<'a> {
impl AsRef<str> for Salt<'_> {
fn as_ref(&self) -> &str {
self.as_str()
}
Expand All @@ -177,13 +177,13 @@ impl<'a> TryFrom<&'a str> for Salt<'a> {
}
}

impl<'a> fmt::Display for Salt<'a> {
impl fmt::Display for Salt<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}

impl<'a> fmt::Debug for Salt<'a> {
impl fmt::Debug for Salt<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Salt({:?})", self.as_str())
}
Expand Down
4 changes: 2 additions & 2 deletions password-hash/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<'a> Value<'a> {
}
}

impl<'a> AsRef<str> for Value<'a> {
impl AsRef<str> for Value<'_> {
fn as_ref(&self) -> &str {
self.as_str()
}
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a> TryFrom<&Value<'a>> for Decimal {
}
}

impl<'a> fmt::Display for Value<'a> {
impl fmt::Display for Value<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
Expand Down
4 changes: 2 additions & 2 deletions universal-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ pub trait UniversalHash: BlockSizeUser + Sized {
blocks: &'a [Block<Self>],
}

impl<'a, BS: BlockSizes> BlockSizeUser for Ctx<'a, BS> {
impl<BS: BlockSizes> BlockSizeUser for Ctx<'_, BS> {
type BlockSize = BS;
}

impl<'a, BS: BlockSizes> UhfClosure for Ctx<'a, BS> {
impl<BS: BlockSizes> UhfClosure for Ctx<'_, BS> {
#[inline(always)]
fn call<B: UhfBackend<BlockSize = BS>>(self, backend: &mut B) {
let pb = B::ParBlocksSize::USIZE;
Expand Down