Skip to content

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
@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.

2 participants