Merge pull request #764 from oli-obk/fix/cc/multi_diverge

prevent cc lint from panicking on unreachable code
This commit is contained in:
Martin Carton 2016-03-14 17:32:22 +01:00
commit 4fa6f49f74
2 changed files with 10 additions and 0 deletions

View File

@ -47,6 +47,10 @@ impl CyclomaticComplexity {
let cfg = CFG::new(cx.tcx, block);
let n = cfg.graph.len_nodes() as u64;
let e = cfg.graph.len_edges() as u64;
if e + 2 < n {
// the function has unreachable code, other lints should catch this
return;
}
let cc = e + 2 - n;
let mut helper = CCHelper {
match_arms: 0,

View File

@ -298,3 +298,9 @@ fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1
}
}
}
#[cyclomatic_complexity = "0"]
fn mcarton_sees_all() {
panic!("meh");
panic!("möh");
}