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

Piotrmaks arg ptr #195

Merged
merged 4 commits into from
Sep 5, 2020
Merged

Piotrmaks arg ptr #195

merged 4 commits into from
Sep 5, 2020

Conversation

asomers
Copy link
Owner

@asomers asomers commented Sep 5, 2020

Mocking method with String or Vec arguments cause clippy::ptr_arg warning in user code:

#[automock]
trait Foo {
    fn foo(&self, x: String);
}
error: writing `&String` instead of `&str` involves a new object where a slice will do.
 --> mockall/tests/automock_string_arguments.rs:7:1
  |
7 | #[automock]
  | ^^^^^^^^^^^
  |
note: the lint level is defined here
 --> mockall/tests/automock_string_arguments.rs:3:9
  |
3 | #![deny(warnings)]
  |         ^^^^^^^^
  = note: `#[deny(clippy::ptr_arg)]` implied by `#[deny(warnings)]`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
  = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

This PR silences the warning.

Fixes #58 .

p3s and others added 4 commits September 5, 2020 11:23
* There is no need to duplicate the tests for both automock and mock!.
  Especially since version 0.8.0, there is less duplicated code, and
  most features don't need to be tested both ways.

* Test with as well as withf

* Add other Deref types to the test
@asomers asomers merged commit 99677a9 into master Sep 5, 2020
@asomers asomers deleted the piotrmaks-arg-ptr branch September 5, 2020 18:58
asomers added a commit that referenced this pull request Sep 5, 2020
asomers added a commit that referenced this pull request Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In predicate functions, use deref()ed type for argument types that are Deref
2 participants