Skip to content

Conversation

asomers
Copy link
Owner

@asomers asomers commented Apr 16, 2025

std::io::Read::read is often called with an uninitialized buffer as its argument. So Mockall shouldn't try to read from that buffer, even though the language rules allow it to. Previously, Mockall would try to read from it, in order to format a panic message in case no matching Expectation was found.

Now, Mockall will not try to format such a panic message preemptively. It will only do it if there actually isn't any matching Expectation. That also provides a small performance boost to all users.

Also, do a better job of clearing poison from static methods' Mutexes following a panic. Previously we would only do that if the user had created a Context object. Now we will do it regardless.

Fixes #647

std::io::Read::read is often called with an uninitialized buffer as its
argument.  So Mockall shouldn't try to read from that buffer, even
though the language rules allow it to.  Previously, Mockall would try to
read from it, in order to format a panic message in case no matching
Expectation was found.

Now, Mockall will not try to format such a panic message preemptively.
It will only do it if there actually isn't any matching Expectation.
That also provides a small performance boost to all users.

Also, do a better job of clearing poison from static methods' Mutexes
following a panic.  Previously we would only do that if the user had
created a Context object.  Now we will do it regardless.

Fixes #647
@asomers asomers merged commit 95f91d0 into master Apr 28, 2025
3 checks passed
@asomers asomers deleted the std-io-Read-read branch April 28, 2025 19:45
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.

Mockall will format function arguments too greedily
1 participant