diff --git a/crates/toml_edit_fuzz/parse_document.rs b/crates/toml_edit_fuzz/parse_document.rs index 018eccdc..9bc0fed5 100644 --- a/crates/toml_edit_fuzz/parse_document.rs +++ b/crates/toml_edit_fuzz/parse_document.rs @@ -5,19 +5,23 @@ use toml_edit::DocumentMut; libfuzzer_sys::fuzz_target!(|data| { if let Ok(data) = std::str::from_utf8(data) { println!("parsing: {data:?}"); - let doc = data.parse::(); - if let Ok(doc) = doc { - let toml = doc.to_string(); - println!("parsing: {toml:?}"); - let doc = toml.parse::(); - assert!( - doc.is_ok(), - "Failed to parse `doc.to_string()`: {}\n```\n{}\n```", - doc.unwrap_err(), - toml - ); - let doc = doc.unwrap(); - assert_eq!(doc.to_string(), toml); - } + let doc = match data.parse::() { + Ok(doc) => doc, + Err(err) => { + println!("{err}"); + return; + } + }; + let toml = doc.to_string(); + println!("parsing: {toml:?}"); + let doc = toml.parse::(); + assert!( + doc.is_ok(), + "Failed to parse `doc.to_string()`: {}\n```\n{}\n```", + doc.unwrap_err(), + toml + ); + let doc = doc.unwrap(); + assert_eq!(doc.to_string(), toml); } });