]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
fallout
[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 #[plugin_registrar]
13 pub fn plugin_registrar(reg: &mut Registry) {
14     if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
15         reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
16     } else {
17         clippy_lints::register_plugins(reg);
18     }
19 }
20
21 // only exists to let the dogfood integration test works.
22 // Don't run clippy as an executable directly
23 #[allow(dead_code)]
24 fn main() {
25     panic!("Please use the cargo-clippy executable");
26 }