Import rustc_plugin from its new location

Depends on https://github.com/rust-lang/rust/pull/62727
This commit is contained in:
Simon Sapin 2019-08-19 17:51:39 +02:00
parent 918d609002
commit 08d8ffc6a9
4 changed files with 12 additions and 16 deletions

View file

@ -90,7 +90,7 @@ Clippy is a [rustc compiler plugin][compiler_plugin]. The main entry point is at
pub mod else_if_without_else; pub mod else_if_without_else;
// ... // ...
pub fn register_plugins(reg: &mut rustc_plugin::Registry) { pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry) {
// ... // ...
reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse); reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
// ... // ...
@ -103,7 +103,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
} }
``` ```
The [`rustc_plugin::PluginRegistry`][plugin_registry] provides two methods to register lints: [register_early_lint_pass][reg_early_lint_pass] and [register_late_lint_pass][reg_late_lint_pass]. The [`plugin::PluginRegistry`][plugin_registry] provides two methods to register lints: [register_early_lint_pass][reg_early_lint_pass] and [register_late_lint_pass][reg_late_lint_pass].
Both take an object that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in every single lint. Both take an object that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in every single lint.
It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `util/dev update_lints` and you don't have to add anything by hand. When you are writing your own lint, you can use that script to save you some time. It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `util/dev update_lints` and you don't have to add anything by hand. When you are writing your own lint, you can use that script to save you some time.
@ -193,9 +193,9 @@ or the [MIT](http://opensource.org/licenses/MIT) license.
[lint_crate_entry]: https://github.com/rust-lang/rust-clippy/blob/c5b39a5917ffc0f1349b6e414fa3b874fdcf8429/clippy_lints/src/lib.rs [lint_crate_entry]: https://github.com/rust-lang/rust-clippy/blob/c5b39a5917ffc0f1349b6e414fa3b874fdcf8429/clippy_lints/src/lib.rs
[else_if_without_else]: https://github.com/rust-lang/rust-clippy/blob/c5b39a5917ffc0f1349b6e414fa3b874fdcf8429/clippy_lints/src/else_if_without_else.rs [else_if_without_else]: https://github.com/rust-lang/rust-clippy/blob/c5b39a5917ffc0f1349b6e414fa3b874fdcf8429/clippy_lints/src/else_if_without_else.rs
[compiler_plugin]: https://doc.rust-lang.org/unstable-book/language-features/plugin.html#lint-plugins [compiler_plugin]: https://doc.rust-lang.org/unstable-book/language-features/plugin.html#lint-plugins
[plugin_registry]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin/registry/struct.Registry.html [plugin_registry]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin_impl/registry/struct.Registry.html
[reg_early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin/registry/struct.Registry.html#method.register_early_lint_pass [reg_early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin_impl/registry/struct.Registry.html#method.register_early_lint_pass
[reg_late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin/registry/struct.Registry.html#method.register_late_lint_pass [reg_late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin_impl/registry/struct.Registry.html#method.register_late_lint_pass
[early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.EarlyLintPass.html [early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.EarlyLintPass.html
[late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.LateLintPass.html [late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.LateLintPass.html
[toolstate_commit_history]: https://github.com/rust-lang-nursery/rust-toolstate/commits/master [toolstate_commit_history]: https://github.com/rust-lang-nursery/rust-toolstate/commits/master

View file

@ -23,12 +23,12 @@ extern crate rustc;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_data_structures; extern crate rustc_data_structures;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_driver;
#[allow(unused_extern_crates)]
extern crate rustc_errors; extern crate rustc_errors;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_mir; extern crate rustc_mir;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_plugin;
#[allow(unused_extern_crates)]
extern crate rustc_target; extern crate rustc_target;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_typeck; extern crate rustc_typeck;
@ -320,7 +320,7 @@ pub fn register_pre_expansion_lints(
} }
#[doc(hidden)] #[doc(hidden)]
pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf { pub fn read_conf(reg: &rustc_driver::plugin::Registry<'_>) -> Conf {
match utils::conf::file_from_args(reg.args()) { match utils::conf::file_from_args(reg.args()) {
Ok(file_name) => { Ok(file_name) => {
// if the user specified a file, it must exist, otherwise default to `clippy.toml` but // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
@ -382,7 +382,7 @@ pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
/// Used in `./src/driver.rs`. /// Used in `./src/driver.rs`.
#[allow(clippy::too_many_lines)] #[allow(clippy::too_many_lines)]
#[rustfmt::skip] #[rustfmt::skip]
pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Conf) {
let mut store = reg.sess.lint_store.borrow_mut(); let mut store = reg.sess.lint_store.borrow_mut();
register_removed_non_tool_lints(&mut store); register_removed_non_tool_lints(&mut store);

View file

@ -7,8 +7,6 @@
extern crate rustc_driver; extern crate rustc_driver;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_interface; extern crate rustc_interface;
#[allow(unused_extern_crates)]
extern crate rustc_plugin;
use rustc_interface::interface; use rustc_interface::interface;
use rustc_tools_util::*; use rustc_tools_util::*;
@ -65,7 +63,7 @@ struct ClippyCallbacks;
impl rustc_driver::Callbacks for ClippyCallbacks { impl rustc_driver::Callbacks for ClippyCallbacks {
fn after_parsing(&mut self, compiler: &interface::Compiler) -> rustc_driver::Compilation { fn after_parsing(&mut self, compiler: &interface::Compiler) -> rustc_driver::Compilation {
let sess = compiler.session(); let sess = compiler.session();
let mut registry = rustc_plugin::registry::Registry::new( let mut registry = rustc_driver::plugin::registry::Registry::new(
sess, sess,
compiler compiler
.parse() .parse()
@ -81,7 +79,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
let conf = clippy_lints::read_conf(&registry); let conf = clippy_lints::read_conf(&registry);
clippy_lints::register_plugins(&mut registry, &conf); clippy_lints::register_plugins(&mut registry, &conf);
let rustc_plugin::registry::Registry { let rustc_driver::plugin::registry::Registry {
early_lint_passes, early_lint_passes,
late_lint_passes, late_lint_passes,
lint_groups, lint_groups,

View file

@ -7,9 +7,7 @@
// (Currently there is no way to opt into sysroot crates without `extern crate`.) // (Currently there is no way to opt into sysroot crates without `extern crate`.)
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate rustc_driver; extern crate rustc_driver;
#[allow(unused_extern_crates)] use self::rustc_driver::plugin::Registry;
extern crate rustc_plugin;
use self::rustc_plugin::Registry;
#[plugin_registrar] #[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry<'_>) { pub fn plugin_registrar(reg: &mut Registry<'_>) {