mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Import rustc_plugin from its new location
Depends on https://github.com/rust-lang/rust/pull/62727
This commit is contained in:
parent
918d609002
commit
08d8ffc6a9
4 changed files with 12 additions and 16 deletions
|
@ -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 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);
|
||||
// ...
|
||||
|
@ -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.
|
||||
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
|
||||
[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
|
||||
[plugin_registry]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin/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_late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_plugin/registry/struct.Registry.html#method.register_late_lint_pass
|
||||
[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_impl/registry/struct.Registry.html#method.register_early_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
|
||||
[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
|
||||
|
|
|
@ -23,12 +23,12 @@ extern crate rustc;
|
|||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_data_structures;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_driver;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_errors;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_mir;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_plugin;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_target;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_typeck;
|
||||
|
@ -320,7 +320,7 @@ pub fn register_pre_expansion_lints(
|
|||
}
|
||||
|
||||
#[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()) {
|
||||
Ok(file_name) => {
|
||||
// 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`.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[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();
|
||||
register_removed_non_tool_lints(&mut store);
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
extern crate rustc_driver;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_interface;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc_interface::interface;
|
||||
use rustc_tools_util::*;
|
||||
|
@ -65,7 +63,7 @@ struct ClippyCallbacks;
|
|||
impl rustc_driver::Callbacks for ClippyCallbacks {
|
||||
fn after_parsing(&mut self, compiler: &interface::Compiler) -> rustc_driver::Compilation {
|
||||
let sess = compiler.session();
|
||||
let mut registry = rustc_plugin::registry::Registry::new(
|
||||
let mut registry = rustc_driver::plugin::registry::Registry::new(
|
||||
sess,
|
||||
compiler
|
||||
.parse()
|
||||
|
@ -81,7 +79,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
|
|||
let conf = clippy_lints::read_conf(®istry);
|
||||
clippy_lints::register_plugins(&mut registry, &conf);
|
||||
|
||||
let rustc_plugin::registry::Registry {
|
||||
let rustc_driver::plugin::registry::Registry {
|
||||
early_lint_passes,
|
||||
late_lint_passes,
|
||||
lint_groups,
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
// (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 self::rustc_plugin::Registry;
|
||||
use self::rustc_driver::plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry<'_>) {
|
||||
|
|
Loading…
Reference in a new issue