Test signatures for functions that only accept 'static borrows - #21
Merged
Merged
Conversation
Since the signature check change, a safe mock! or replace! signature cannot declare a 'static borrowed input, even for a function that only accepts 'static borrows; such functions use an unsafe fn signature. Only mock! had a test for that form, and neither macro documented the rejection. Two compile_fail doctests now show that a safe fn(&'static str) signature is rejected for such a function, one for mock! and one for replace!. tests/replacement.rs gains a test that replaces one through unsafe fn(&'static str) -> usize and checks that the replacement kept its 'static argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds tests for functions that only take
'staticborrows.Since #19,
mock!andreplace!reject a safe signature likefn(&'static str)for these functions. They needunsafe fn(&'static str).mock!andreplace!docs: acompile_failexample for the rejected signature.tests/replacement.rs:replace!works withunsafe fn(&'static str) -> usize.Both doctests fail with the lifetime error when compiled alone. CI passes.