Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more warnings about mem::replace on latest nightly #125

Merged
merged 1 commit into from
May 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions mockall_derive/src/expectation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,26 +522,26 @@ impl<'a> Expectation<'a> {
fn with<#with_generics>(&mut self, #with_args)
{
let mut __mockall_guard = self.matcher.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(),
Matcher::Pred(Box::new((#boxed_withargs))));
*__mockall_guard.deref_mut() =
Matcher::Pred(Box::new((#boxed_withargs)));
}

fn withf<MockallF>(&mut self, __mockall_f: MockallF)
where MockallF: #hrtb Fn(#refpredty)
-> bool + Send + 'static
{
let mut __mockall_guard = self.matcher.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(),
Matcher::Func(Box::new(__mockall_f)));
*__mockall_guard.deref_mut() =
Matcher::Func(Box::new(__mockall_f));
}

fn withf_st<MockallF>(&mut self, __mockall_f: MockallF)
where MockallF: #hrtb Fn(#refpredty)
-> bool + 'static
{
let mut __mockall_guard = self.matcher.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(),
Matcher::FuncST(::mockall::Fragile::new(Box::new(__mockall_f))));
*__mockall_guard.deref_mut() =
Matcher::FuncST(::mockall::Fragile::new(Box::new(__mockall_f)));
}

fn verify_sequence(&self) {
Expand Down Expand Up @@ -827,8 +827,8 @@ impl<'a> StaticExpectation<'a> {
{
{
let mut __mockall_guard = self.rfunc.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(),
Rfunc::Once(Box::new(__mockall_f)));
*__mockall_guard.deref_mut() =
Rfunc::Once(Box::new(__mockall_f));
}
self
}
Expand All @@ -848,8 +848,8 @@ impl<'a> StaticExpectation<'a> {
{
{
let mut __mockall_guard = self.rfunc.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(), Rfunc::OnceST(
::mockall::Fragile::new(Box::new(__mockall_f))));
*__mockall_guard.deref_mut() = Rfunc::OnceST(
::mockall::Fragile::new(Box::new(__mockall_f)));
}
self
}
Expand All @@ -864,8 +864,8 @@ impl<'a> StaticExpectation<'a> {
{
{
let mut __mockall_guard = self.rfunc.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(),
Rfunc::Mut(Box::new(__mockall_f)));
*__mockall_guard.deref_mut() =
Rfunc::Mut(Box::new(__mockall_f));
}
self
}
Expand All @@ -883,9 +883,8 @@ impl<'a> StaticExpectation<'a> {
{
{
let mut __mockall_guard = self.rfunc.lock().unwrap();
mem::replace(__mockall_guard.deref_mut(), Rfunc::MutST(
::mockall::Fragile::new(Box::new(__mockall_f)))
);
*__mockall_guard.deref_mut() = Rfunc::MutST(
::mockall::Fragile::new(Box::new(__mockall_f)));
}
self
}
Expand Down Expand Up @@ -1575,7 +1574,7 @@ impl<'a> RefExpectation<'a> {
#v fn return_const(&mut self, __mockall_o: #output)
-> &mut Self
{
mem::replace(&mut self.rfunc, Rfunc::Const(__mockall_o));
self.rfunc = Rfunc::Const(__mockall_o);
self
}

Expand Down Expand Up @@ -1777,7 +1776,7 @@ impl<'a> RefMutExpectation<'a> {
/// reference.
#v fn return_var(&mut self, __mockall_o: #output) -> &mut Self
{
mem::replace(&mut self.rfunc, Rfunc::Var(__mockall_o));
self.rfunc = Rfunc::Var(__mockall_o);
self
}

Expand All @@ -1788,8 +1787,7 @@ impl<'a> RefMutExpectation<'a> {
-> &mut Self
where MockallF: FnMut(#(#argty, )*) -> #output + Send + Sync + 'static
{
mem::replace(&mut self.rfunc,
Rfunc::Mut(Box::new(__mockall_f), None));
self.rfunc = Rfunc::Mut(Box::new(__mockall_f), None);
self
}

Expand All @@ -1799,9 +1797,8 @@ impl<'a> RefMutExpectation<'a> {
-> &mut Self
where MockallF: FnMut(#(#argty, )*) -> #output + 'static
{
mem::replace(&mut self.rfunc, Rfunc::MutST(
::mockall::Fragile::new(Box::new(__mockall_f)), None)
);
self.rfunc = Rfunc::MutST(
::mockall::Fragile::new(Box::new(__mockall_f)), None);
self
}

Expand Down