Skip to content

Blog post on removing the Clippy plugin interface #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 4, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions posts/inside-rust/2019-10-24-Clippy-removes-plugin-interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout: post
title: "Clippy is removing its plugin interface"
author: Philipp Krones
description: "Now that compiler plugins are deprecated, Clippy is removing its deprecated plugin interface"
team: the Dev tools team (Clippy) <https://www.rust-lang.org/governance/teams/dev-tools#clippy>
---

Today, we're announcing that Clippy will completely remove its plugin interface.
Using the plugin interface has been deprecated for about one and a half year now
([rust-lang/rust-clippy#2712]). Since then, unsilenceable warning have been
emitted. Now that compiler plugins are officially deprecated
([rust-lang/rust#64675]), Clippy will remove its support for the plugin
interface completely ([rust-lang/rust-clippy#4714]).

[rust-lang/rust-clippy#2712]: https://github.com/rust-lang/rust-clippy/pull/2712
[rust-lang/rust#64675]: https://github.com/rust-lang/rust/pull/64675
[rust-lang/rust-clippy#4714]: https://github.com/rust-lang/rust-clippy/pull/4714

### How do I migrate from the plugin interface?

If you are still using the Clippy plugin interface, here are some steps you can
take to migrate to `cargo clippy`.

1. `Cargo.toml`: Remove every occurrence of the `clippy` dependency and the
`clippy` feature.
2. Completely remove every occurrence of `feature(plugin)` and `plugin(clippy)`.
3. Replace every occurrence of `feature = "clippy"` with `feature =
"cargo-clippy"`. The `cargo-clippy` feature is automatically enabled when
running `cargo clippy`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would typically be the wrong guidance. People used feature = "clippy" because the canonical lint suppression used to be:

#[cfg(feature = "clippy", allow(name_of_lint))]

The correct migration would be to a tool attr:

#[allow(clippy::name_of_lint)]

There might be remaining use cases for #[cfg(feature = "cargo-clippy")] but it would be extremely unusual, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already handled by rustc. Running cargo clippy on

#![cfg_attr(feature = "cargo-clippy", deny(if_not_else))]
// code ...

emits

warning: lint name `if_not_else` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
 --> src/main.rs:1:44
  |
1 | #![cfg_attr(feature = "cargo-clippy", deny(if_not_else))]
  |                                            ^^^^^^^^^^^ help: change it to: `clippy::if_not_else`
  |
  = note: `#[warn(renamed_and_removed_lints)]` on by default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I wanted to write a clippy lint, that detects cfg_attr(cargo-clippy) and suggests to remove this, but never got to finish this lint.

https://github.com/flip1995/rust-clippy/commits/cfg_attr_lint

4. CI: You now have to install Clippy via rustup, with `rustup component add
clippy`. Once it is installed you can just run `cargo clippy` (for more usage
instructions, see the [Clippy `README`]). Note that Clippy is not included in
every nightly, but you can check its availability on the [rustup components
history] page.

[Clippy `README`]: https://github.com/rust-lang/rust-clippy#usage
[rustup components history]: https://rust-lang.github.io/rustup-components-history/index.html

### Where should I go if I have more questions?

If you need help with migrating from the plugin interface, you can contact us
via [Discord] or open an issue on [GitHub].

[Discord]: https://discord.gg/vNNtpyD
[GitHub]: https://github.com/rust-lang/clippy/issues/new