Skip to content
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

Allow "closure" body to be any expression, not only block #105

Merged
merged 1 commit into from Mar 27, 2023

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Mar 27, 2023

The fuzz_target! macro's input is designed to follow Rust's closure syntax, and mimics nearly all the syntax features of Rust closures: optional argument type, optional return type.

However, it diverged from Rust closures in requiring the body of the "closure" to always be surrounded in curly braces, due to the use of $:block.

I had a fuzz target where I had to end up doing the following:

fuzz_target!(|bytes: &[u8]| { do_fuzz(bytes, true) });

The braces here diverge from how the equivalent closure would ordinarily be written. Punctuation which is required but doesn't serve a purpose detracts from the readability of the program.

This PR makes the braces around a "closure" body optional.

fuzz_target!(|bytes: &[u8]| do_fuzz(bytes, true));

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fitzgen fitzgen merged commit df3ac96 into rust-fuzz:main Mar 27, 2023
1 check passed
@dtolnay dtolnay deleted the body branch March 27, 2023 23:24
dtolnay added a commit to dtolnay/proc-macro2 that referenced this pull request Aug 11, 2023
dtolnay added a commit to dtolnay/unsafe-libyaml that referenced this pull request Aug 11, 2023
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.

None yet

2 participants