2018-10-06 16:18:06 +00:00
|
|
|
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2016-05-24 16:25:25 +00:00
|
|
|
// error-pattern:cargo-clippy
|
2016-06-06 15:09:51 +00:00
|
|
|
#![feature(plugin_registrar)]
|
|
|
|
#![feature(rustc_private)]
|
2018-08-01 20:48:41 +00:00
|
|
|
#![allow(clippy::missing_docs_in_private_items)]
|
2018-06-25 18:50:20 +00:00
|
|
|
#![warn(rust_2018_idioms)]
|
2016-03-23 11:19:13 +00:00
|
|
|
|
2018-09-15 07:21:58 +00:00
|
|
|
// FIXME: switch to something more ergonomic here, once available.
|
|
|
|
// (currently there is no way to opt into sysroot crates w/o `extern crate`)
|
|
|
|
#[allow(unused_extern_crates)]
|
2018-12-19 19:41:27 +00:00
|
|
|
extern crate rustc_driver;
|
|
|
|
#[allow(unused_extern_crates)]
|
2018-09-15 07:21:58 +00:00
|
|
|
extern crate rustc_plugin;
|
|
|
|
use self::rustc_plugin::Registry;
|
2014-11-19 08:57:34 +00:00
|
|
|
|
|
|
|
#[plugin_registrar]
|
2018-07-23 11:01:12 +00:00
|
|
|
pub fn plugin_registrar(reg: &mut Registry<'_>) {
|
2018-04-18 18:25:43 +00:00
|
|
|
reg.sess.lint_store.with_read_lock(|lint_store| {
|
2017-08-09 07:59:38 +00:00
|
|
|
for (lint, _, _) in lint_store.get_lint_groups() {
|
2018-05-11 11:20:39 +00:00
|
|
|
reg.sess
|
2018-05-22 08:21:42 +00:00
|
|
|
.struct_warn(
|
|
|
|
"the clippy plugin is being deprecated, please use cargo clippy or rls with the clippy feature",
|
|
|
|
)
|
2018-05-11 11:20:39 +00:00
|
|
|
.emit();
|
2017-08-09 07:59:38 +00:00
|
|
|
if lint == "clippy" {
|
2018-05-11 11:20:39 +00:00
|
|
|
// cargo clippy run on a crate that also uses the plugin
|
2017-08-09 07:59:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-12-19 19:22:38 +00:00
|
|
|
}
|
2018-04-18 18:25:43 +00:00
|
|
|
});
|
2016-12-19 19:22:38 +00:00
|
|
|
|
2018-08-15 06:11:07 +00:00
|
|
|
let conf = clippy_lints::read_conf(reg);
|
|
|
|
clippy_lints::register_plugins(reg, &conf);
|
2016-05-24 16:25:25 +00:00
|
|
|
}
|
2015-08-21 15:11:34 +00:00
|
|
|
|
2016-05-24 16:25:25 +00:00
|
|
|
// only exists to let the dogfood integration test works.
|
|
|
|
// Don't run clippy as an executable directly
|
2016-08-17 16:35:25 +00:00
|
|
|
#[allow(dead_code)]
|
2016-05-24 16:25:25 +00:00
|
|
|
fn main() {
|
|
|
|
panic!("Please use the cargo-clippy executable");
|
2014-12-10 21:34:58 +00:00
|
|
|
}
|