prevent cc lint from panicking on unreachable code

This commit is contained in:
Oliver Schneider 2016-03-14 17:24:55 +01:00
parent eed9baa4fb
commit d5a01e8789
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");
}