mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 03:25:55 +00:00
Merge pull request #764 from oli-obk/fix/cc/multi_diverge
prevent cc lint from panicking on unreachable code
This commit is contained in:
commit
4fa6f49f74
@ -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…
Reference in New Issue
Block a user