]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
Merge pull request #3285 from devonhollowood/pedantic-dogfood-items-after-statements
[rust.git] / src / lib.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 // error-pattern:cargo-clippy
12 #![feature(plugin_registrar)]
13 #![feature(rustc_private)]
14 #![feature(tool_lints)]
15 #![allow(unknown_lints)]
16 #![allow(clippy::missing_docs_in_private_items)]
17 #![warn(rust_2018_idioms)]
18
19 // FIXME: switch to something more ergonomic here, once available.
20 // (currently there is no way to opt into sysroot crates w/o `extern crate`)
21 #[allow(unused_extern_crates)]
22 extern crate rustc_plugin;
23 use self::rustc_plugin::Registry;
24
25 #[plugin_registrar]
26 pub fn plugin_registrar(reg: &mut Registry<'_>) {
27     reg.sess.lint_store.with_read_lock(|lint_store| {
28         for (lint, _, _) in lint_store.get_lint_groups() {
29             reg.sess
30                 .struct_warn(
31                     "the clippy plugin is being deprecated, please use cargo clippy or rls with the clippy feature",
32                 )
33                 .emit();
34             if lint == "clippy" {
35                 // cargo clippy run on a crate that also uses the plugin
36                 return;
37             }
38         }
39     });
40
41     let conf = clippy_lints::read_conf(reg);
42     clippy_lints::register_plugins(reg, &conf);
43 }
44
45 // only exists to let the dogfood integration test works.
46 // Don't run clippy as an executable directly
47 #[allow(dead_code)]
48 fn main() {
49     panic!("Please use the cargo-clippy executable");
50 }