Merge pull request #1317 from oli-obk/cc_attr_used_fixed

mark cyclomatic complexity attribute as used
This commit is contained in:
Martin Carton 2016-11-02 18:25:38 +01:00 committed by GitHub
commit aa8ca9b607
3 changed files with 20 additions and 4 deletions

View File

@ -575,14 +575,14 @@ impl LimitStack {
fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'static str, mut f: F) {
for attr in attrs {
let attr = &attr.node;
if attr.is_sugared_doc {
if attr.node.is_sugared_doc {
continue;
}
if let ast::MetaItemKind::NameValue(ref key, ref value) = attr.value.node {
if let ast::MetaItemKind::NameValue(ref key, ref value) = attr.node.value.node {
if *key == name {
if let LitKind::Str(ref s, _) = value.node {
if let Ok(value) = FromStr::from_str(s) {
attr::mark_used(attr);
f(value)
} else {
sess.span_err(value.span, "not a number");

View File

@ -4,7 +4,6 @@
#![deny(cyclomatic_complexity)]
#![allow(unused)]
fn main() { //~ERROR the function has a cyclomatic complexity of 28
if true {
println!("a");

View File

@ -0,0 +1,17 @@
#![feature(plugin, custom_attribute)]
#![plugin(clippy)]
#![deny(cyclomatic_complexity)]
#![deny(unused)]
fn main() {
kaboom();
}
#[cyclomatic_complexity = "0"]
fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3
if 42 == 43 {
panic!();
} else if "cake" == "lie" {
println!("what?");
}
}