Skip to content

Commit 9963a2c

Browse files
authored
Merge pull request #1171 from oli-obk/examples
also run clippy on examples, tests and benchmarks
2 parents 5f1120b + c89c5d2 commit 9963a2c

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22
#![feature(plugin_registrar)]
33
#![feature(rustc_private)]
44
#![allow(unknown_lints)]
5+
#![feature(borrow_state)]
56
#![allow(missing_docs_in_private_items)]
67

78
extern crate rustc_plugin;
89
use rustc_plugin::Registry;
910

1011
extern crate clippy_lints;
1112

12-
pub use clippy_lints::*;
13-
1413
#[plugin_registrar]
1514
pub fn plugin_registrar(reg: &mut Registry) {
16-
register_plugins(reg);
15+
if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
16+
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
17+
} else {
18+
clippy_lints::register_plugins(reg);
19+
}
1720
}
1821

1922
// only exists to let the dogfood integration test works.
2023
// Don't run clippy as an executable directly
21-
#[allow(dead_code, print_stdout)]
24+
#[allow(dead_code)]
2225
fn main() {
2326
panic!("Please use the cargo-clippy executable");
2427
}

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ pub fn main() {
148148
if let Err(code) = process(std::iter::once("--lib".to_owned()).chain(args), &dep_path, &sys_root) {
149149
std::process::exit(code);
150150
}
151-
} else if first == "bin" {
152-
if let Err(code) = process(vec!["--bin".to_owned(), target.name].into_iter().chain(args), &dep_path, &sys_root) {
151+
} else if ["bin", "example", "test", "bench"].contains(&&**first) {
152+
if let Err(code) = process(vec![format!("--{}", first), target.name].into_iter().chain(args), &dep_path, &sys_root) {
153153
std::process::exit(code);
154154
}
155155
}

tests/camel_case.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#[allow(plugin_as_library)]
2-
extern crate clippy;
1+
extern crate clippy_lints;
32

4-
use clippy::utils::{camel_case_from, camel_case_until};
3+
use clippy_lints::utils::{camel_case_from, camel_case_until};
54

65
#[test]
76
fn from_full() {

tests/compile-test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::env::{set_var, var};
66
fn run_mode(dir: &'static str, mode: &'static str) {
77
let mut config = compiletest::default_config();
88

9-
let cfg_mode = mode.parse().ok().expect("Invalid mode");
9+
let cfg_mode = mode.parse().expect("Invalid mode");
1010
config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps".to_owned());
1111
if let Ok(name) = var::<&str>("TESTNAME") {
1212
let s: String = name.to_owned();

tests/consts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
#![allow(plugin_as_library)]
21
#![feature(rustc_private)]
32

4-
extern crate clippy;
3+
extern crate clippy_lints;
54
extern crate rustc;
65
extern crate rustc_const_eval;
76
extern crate rustc_const_math;
87
extern crate syntax;
98

10-
use clippy::consts::{constant_simple, Constant, FloatWidth};
9+
use clippy_lints::consts::{constant_simple, Constant, FloatWidth};
1110
use rustc_const_math::ConstInt;
1211
use rustc::hir::*;
1312
use syntax::ast::{LitIntType, LitKind, StrStyle};

tests/matches.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#![allow(plugin_as_library)]
21
#![feature(rustc_private)]
32

4-
extern crate clippy;
3+
extern crate clippy_lints;
54
extern crate syntax;
65

76
#[test]
87
fn test_overlapping() {
9-
use clippy::matches::overlapping;
8+
use clippy_lints::matches::overlapping;
109
use syntax::codemap::DUMMY_SP;
1110

1211
let sp = |s, e| {
13-
clippy::matches::SpannedRange {
12+
clippy_lints::matches::SpannedRange {
1413
span: DUMMY_SP,
1514
node: (s, e),
1615
}

tests/trim_multiline.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/// test the multiline-trim function
2-
#[allow(plugin_as_library)]
3-
extern crate clippy;
2+
extern crate clippy_lints;
43

5-
use clippy::utils::trim_multiline;
4+
use clippy_lints::utils::trim_multiline;
65

76
#[test]
87
fn test_single_line() {

0 commit comments

Comments
 (0)