forked from BurntSushi/quickcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Do recursive shrinking without recursive function calls #1
Open
neithernut
wants to merge
25
commits into
cloudhead:master
Choose a base branch
from
neithernut:non-recursive-shrinking
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
... so that memchr builds. Sigh.
* Shut up non_fmt_panic warning Like a few other macros, `panic!` accepts a format string and arguments. The format string is meant to be static and calling it with a message string will generate a warning. Currently, the warning also indicates that `rustc` will generate an error instead in the near future. * Eliminate redundant format! in panic! The `panic!` matro itself does take a foramt string. In fact, the redundant format generated a warning.
… crates.io badge (BurntSushi#309) * Use SPDX license format and remove outdated Travis CI reference * Fix crates.io badge
Currently https://docs.rs/quickcheck doesn't say much about what this crate does. I think having most info in the README is OK, but probably there should be some info in the crate docs root as well.
Required by `env_logger` crate
We try to shrink values recursively, i.e. when a shrunk value witnesses a failure, we'd shrink that value further. Previously, this recursion would be implemented via actual control flow recursion, i.e. a function calling itself. Since the recursion could not be unrolled by the compiler, this could result in stack overflows in some situations. Albeit such an overflow would often hint at a faulty shrinker (e.g. a shrinker yielding the original value), the stack overflow could also occur in other situations. This change switches from a recursive control flow to explicitly swapping out the shrinking iterator during the iteration.
In the past, shrinking was implemented using recursion in the control flow. `shrink_failure` would call itself. That function was introduced originally in 5b19e7c presumably in order to implement recursive shrinking. However, we recently choose an approach which would not rely on recursive control flow but on swapping out an iterator. Thus, the reason why `shrink_failure` existed in the first place doesn't exist any more. This change moves the logic in its original place, but also replaces the `match` which enclosed the call to `shrink_failure` with an `if`.
61ae277
to
d930487
Compare
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.
Originally BurntSushi#294