Merge pull request #1171 from oli-obk/examples
also run clippy on examples, tests and benchmarks
This commit is contained in:
commit
9963a2c78c
11
src/lib.rs
11
src/lib.rs
@ -2,6 +2,7 @@
|
||||
#![feature(plugin_registrar)]
|
||||
#![feature(rustc_private)]
|
||||
#![allow(unknown_lints)]
|
||||
#![feature(borrow_state)]
|
||||
#![allow(missing_docs_in_private_items)]
|
||||
|
||||
extern crate rustc_plugin;
|
||||
@ -9,16 +10,18 @@ use rustc_plugin::Registry;
|
||||
|
||||
extern crate clippy_lints;
|
||||
|
||||
pub use clippy_lints::*;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
register_plugins(reg);
|
||||
if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
|
||||
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
|
||||
} else {
|
||||
clippy_lints::register_plugins(reg);
|
||||
}
|
||||
}
|
||||
|
||||
// only exists to let the dogfood integration test works.
|
||||
// Don't run clippy as an executable directly
|
||||
#[allow(dead_code, print_stdout)]
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
panic!("Please use the cargo-clippy executable");
|
||||
}
|
||||
|
@ -148,8 +148,8 @@ pub fn main() {
|
||||
if let Err(code) = process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
} else if first == "bin" {
|
||||
if let Err(code) = process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root) {
|
||||
} else if ["bin", "example", "test", "bench"].contains(&&**first) {
|
||||
if let Err(code) = process(vec![format!("--{}", first), target.name].into_iter().chain(args), &dep_path, &sys_root) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#[allow(plugin_as_library)]
|
||||
extern crate clippy;
|
||||
extern crate clippy_lints;
|
||||
|
||||
use clippy::utils::{camel_case_from, camel_case_until};
|
||||
use clippy_lints::utils::{camel_case_from, camel_case_until};
|
||||
|
||||
#[test]
|
||||
fn from_full() {
|
||||
|
@ -6,7 +6,7 @@ use std::env::{set_var, var};
|
||||
fn run_mode(dir: &'static str, mode: &'static str) {
|
||||
let mut config = compiletest::default_config();
|
||||
|
||||
let cfg_mode = mode.parse().ok().expect("Invalid mode");
|
||||
let cfg_mode = mode.parse().expect("Invalid mode");
|
||||
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps".to_owned());
|
||||
if let Ok(name) = var::<&str>("TESTNAME") {
|
||||
let s: String = name.to_owned();
|
||||
|
@ -1,13 +1,12 @@
|
||||
#![allow(plugin_as_library)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate clippy;
|
||||
extern crate clippy_lints;
|
||||
extern crate rustc;
|
||||
extern crate rustc_const_eval;
|
||||
extern crate rustc_const_math;
|
||||
extern crate syntax;
|
||||
|
||||
use clippy::consts::{constant_simple, Constant, FloatWidth};
|
||||
use clippy_lints::consts::{constant_simple, Constant, FloatWidth};
|
||||
use rustc_const_math::ConstInt;
|
||||
use rustc::hir::*;
|
||||
use syntax::ast::{LitIntType, LitKind, StrStyle};
|
||||
|
@ -1,16 +1,15 @@
|
||||
#![allow(plugin_as_library)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate clippy;
|
||||
extern crate clippy_lints;
|
||||
extern crate syntax;
|
||||
|
||||
#[test]
|
||||
fn test_overlapping() {
|
||||
use clippy::matches::overlapping;
|
||||
use clippy_lints::matches::overlapping;
|
||||
use syntax::codemap::DUMMY_SP;
|
||||
|
||||
let sp = |s, e| {
|
||||
clippy::matches::SpannedRange {
|
||||
clippy_lints::matches::SpannedRange {
|
||||
span: DUMMY_SP,
|
||||
node: (s, e),
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/// test the multiline-trim function
|
||||
#[allow(plugin_as_library)]
|
||||
extern crate clippy;
|
||||
extern crate clippy_lints;
|
||||
|
||||
use clippy::utils::trim_multiline;
|
||||
use clippy_lints::utils::trim_multiline;
|
||||
|
||||
#[test]
|
||||
fn test_single_line() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user