You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #236, if generic args are neither referenced in method arguments nor in the return type, it's not possible to set expectations for different types.
I've created a test case that shows the problem. The regular_impl test shows a regular trait implementation and passes. The generic_only test uses a mock!ed trait implementation along with expectations and panics:
thread 'generic_only' panicked at 'called Result::unwrap() on an Err value: TypeMismatch { expected: "[ONLY ON NIGHTLY]", found: "[ONLY ON NIGHTLY]" }'
Wow! That bug title's a mouthful. First of all, your panic message will be more informative if you build mockall with the nightly crate feature. Secondly, from Mockall's perspective that method isn't really generic at all. So the fact that mock.expect_foo::<T> even compiles indicates a bug. The expectation should be concrete. I'll fix it.
If the function's generic parameters appeared in neither input nor
return type, the Expectations object would not be parameterized on the
functions generic parameters. This wasn't really by design; it was
actually an artifact of Mockall's second incarnation, which used a
macro_rules! macro to generate the mock objects.
Fixing the problem is easy. It's a matter of removing the code that
tried to guess the generic parameters based on the functions arguments
and return types.
Fixes#269
@twz123 could you please test your application using Mockall at 274a539 ? And expect_foo isn't concrete after all; it should be generic just the way you wrote it.
Related to #236, if generic args are neither referenced in method arguments nor in the return type, it's not possible to set expectations for different types.
I've created a test case that shows the problem. The
regular_impl
test shows a regular trait implementation and passes. Thegeneric_only
test uses amock!
ed trait implementation along with expectations and panics:Following the code:
The text was updated successfully, but these errors were encountered: