-
Notifications
You must be signed in to change notification settings - Fork 68
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 mem::replace warning #124
Conversation
This PR fixes the following warning caused by not using the returned value from `mem::replace`. ``` warning: unused return value of `std::mem::replace` that must be used --> mockall_derive/src/lib.rs:519:21 | 519 | mem::replace(bt, new_bt); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: if you don't need the old value, you can just assign the new value directly warning: 1 warning emitted ```
mockall_derive/src/lib.rs
Outdated
@@ -516,7 +516,7 @@ fn supersuperfy(original: &Type, levels: i32) -> Type { | |||
Type::BareFn(bfn) => { | |||
if let ReturnType::Type(_, ref mut bt) = bfn.output { | |||
let new_bt = Box::new(supersuperfy(bt.as_ref(), levels)); | |||
mem::replace(bt, new_bt); | |||
let _ = mem::replace(bt, new_bt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could instead replace this with mem::swap
if you prefer 👍 but imho thought this was a bit more explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - should've seen that we could get rid of mem::replace
entirely
Thanks! But I haven't noticed this warning before. Is it a new one? What rustc version are you using? |
Warning displayed when running |
This PR fixes the following warning caused by not using the returned
value from
mem::replace
.