prevent cc lint from panicking on unreachable code
This commit is contained in:
parent
eed9baa4fb
commit
d5a01e8789
2 changed files with 10 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue