Skip to content

Commit

Permalink
Lint: Apply future clippy::needless_lifetimes.
Browse files Browse the repository at this point in the history
I'm not entirely sure I like the non-uniformity of giving a name to the
lifetime in the type only if it is used in the body, but I do appreciate
reducing the generic parameter count in many impl blocks, and all of the
actual cases seem fine.

This additional lint came from <rust-lang/rust-clippy#13286>
“Extend needless_lifetimes to suggest eliding impl lifetimes”.
  • Loading branch information
kpreid committed Oct 4, 2024
1 parent d5a7400 commit cc2a664
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/math/vol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a, V> Vol<&'a [V], ZMaj> {
}
}

impl<'a, V> Vol<&'a mut [V], ZMaj> {
impl<V> Vol<&mut [V], ZMaj> {
/// Divide `self` into two approximately equal-sized parts.
/// each of which refers to the appropriate sub-slice of elements.
///
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-base/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ where
}
}

impl<'a, A, B, T, F> Extend<A> for MapExtend<'a, A, B, T, F>
impl<A, B, T, F> Extend<A> for MapExtend<'_, A, B, T, F>
where
T: Extend<B>,
F: Fn(A) -> B,
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-render/src/raytracer/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ pub struct RtScene<'a, P: Accumulate> {
options: RtOptionsRef<'a, <P::BlockData as RtBlockData>::Options>,
}

impl<'a, P: Accumulate> fmt::Debug for RtScene<'a, P>
impl<P: Accumulate> fmt::Debug for RtScene<'_, P>
where
<P::BlockData as RtBlockData>::Options: fmt::Debug,
{
Expand All @@ -345,7 +345,7 @@ where
}
}

