diff --git a/Cargo.lock b/Cargo.lock index e7b8546..8c6048b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,51 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "arbitrary" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c38b6b6b79f671c25e1a3e785b7b82d7562ffc9cd3efdc98627e5668a2472490" + [[package]] name = "fuzz-rustc-ast" version = "0.1.0" +dependencies = [ + "arbitrary", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.88" +source = "git+https://github.com/Nilstrieb/syn?branch=arbitrary#a0860e2ae754ade1340683bc54e403540202484b" +dependencies = [ + "arbitrary", + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" diff --git a/Cargo.toml b/Cargo.toml index 01948e9..7fd3ae8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "fuzz-rustc-ast" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] +arbitrary = "1.1.0" +# fork of syn with the arbitrary trait impls +syn = { git = "https://github.com/Nilstrieb/syn", branch = "arbitrary", features = ["full", "arbitrary"] } + +[features] diff --git a/src/main.rs b/src/main.rs index e7a11a9..04a95d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,11 @@ +use arbitrary::Arbitrary; +use std::path::PathBuf; + fn main() { - println!("Hello, world!"); + let data = std::fs::read(PathBuf::from(file!()).parent().unwrap().join("Cargo.toml")).unwrap(); + let mut unstructured = arbitrary::Unstructured::new(&data); + + let ast = syn::Item::arbitrary(&mut unstructured); + + println!("{ast}"); }