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

Need to deselfify mock method arguments #355

Closed
asomers opened this issue Feb 1, 2022 · 0 comments · Fixed by #373
Closed

Need to deselfify mock method arguments #355

asomers opened this issue Feb 1, 2022 · 0 comments · Fixed by #373
Labels
bug Something isn't working

Comments

@asomers
Copy link
Owner

asomers commented Feb 1, 2022

Mockall knows that if a mocked function's return type is Self, it should replace that with the mock type. See the various constructor tests in mockall/tests. But it doesn't currently perform that transformation for argument types, unless they're self. That comes up with methods like eq, which compare two arguments of Self type. It should. For example, neither of the functions here will compile successfully:

mock! {
    #[derive(Debug)]
    pub Foo {
        fn compare(&self, other: &Foo) -> bool;
    }
    impl PartialEq for Foo {
        fn eq(&self, other: &Self) -> bool;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant