mark cyclomatic complexity attribute as used

fixes #1315
This commit is contained in:
Oliver Schneider 2016-11-02 10:29:57 +01:00
parent 0e1f065678
commit a56af73fd8
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
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?");
}
}