]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
Merge pull request #1975 from bjgill/clippy--all
[rust.git] / src / lib.rs
1 // error-pattern:cargo-clippy
2 #![feature(plugin_registrar)]
3 #![feature(rustc_private)]
4 #![allow(unknown_lints)]
5 #![allow(missing_docs_in_private_items)]
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 let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
15         for (lint, _, _) in lint_store.get_lint_groups() {
16             if lint == "clippy" {
17                 reg.sess
18                     .struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
19                     .emit();
20                 return;
21             }
22         }
23     }
24
25     clippy_lints::register_plugins(reg);
26 }
27
28 // only exists to let the dogfood integration test works.
29 // Don't run clippy as an executable directly
30 #[allow(dead_code)]
31 fn main() {
32     panic!("Please use the cargo-clippy executable");
33 }