(path: &std::path::Path)
| 563 | } |
| 564 | |
| 565 | pub fn write_log(path: &std::path::Path) -> Result<()> { |
| 566 | let debug_log = if let Some(debug_log) = debug::log_finish() { |
| 567 | debug_log |
| 568 | } else { |
| 569 | return Err(anyhow!( |
| 570 | "debug log was started, but it cannot be found after compilation" |
| 571 | )); |
| 572 | }; |
| 573 | match path.extension().and_then(|s| s.to_str()) { |
| 574 | Some("json") => { |
| 575 | let file = BufWriter::new(File::create(path)?); |
| 576 | serde_json::to_writer(file, &debug_log)?; |
| 577 | } |
| 578 | Some("html") => { |
| 579 | let file = BufWriter::new(File::create(path)?); |
| 580 | debug::render_log_to_html(file, &debug_log)?; |
| 581 | } |
| 582 | _ => { |
| 583 | return Err(anyhow!("unknown debug log format for file {path:?}")); |
| 584 | } |
| 585 | } |
| 586 | Ok(()) |
| 587 | } |
| 588 | |
| 589 | fn drop_module_def(stmts: &mut Vec<pr::Stmt>, name: &str) { |
| 590 | stmts.retain(|x| x.kind.as_module_def().map_or(true, |m| m.name != name)); |
no test coverage detected