mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 14:38:46 +00:00
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,
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue