]> git.lizzy.rs Git - rust.git/blob - src/lib.rs
Merge pull request #3465 from flip1995/rustfmt
[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 // error-pattern:cargo-clippy
11 #![feature(plugin_registrar)]
12 #![feature(rustc_private)]
13 #![allow(clippy::missing_docs_in_private_items)]
14 #![warn(rust_2018_idioms)]
15
16 // FIXME: switch to something more ergonomic here, once available.
17 // (currently there is no way to opt into sysroot crates w/o `extern crate`)
18 #[allow(unused_extern_crates)]
19 extern crate rustc_plugin;
20 use self::rustc_plugin::Registry;
21
22 #[plugin_registrar]
23 pub fn plugin_registrar(reg: &mut Registry<'_>) {
24     reg.sess.lint_store.with_read_lock(|lint_store| {
25         for (lint, _, _) in lint_store.get_lint_groups() {
26             reg.sess
27                 .struct_warn(
28                     "the clippy plugin is being deprecated, please use cargo clippy or rls with the clippy feature",
29                 )
30                 .emit();
31             if lint == "clippy" {
32                 // cargo clippy run on a crate that also uses the plugin
33                 return;
34             }
35         }
36     });
37
38     let conf = clippy_lints::read_conf(reg);
39     clippy_lints::register_plugins(reg, &conf);
40 }
41
42 // only exists to let the dogfood integration test works.
43 // Don't run clippy as an executable directly
44 #[allow(dead_code)]
45 fn main() {
46     panic!("Please use the cargo-clippy executable");
47 }