From 06ca096ad1fd82828aa228bc533af52132ba1000 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 12 Feb 2021 22:18:59 -0700 Subject: [PATCH] Fix Clippy warnings in generated code with Rust nightly 1.52.0 --- CHANGELOG.md | 4 ++++ mockall_derive/src/mock_function.rs | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99aa2e2e..d3e9fec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed ### Fixed + +- Fixed Clippy warnings in generated code with Rustc 1.52.0. + ([#255](https://github.com/asomers/mockall/pull/255)) + ### Removed ## [0.9.0] - 2020-12-21 diff --git a/mockall_derive/src/mock_function.rs b/mockall_derive/src/mock_function.rs index f2d4fc0f..70467993 100644 --- a/mockall_derive/src/mock_function.rs +++ b/mockall_derive/src/mock_function.rs @@ -894,7 +894,7 @@ impl<'a> ToTokens for Common<'a> { { let mut __mockall_guard = self.matcher.lock().unwrap(); *__mockall_guard.deref_mut() = - Matcher::FuncST( + Matcher::FuncSt( ::mockall::Fragile::new(Box::new(__mockall_f)) ); } @@ -1522,7 +1522,7 @@ impl<'a> ToTokens for Matcher<'a> { Always, Func(Box bool + Send>), // Version of Matcher::Func for closures that aren't Send - FuncST(::mockall::Fragile bool>>), + FuncSt(::mockall::Fragile bool>>), Pred(Box<(#preds)>), // Prevent "unused type parameter" errors // Surprisingly, PhantomData is Send even if @@ -1536,7 +1536,7 @@ impl<'a> ToTokens for Matcher<'a> { Matcher::Always => true, Matcher::Func(__mockall_f) => __mockall_f(#(#argnames, )*), - Matcher::FuncST(__mockall_f) => + Matcher::FuncSt(__mockall_f) => (__mockall_f.get())(#(#argnames, )*), Matcher::Pred(__mockall_pred) => [#pred_matches] @@ -1561,7 +1561,7 @@ impl<'a> ToTokens for Matcher<'a> { match self { Matcher::Always => write!(__mockall_fmt, ""), Matcher::Func(_) => write!(__mockall_fmt, ""), - Matcher::FuncST(_) => write!(__mockall_fmt, ""), + Matcher::FuncSt(_) => write!(__mockall_fmt, ""), Matcher::Pred(__mockall_p) => { write!(__mockall_fmt, #braces, #(__mockall_p.#indices,)*) @@ -1661,7 +1661,7 @@ impl<'a> ToTokens for RefMutRfunc<'a> { Mut((Box #owned_output + Send + Sync>), Option<#owned_output>), // Version of Rfunc::Mut for closures that aren't Send - MutST((::mockall::Fragile< + MutSt((::mockall::Fragile< Box #owned_output >> ), Option<#owned_output> ), @@ -1692,7 +1692,7 @@ impl<'a> ToTokens for RefMutRfunc<'a> { unreachable!() } }, - Rfunc::MutST(ref mut __mockall_f, ref mut __mockall_o)=> + Rfunc::MutSt(ref mut __mockall_f, ref mut __mockall_o)=> { *__mockall_o = Some((__mockall_f.get_mut())( #(#argnames, )*) @@ -1745,12 +1745,12 @@ impl<'a> ToTokens for StaticRfunc<'a> { Expired, Mut(Box #output + Send>), // Version of Rfunc::Mut for closures that aren't Send - MutST(::mockall::Fragile< + MutSt(::mockall::Fragile< Box #output >> ), Once(Box #output + Send>), // Version of Rfunc::Once for closure that aren't Send - OnceST(::mockall::Fragile< + OnceSt(::mockall::Fragile< Box #output>> ), // Prevent "unused type parameter" errors Surprisingly, @@ -1775,7 +1775,7 @@ impl<'a> ToTokens for StaticRfunc<'a> { Rfunc::Mut(__mockall_f) => { Ok(__mockall_f( #(#argnames, )* )) }, - Rfunc::MutST(__mockall_f) => { + Rfunc::MutSt(__mockall_f) => { Ok((__mockall_f.get_mut())(#(#argnames,)*)) }, Rfunc::Once(_) => { @@ -1786,8 +1786,8 @@ impl<'a> ToTokens for StaticRfunc<'a> { unreachable!() } }, - Rfunc::OnceST(_) => { - if let Rfunc::OnceST(mut __mockall_f) = + Rfunc::OnceSt(_) => { + if let Rfunc::OnceSt(mut __mockall_f) = mem::replace(self, Rfunc::Expired) { Ok((__mockall_f.into_inner())(#(#argnames,)*)) } else { @@ -1941,7 +1941,7 @@ impl<'a> ToTokens for RefMutExpectation<'a> { -> &mut Self where MockallF: FnMut(#(#argty, )*) -> #owned_output + 'static { - self.rfunc = Rfunc::MutST( + self.rfunc = Rfunc::MutSt( ::mockall::Fragile::new(Box::new(__mockall_f)), None); self } @@ -2078,7 +2078,7 @@ impl<'a> ToTokens for StaticExpectation<'a> { { { let mut __mockall_guard = self.rfunc.lock().unwrap(); - *__mockall_guard.deref_mut() = Rfunc::OnceST( + *__mockall_guard.deref_mut() = Rfunc::OnceSt( ::mockall::Fragile::new(Box::new(__mockall_f))); } self @@ -2113,7 +2113,7 @@ impl<'a> ToTokens for StaticExpectation<'a> { { { let mut __mockall_guard = self.rfunc.lock().unwrap(); - *__mockall_guard.deref_mut() = Rfunc::MutST( + *__mockall_guard.deref_mut() = Rfunc::MutSt( ::mockall::Fragile::new(Box::new(__mockall_f))); } self