Skip to content

Commit

Permalink
update test file format
Browse files Browse the repository at this point in the history
  • Loading branch information
sskeirik committed Jun 25, 2024
1 parent a0eccf9 commit 8184e2d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/ui-fulldeps/stable-mir/smir_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ use serde_json::to_string;
const CRATE_NAME: &str = "input";

fn serialize_to_json(_tcx: TyCtxt<'_>) -> ControlFlow<()> {
let path = "output.json";
let mut writer = BufWriter::new(std::fs::File::create(path).expect("Failed to create path"));
let local_crate = stable_mir::local_crate();
let items: Vec<Body> = stable_mir::all_local_items().iter().map(|item| { item.body() }).collect();
let crate_data = ( local_crate.name, items );
writer.write_all(to_string(&crate_data).expect("serde_json failed").as_bytes()).expect("JSON serialization failed");
ControlFlow::Continue(())
let path = "output.json";
let mut writer = BufWriter::new(std::fs::File::create(path)
.expect("Failed to create path"));
let local_crate = stable_mir::local_crate();
let items: Vec<Body> = stable_mir::all_local_items()
.iter()
.map(|item| { item.body() })
.collect();
let crate_data = ( local_crate.name, items );
writer.write_all(to_string(&crate_data)
.expect("serde_json failed")
.as_bytes()).expect("JSON serialization failed");
ControlFlow::Continue(())
}

/// This test will generate and analyze a dummy crate using the stable mir.
Expand Down

0 comments on commit 8184e2d

Please sign in to comment.