]> git.lizzy.rs Git - rust.git/blobdiff - src/lib.rs
deps: bump toml from 0.4 to 0.5
[rust.git] / src / lib.rs
index 9e83a96fee689e085ef0f66519d4cea6197d22c5..86174a6b316fc942663ef7122eb71b74a15f7bcd 100644 (file)
@@ -1,21 +1,34 @@
 // error-pattern:cargo-clippy
 #![feature(plugin_registrar)]
 #![feature(rustc_private)]
-#![allow(unknown_lints)]
-#![feature(borrow_state)]
+#![warn(rust_2018_idioms)]
 
+// FIXME: switch to something more ergonomic here, once available.
+// (Currently there is no way to opt into sysroot crates without `extern crate`.)
+#[allow(unused_extern_crates)]
+extern crate rustc_driver;
+#[allow(unused_extern_crates)]
 extern crate rustc_plugin;
-use rustc_plugin::Registry;
-
-extern crate clippy_lints;
+use self::rustc_plugin::Registry;
 
 #[plugin_registrar]
-pub fn plugin_registrar(reg: &mut Registry) {
-    if reg.sess.lint_store.borrow_state() == std::cell::BorrowState::Unused && reg.sess.lint_store.borrow().get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") {
-        reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit();
-    } else {
-        clippy_lints::register_plugins(reg);
-    }
+pub fn plugin_registrar(reg: &mut Registry<'_>) {
+    reg.sess.lint_store.with_read_lock(|lint_store| {
+        for (lint, _, _) in lint_store.get_lint_groups() {
+            reg.sess
+                .struct_warn(
+                    "the clippy plugin is being deprecated, please use cargo clippy or rls with the clippy feature",
+                )
+                .emit();
+            if lint == "clippy" {
+                // cargo clippy run on a crate that also uses the plugin
+                return;
+            }
+        }
+    });
+
+    let conf = clippy_lints::read_conf(reg);
+    clippy_lints::register_plugins(reg, &conf);
 }
 
 // only exists to let the dogfood integration test works.