Skip to content

Commit

Permalink
Clippy cleanup: needless_lifetimes (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers authored Oct 7, 2024
1 parent 97c31d2 commit d5b3b46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions mockall/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ pub struct ArgPrinter<'a, T>(pub &'a T);

#[doc(hidden)]
pub struct DebugPrint<'a, T: Debug>(pub &'a T);
impl<'a, T> Debug for DebugPrint<'a, T> where T: Debug {
impl<T> Debug for DebugPrint<'_, T> where T: Debug {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(self.0, f)
}
Expand All @@ -1503,7 +1503,7 @@ impl Debug for NothingPrint {
}
#[doc(hidden)]
pub trait ViaNothing { fn debug_string(&self) -> NothingPrint; }
impl<'a, T> ViaNothing for ArgPrinter<'a, T> {
impl<T> ViaNothing for ArgPrinter<'_, T> {
fn debug_string(&self) -> NothingPrint {
NothingPrint
}
Expand Down
3 changes: 3 additions & 0 deletions mockall/tests/automock_nonstatic_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub struct NonStaticStruct<'nss> {
_x: &'nss i32
}

// For an example without the needless_lifetimes, see
// automock_elided_lifetime.rs and issue #610 .
#[allow(clippy::needless_lifetimes)]
#[automock]
impl<'nss> NonStaticStruct<'nss> {
pub fn foo(&self) -> i64 {
Expand Down
38 changes: 19 additions & 19 deletions mockall_derive/src/mock_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ struct Common<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for Common<'a> {
impl ToTokens for Common<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let predty = &self.f.predty;
Expand Down Expand Up @@ -1065,7 +1065,7 @@ struct CommonExpectationMethods<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for CommonExpectationMethods<'a> {
impl ToTokens for CommonExpectationMethods<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let hrtb = self.f.hrtb();
Expand Down Expand Up @@ -1190,7 +1190,7 @@ struct CommonExpectationsMethods<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for CommonExpectationsMethods<'a> {
impl ToTokens for CommonExpectationsMethods<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let (ig, tg, wc) = self.f.egenerics.split_for_impl();
let v = &self.f.privmod_vis;
Expand Down Expand Up @@ -1235,7 +1235,7 @@ struct ExpectationGuardCommonMethods<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for ExpectationGuardCommonMethods<'a> {
impl ToTokens for ExpectationGuardCommonMethods<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.f.is_static {
return;
Expand Down Expand Up @@ -1406,7 +1406,7 @@ struct ConcreteExpectationGuard<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for ConcreteExpectationGuard<'a> {
impl ToTokens for ConcreteExpectationGuard<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.f.is_static {
return;
Expand Down Expand Up @@ -1475,7 +1475,7 @@ struct GenericExpectationGuard<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for GenericExpectationGuard<'a> {
impl ToTokens for GenericExpectationGuard<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.f.is_static {
return;
Expand Down Expand Up @@ -1545,7 +1545,7 @@ struct Context<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for Context<'a> {
impl ToTokens for Context<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.f.is_static {
return;
Expand Down Expand Up @@ -1656,7 +1656,7 @@ struct Matcher<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for Matcher<'a> {
impl ToTokens for Matcher<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let (ig, tg, wc) = self.f.cgenerics.split_for_impl();
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -1760,7 +1760,7 @@ struct RefRfunc<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefRfunc<'a> {
impl ToTokens for RefRfunc<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let fn_params = &self.f.fn_params;
let (ig, tg, wc) = self.f.egenerics.split_for_impl();
Expand Down Expand Up @@ -1819,7 +1819,7 @@ struct RefMutRfunc<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefMutRfunc<'a> {
impl ToTokens for RefMutRfunc<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let argty = &self.f.argty;
Expand Down Expand Up @@ -1909,7 +1909,7 @@ struct StaticRfunc<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for StaticRfunc<'a> {
impl ToTokens for StaticRfunc<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let argty = &self.f.argty;
Expand Down Expand Up @@ -1996,7 +1996,7 @@ struct RefExpectation<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefExpectation<'a> {
impl ToTokens for RefExpectation<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let argty = &self.f.argty;
Expand Down Expand Up @@ -2062,7 +2062,7 @@ struct RefMutExpectation<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefMutExpectation<'a> {
impl ToTokens for RefMutExpectation<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let common_methods = CommonExpectationMethods{f: self.f};
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -2150,7 +2150,7 @@ struct StaticExpectation<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for StaticExpectation<'a> {
impl ToTokens for StaticExpectation<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let common_methods = CommonExpectationMethods{f: self.f};
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -2324,7 +2324,7 @@ struct RefExpectations<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefExpectations<'a> {
impl ToTokens for RefExpectations<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let common_methods = CommonExpectationsMethods{f: self.f};
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -2362,7 +2362,7 @@ struct RefMutExpectations<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for RefMutExpectations<'a> {
impl ToTokens for RefMutExpectations<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let common_methods = CommonExpectationsMethods{f: self.f};
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -2401,7 +2401,7 @@ struct StaticExpectations<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for StaticExpectations<'a> {
impl ToTokens for StaticExpectations<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let common_methods = CommonExpectationsMethods{f: self.f};
let argnames = &self.f.argnames;
Expand Down Expand Up @@ -2438,7 +2438,7 @@ struct GenericExpectations<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for GenericExpectations<'a> {
impl ToTokens for GenericExpectations<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if ! self.f.is_expectation_generic() {
return;
Expand Down Expand Up @@ -2484,7 +2484,7 @@ struct StaticGenericExpectations<'a> {
f: &'a MockFunction
}

impl<'a> ToTokens for StaticGenericExpectations<'a> {
impl ToTokens for StaticGenericExpectations<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let argnames = &self.f.argnames;
let argty = &self.f.argty;
Expand Down

0 comments on commit d5b3b46

Please sign in to comment.