fix(analysis-stats): divided by zero error

This commit is contained in:
Weihang Lo 2023-05-16 13:57:36 +01:00
parent 2f8cd66fb4
commit 77be56b691
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -227,7 +227,7 @@ fn run_data_layout(&self, db: &RootDatabase, adts: &[hir::Adt], verbosity: Verbo
fail += 1;
}
eprintln!("{:<20} {}", "Data layouts:", sw.elapsed());
eprintln!("Failed data layouts: {fail} ({}%)", fail * 100 / all);
eprintln!("Failed data layouts: {fail} ({}%)", percentage(fail, all));
report_metric("failed data layouts", fail, "#");
}
@ -254,7 +254,7 @@ fn run_const_eval(&self, db: &RootDatabase, consts: &[hir::Const], verbosity: Ve
fail += 1;
}
eprintln!("{:<20} {}", "Const evaluation:", sw.elapsed());
eprintln!("Failed const evals: {fail} ({}%)", fail * 100 / all);
eprintln!("Failed const evals: {fail} ({}%)", percentage(fail, all));
report_metric("failed const evals", fail, "#");
}
@ -280,7 +280,7 @@ fn run_mir_lowering(&self, db: &RootDatabase, funcs: &[Function], verbosity: Ver
fail += 1;
}
eprintln!("{:<20} {}", "MIR lowering:", sw.elapsed());
eprintln!("Mir failed bodies: {fail} ({}%)", fail * 100 / all);
eprintln!("Mir failed bodies: {fail} ({}%)", percentage(fail, all));
report_metric("mir failed bodies", fail, "#");
}