]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
Merge branch 'master' of github.com:rust-lang-nursery/rust-clippy
[rust.git] / src / lib.rs
1 // error-pattern:cargo-clippy
2 #![feature(plugin_registrar)]
3 #![feature(rustc_private)]
4 #![feature(macro_vis_matcher)]
5 #![allow(unknown_lints)]
6 #![allow(missing_docs_in_private_items)]
7
8 extern crate rustc_plugin;
9 use rustc_plugin::Registry;
10
11 extern crate clippy_lints;
12
13 #[plugin_registrar]
14 pub fn plugin_registrar(reg: &mut Registry) {
15     if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
16         for (lint, _, _) in lint_store.get_lint_groups() {
17             if lint == "clippy" {
18                 reg.sess
19                     .struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
20                     .emit();
21                 return;
22             }
23         }
24     }
25
26     clippy_lints::register_plugins(reg);
27 }
28
29 // only exists to let the dogfood integration test works.
30 // Don't run clippy as an executable directly
31 #[allow(dead_code)]
32 fn main() {
33     panic!("Please use the cargo-clippy executable");
34 }