-
Notifications
You must be signed in to change notification settings - Fork 76
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
Improve derived recursion guard #111
Conversation
…as been invoked twice on empty input
What name clashes are possible, given that we add the type name to the recursion guard's name? |
})?; | ||
} | ||
|
||
let result = (|| { #expr })(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the immediately-invoked closure here to allow passing things like return 42
as expr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda. It is to stop ?
in #expr
from aborting the outer function before the recursion counter has been decreased again. Ugly hack in the absence of try blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks, makes sense.
#[derive(Arbitrary)]
struct Foo;
struct RECURSIVE_COUNT_Foo: i32 = 42; Sure, unlikely that anyone runs into this on accident, but since it's easy to prevent… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
As per your invitation.
Turns
into
I've also wrapped the thread local and impl in a
const _: () = {…};
to avoid name clashes. I have no idea whether that's the best way of doing it, but it's what serde does.