]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
plugin mode still needs to work
[rust.git] / src / lib.rs
1 // error-pattern:cargo-clippy
2 #![feature(plugin_registrar)]
3 #![feature(rustc_private)]
4 #![allow(unknown_lints)]
5 #![feature(borrow_state)]
6
7 extern crate rustc_plugin;
8 use rustc_plugin::Registry;
9
10 extern crate clippy_lints;
11
12 pub use clippy_lints::*;
13
14 #[plugin_registrar]
15 pub fn plugin_registrar(reg: &mut Registry) {
16     if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
17         reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
18     } else {
19         register_plugins(reg);
20     }
21 }
22
23 // only exists to let the dogfood integration test works.
24 // Don't run clippy as an executable directly
25 #[allow(dead_code, print_stdout)]
26 fn main() {
27     panic!("Please use the cargo-clippy executable");
28 }