diff --git a/Cargo.toml b/Cargo.toml index 611dbd9..9e985ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,16 @@ static = [] bitflags = "0.7.0" libc = "0.2.11" +[dependencies.clippy] + +version = "0.0.69" +optional = true + [build-dependencies] glob = "0.2.11" + +[build-dependencies.clippy] + +version = "0.0.69" +optional = true diff --git a/build.rs b/build.rs index 3453b45..90707a4 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,10 @@ +//! Finds and links to the required `libclang` libraries. + +#![cfg_attr(feature="clippy", feature(plugin))] +#![cfg_attr(feature="clippy", plugin(clippy))] +#![cfg_attr(feature="clippy", warn(clippy))] +#![cfg_attr(feature="clippy", allow(if_not_else, similar_names))] + extern crate glob; use std::env; @@ -121,7 +128,7 @@ fn get_llvm_libraries() -> Vec { if p.starts_with("-l") { Some(p[2..].into()) } else { - get_library_name(&Path::new(p)) + get_library_name(Path::new(p)) } }).collect() } diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..006bfc4 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["FreeBSD"] diff --git a/src/lib.rs b/src/lib.rs index fb51707..5b68fcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,11 @@ #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] +#![cfg_attr(feature="clippy", feature(plugin))] +#![cfg_attr(feature="clippy", plugin(clippy))] +#![cfg_attr(feature="clippy", warn(clippy))] +#![cfg_attr(feature="clippy", allow(if_not_else, similar_names))] + #[macro_use] extern crate bitflags; diff --git a/src/support.rs b/src/support.rs index 1b8e3dc..b550f23 100644 --- a/src/support.rs +++ b/src/support.rs @@ -85,7 +85,7 @@ fn run_clang(path: &Path, arguments: &[&str], stdout: bool) -> String { fn parse_version(path: &Path) -> CXVersion { let output = run_clang(path, &["--version"], true); let start = output.find("version ").unwrap() + 8; - let digits = output[start..].split_whitespace().nth(0).unwrap().split("."); + let digits = output[start..].split_whitespace().nth(0).unwrap().split('.'); let numbers = digits.map(|d| d.parse::().unwrap()).collect::>(); CXVersion { Major: numbers[0], Minor: numbers[1], Subminor: *numbers.get(2).unwrap_or(&0) } }