Skip to content

Commit

Permalink
Fix Clippy lints (#957)
Browse files Browse the repository at this point in the history
This shouldn't have made it onto `main`, but was able to as a result of
the bug described in #947.

This will need to merge before #948 can merge.
  • Loading branch information
joshlf committed Feb 26, 2024
1 parent a309a36 commit 40b550e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8301,13 +8301,15 @@ mod tests {
pub(super) struct AutorefWrapper<T: ?Sized>(pub(super) PhantomData<T>);

pub(super) trait TestIsBitValidShared<T: ?Sized> {
#[allow(clippy::needless_lifetimes)]
fn test_is_bit_valid_shared<'ptr, A: invariant::at_least::Shared>(
&self,
candidate: Maybe<'ptr, T, A>,
) -> Option<bool>;
}

impl<T: TryFromBytes + NoCell + ?Sized> TestIsBitValidShared<T> for AutorefWrapper<T> {
#[allow(clippy::needless_lifetimes)]
fn test_is_bit_valid_shared<'ptr, A: invariant::at_least::Shared>(
&self,
candidate: Maybe<'ptr, T, A>,
Expand All @@ -8317,25 +8319,29 @@ mod tests {
}

pub(super) trait TestTryFromRef<T: ?Sized> {
#[allow(clippy::needless_lifetimes)]
fn test_try_from_ref<'bytes>(
&self,
bytes: &'bytes [u8],
) -> Option<Option<&'bytes T>>;

#[allow(clippy::needless_lifetimes)]
fn test_try_from_mut<'bytes>(
&self,
bytes: &'bytes mut [u8],
) -> Option<Option<&'bytes mut T>>;
}

impl<T: TryFromBytes + NoCell + KnownLayout + ?Sized> TestTryFromRef<T> for AutorefWrapper<T> {
#[allow(clippy::needless_lifetimes)]
fn test_try_from_ref<'bytes>(
&self,
bytes: &'bytes [u8],
) -> Option<Option<&'bytes T>> {
Some(T::try_from_ref(bytes))
}

#[allow(clippy::needless_lifetimes)]
fn test_try_from_mut<'bytes>(
&self,
bytes: &'bytes mut [u8],
Expand All @@ -8357,10 +8363,12 @@ mod tests {
}

pub(super) trait TestAsBytes<T: ?Sized> {
#[allow(clippy::needless_lifetimes)]
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t T) -> Option<&'t [u8]>;
}

impl<T: IntoBytes + NoCell + ?Sized> TestAsBytes<T> for AutorefWrapper<T> {
#[allow(clippy::needless_lifetimes)]
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t T) -> Option<&'t [u8]> {
Some(t.as_bytes())
}
Expand Down Expand Up @@ -8407,6 +8415,7 @@ mod tests {
// implementations defined in the `autoref_trick` module above.
#[allow(unused)]
impl AutorefWrapper<$ty> {
#[allow(clippy::needless_lifetimes)]
fn test_is_bit_valid_shared<'ptr, A: invariant::at_least::Shared>(
&mut self,
candidate: Maybe<'ptr, $ty, A>,
Expand All @@ -8424,6 +8433,7 @@ mod tests {
None
}

#[allow(clippy::needless_lifetimes)]
fn test_try_from_ref<'bytes>(&mut self, _bytes: &'bytes [u8]) -> Option<Option<&'bytes $ty>> {
assert_on_allowlist!(
test_try_from_ref($ty):
Expand All @@ -8433,6 +8443,7 @@ mod tests {
None
}

#[allow(clippy::needless_lifetimes)]
fn test_try_from_mut<'bytes>(&mut self, _bytes: &'bytes mut [u8]) -> Option<Option<&'bytes mut $ty>> {
assert_on_allowlist!(
test_try_from_mut($ty):
Expand Down
5 changes: 4 additions & 1 deletion src/pointer/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ mod _conversions {
/// methods from being called on `self` as long as the returned `Ptr`
/// exists.
#[doc(hidden)]
#[inline]
#[allow(clippy::needless_lifetimes)] // Allows us to name the lifetime in the safety comment below.
pub fn reborrow<'b>(&'b mut self) -> Ptr<'b, T, I>
where
Expand Down Expand Up @@ -691,15 +692,17 @@ mod _transitions {
let t = t.as_bytes();

let mut i = 0;
#[allow(clippy::arithmetic_side_effects)]
while i < s.len() {
#[allow(clippy::indexing_slicing)]
if s[i] != t[i] {
return false;
}

i += 1;
}

return true;
true
}

assert!(I::Aliasing::IS_EXCLUSIVE);
Expand Down

0 comments on commit 40b550e

Please sign in to comment.