From c6bd81bbf30bc5d36aae8bf6e5613737f139a7ac Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 29 Apr 2022 15:43:36 -0700 Subject: [PATCH] Resolve clippy::needless_lifetimes error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) --> src/range_map.rs:66:5 | 66 | pub fn iter<'a>(&'a self, offset: Size, len: Size) -> impl Iterator + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::needless-lifetimes` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) --> src/range_map.rs:86:5 | 86 | pub fn iter_mut_all<'a>(&'a mut self) -> impl Iterator + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) --> src/range_map.rs:122:5 | 122 | / pub fn iter_mut<'a>( 123 | | &'a mut self, 124 | | offset: Size, 125 | | len: Size, 126 | | ) -> impl Iterator + 'a | |_____________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) --> src/shims/intrinsics.rs:1391:1 | 1391 | fn simd_element_to_bool<'tcx>(elem: ImmTy<'tcx, Tag>) -> InterpResult<'tcx, bool> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes --- src/range_map.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/range_map.rs b/src/range_map.rs index 8b5a3af5bac5..f0507ffabad0 100644 --- a/src/range_map.rs +++ b/src/range_map.rs @@ -63,7 +63,7 @@ impl RangeMap { /// through interior mutability. /// /// The iterator also provides the offset of the given element. - pub fn iter<'a>(&'a self, offset: Size, len: Size) -> impl Iterator + 'a { + pub fn iter(&self, offset: Size, len: Size) -> impl Iterator { let offset = offset.bytes(); let len = len.bytes(); // Compute a slice starting with the elements we care about. @@ -83,7 +83,7 @@ impl RangeMap { .map(|elem| (Size::from_bytes(elem.range.start), &elem.data)) } - pub fn iter_mut_all<'a>(&'a mut self) -> impl Iterator + 'a { + pub fn iter_mut_all(&mut self) -> impl Iterator { self.v.iter_mut().map(|elem| &mut elem.data) } @@ -119,11 +119,7 @@ impl RangeMap { /// Moreover, this will opportunistically merge neighbouring equal blocks. /// /// The iterator also provides the offset of the given element. - pub fn iter_mut<'a>( - &'a mut self, - offset: Size, - len: Size, - ) -> impl Iterator + 'a + pub fn iter_mut(&mut self, offset: Size, len: Size) -> impl Iterator where T: Clone + PartialEq, {