Skip to content

Commit

Permalink
Merge pull request #255 from asomers/clippy-2.52.0
Browse files Browse the repository at this point in the history
Fix Clippy warnings in generated code with Rust nightly 1.52.0
  • Loading branch information
asomers authored Feb 13, 2021
2 parents fb50ec5 + 06ca096 commit f04c641
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions mockall_derive/src/mock_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
}
Expand Down Expand Up @@ -1522,7 +1522,7 @@ impl<'a> ToTokens for Matcher<'a> {
Always,
Func(Box<dyn #hrtb Fn(#( #refpredty, )*) -> bool + Send>),
// Version of Matcher::Func for closures that aren't Send
FuncST(::mockall::Fragile<Box<dyn #hrtb Fn(#( #refpredty, )*) -> bool>>),
FuncSt(::mockall::Fragile<Box<dyn #hrtb Fn(#( #refpredty, )*) -> bool>>),
Pred(Box<(#preds)>),
// Prevent "unused type parameter" errors
// Surprisingly, PhantomData<Fn(generics)> is Send even if
Expand All @@ -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]
Expand All @@ -1561,7 +1561,7 @@ impl<'a> ToTokens for Matcher<'a> {
match self {
Matcher::Always => write!(__mockall_fmt, "<anything>"),
Matcher::Func(_) => write!(__mockall_fmt, "<function>"),
Matcher::FuncST(_) => write!(__mockall_fmt, "<single threaded function>"),
Matcher::FuncSt(_) => write!(__mockall_fmt, "<single threaded function>"),
Matcher::Pred(__mockall_p) => {
write!(__mockall_fmt, #braces,
#(__mockall_p.#indices,)*)
Expand Down Expand Up @@ -1661,7 +1661,7 @@ impl<'a> ToTokens for RefMutRfunc<'a> {
Mut((Box<dyn FnMut(#(#argty, )*) -> #owned_output + Send + Sync>),
Option<#owned_output>),
// Version of Rfunc::Mut for closures that aren't Send
MutST((::mockall::Fragile<
MutSt((::mockall::Fragile<
Box<dyn FnMut(#(#argty, )*) -> #owned_output >>
), Option<#owned_output>
),
Expand Down Expand Up @@ -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, )*)
Expand Down Expand Up @@ -1745,12 +1745,12 @@ impl<'a> ToTokens for StaticRfunc<'a> {
Expired,
Mut(Box<dyn #hrtb FnMut(#(#argty, )*) -> #output + Send>),
// Version of Rfunc::Mut for closures that aren't Send
MutST(::mockall::Fragile<
MutSt(::mockall::Fragile<
Box<dyn #hrtb FnMut(#(#argty, )*) -> #output >>
),
Once(Box<dyn #hrtb FnOnce(#(#argty, )*) -> #output + Send>),
// Version of Rfunc::Once for closure that aren't Send
OnceST(::mockall::Fragile<
OnceSt(::mockall::Fragile<
Box<dyn #hrtb FnOnce(#(#argty, )*) -> #output>>
),
// Prevent "unused type parameter" errors Surprisingly,
Expand All @@ -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(_) => {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f04c641

Please sign in to comment.