impl<'a, P: Accumulate> Clone for RtScene<'a, P> {
impl<P: Accumulate> Clone for RtScene<'_, P> {
fn clone(&self) -> Self {
Self {
rts: self.rts,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-ui/src/vui/widget_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub struct WidgetContext<'a> {
grant: &'a LayoutGrant,
}

impl<'a> WidgetContext<'a> {
impl WidgetContext<'_> {
/// The time tick that is currently passing, causing this step.
pub fn tick(&self) -> Tick {
match self.behavior_context {
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'a, H: Host> Context<'a, H> {
}
}

impl<'a, H: Host + fmt::Debug> fmt::Debug for Context<'a, H> {
impl<H: Host + fmt::Debug> fmt::Debug for Context<'_, H> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// binder functions are not debuggable
f.debug_struct("Context")
Expand Down Expand Up @@ -485,7 +485,7 @@ pub struct QueryItem<'a, H: Host, B: Behavior<H> + ?Sized> {
pub attachment: &'a H::Attachment,
}

impl<'a, H: Host, B: Behavior<H> + ?Sized> Clone for QueryItem<'a, H, B> {
impl<H: Host, B: Behavior<H> + ?Sized> Clone for QueryItem<'_, H, B> {
fn clone(&self) -> Self {
// Manual impl avoids `H: Clone` bound.
Self {
Expand All @@ -495,7 +495,7 @@ impl<'a, H: Host, B: Behavior<H> + ?Sized> Clone for QueryItem<'a, H, B> {
}
}

impl<'a, H: Host, B: Behavior<H> + ?Sized> fmt::Debug for QueryItem<'a, H, B> {
impl<H: Host, B: Behavior<H> + ?Sized> fmt::Debug for QueryItem<'_, H, B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let QueryItem {
attachment,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/content/load_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> PngAdapter<'a> {
}
}

impl<'a> PngAdapter<'a> {
impl PngAdapter<'_> {
#[doc(hidden)] // TODO: ponder good API
pub fn get_brush(&self, x: i32, y: i32) -> &VoxelBrush<'_> {
if x < 0 || y < 0 || x >= self.width || y >= self.height {
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub trait VoxelColor<'a>: PixelColor {
fn into_blocks(self) -> VoxelBrush<'a>;
}

impl<'a> PixelColor for &'a Block {
impl PixelColor for &Block {
type Raw = ();
}
impl<'a> VoxelColor<'a> for &'a Block {
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<'notifier, M, const CAPACITY: usize> Buffer<'notifier, M, CAPACITY> {
}
}

impl<'notifier, M, const CAPACITY: usize> Drop for Buffer<'notifier, M, CAPACITY> {
impl<M, const CAPACITY: usize> Drop for Buffer<'_, M, CAPACITY> {
fn drop(&mut self) {
// TODO: Should we discard messages if panicking?
// Currently leaning no, because we've specified that listeners should not panic even under
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/raytracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ impl<D: RtBlockData> SpaceRaytracer<D> {
_p: PhantomData<fn() -> P>,
}

impl<'a, D: RtBlockData, P: Accumulate<BlockData = D> + Into<String>> fmt::Display
for ToText<'a, D, P>
impl<D: RtBlockData, P: Accumulate<BlockData = D> + Into<String>> fmt::Display
for ToText<'_, D, P>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.rt
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/raytracer/accum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl<'a, C> RtOptionsRef<'a, C> {
}

// Non-derived implementations for no `C: Clone` bound.
impl<'a, C> Copy for RtOptionsRef<'a, C> {}
impl<'a, C> Clone for RtOptionsRef<'a, C> {
impl<C> Copy for RtOptionsRef<'_, C> {}
impl<C> Clone for RtOptionsRef<'_, C> {
fn clone(&self) -> Self {
*self
}
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes/src/save/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) struct GzSerde<'a, T: 'static>(pub Cow<'a, [T]>)
where
[T]: ToOwned;

impl<'a, T: bytemuck::NoUninit> serde::Serialize for GzSerde<'a, T> {
impl<T: bytemuck::NoUninit> serde::Serialize for GzSerde<'_, T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down Expand Up @@ -48,7 +48,7 @@ impl<'a, T: bytemuck::NoUninit> serde::Serialize for GzSerde<'a, T> {
}
}

impl<'a, 'de, T: bytemuck::CheckedBitPattern> serde::Deserialize<'de> for GzSerde<'a, T> {
impl<'de, T: bytemuck::CheckedBitPattern> serde::Deserialize<'de> for GzSerde<'_, T> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/universe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ impl behavior::Host for Universe {
#[derive(Clone, Debug)]
#[expect(clippy::module_name_repetitions)] // TODO: consider renaming to Iter
pub struct UniverseIter<'u, T>(alloc::collections::btree_map::Iter<'u, Name, RootHandle<T>>);
impl<'u, T> Iterator for UniverseIter<'u, T> {
impl<T> Iterator for UniverseIter<'_, T> {
type Item = (Name, Handle<T>);
fn next(&mut self) -> Option<Self::Item> {
self.0
Expand Down
10 changes: 5 additions & 5 deletions all-is-cubes/src/util/maybe_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,33 +164,33 @@ impl<T> RwLock<T> {
}
}

impl<'a, T> ops::Deref for MutexGuard<'a, T> {
impl<T> ops::Deref for MutexGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a, T> ops::DerefMut for MutexGuard<'a, T> {
impl<T> ops::DerefMut for MutexGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<'a, T> ops::Deref for RwLockReadGuard<'a, T> {
impl<T> ops::Deref for RwLockReadGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a, T> ops::Deref for RwLockWriteGuard<'a, T> {
impl<T> ops::Deref for RwLockWriteGuard<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a, T> ops::DerefMut for RwLockWriteGuard<'a, T> {
impl<T> ops::DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
Expand Down
2 changes: 1 addition & 1 deletion test-renderers/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ where
#[expect(missing_debug_implementations)]
pub struct TestCaseCollector<'a>(&'a mut BTreeMap<String, TestCase>);

impl<'a> TestCaseCollector<'a> {
impl TestCaseCollector<'_> {
#[track_caller]
pub fn insert<F>(
&mut self,
Expand Down

0 comments on commit cc2a664

Please sign in to comment.