Skip to content

Commit 18a5b90

Browse files
authored
Merge pull request #2712 from rust-lang-nursery/oli-obk-patch-1
Deprecate plugin-clippy
2 parents 553b90b + fd8a1d2 commit 18a5b90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+39
-213
lines changed

CONTRIBUTING.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,7 @@ Therefore you should use `tests/ui/update-all-references.sh` (after running
152152
Manually testing against an example file is useful if you have added some
153153
`println!`s and test suite output becomes unreadable. To try clippy with your
154154
local modifications, run `cargo run --bin clippy-driver -- -L ./target/debug input.rs` from the
155-
working copy root. Your test file, here `input.rs`, needs to have clippy
156-
enabled as a plugin:
157-
158-
```rust
159-
#![feature(plugin)]
160-
#![plugin(clippy)]
161-
```
155+
working copy root.
162156

163157
### How Clippy works
164158

README.md

+1-92
Original file line numberDiff line numberDiff line change
@@ -71,47 +71,9 @@ similar crates.
7171
SYSROOT=/path/to/rustc/sysroot cargo install clippy
7272
```
7373

74-
### Optional dependency
75-
76-
In some cases you might want to include clippy in your project directly, as an
77-
optional dependency. To do this, just modify `Cargo.toml`:
78-
79-
```toml
80-
[dependencies]
81-
clippy = { version = "*", optional = true }
82-
```
83-
84-
And, in your `main.rs` or `lib.rs`, add these lines:
85-
86-
```rust
87-
#![cfg_attr(feature="clippy", feature(plugin))]
88-
#![cfg_attr(feature="clippy", plugin(clippy))]
89-
```
90-
91-
Then build by enabling the feature: `cargo +nightly build --features "clippy"`.
92-
93-
Instead of adding the `cfg_attr` attributes you can also run clippy on demand:
94-
`cargo rustc --features clippy -- -Z no-trans -Z extra-plugins=clippy`
95-
(the `-Z no trans`, while not necessary, will stop the compilation process after
96-
typechecking (and lints) have completed, which can significantly reduce the runtime).
97-
98-
Alternatively, to only run clippy when testing:
99-
100-
```toml
101-
[dev-dependencies]
102-
clippy = { version = "*" }
103-
```
104-
105-
and add to `main.rs` or `lib.rs`:
106-
107-
```
108-
#![cfg_attr(test, feature(plugin))]
109-
#![cfg_attr(test, plugin(clippy))]
110-
```
111-
11274
### Running clippy from the command line without installing it
11375

114-
To have cargo compile your crate with clippy without clippy installation and without needing `#![plugin(clippy)]`
76+
To have cargo compile your crate with clippy without clippy installation
11577
in your code, you can use:
11678

11779
```terminal
@@ -121,53 +83,6 @@ cargo run --bin cargo-clippy --manifest-path=path_to_clippys_Cargo.toml
12183
*[Note](https://github.com/rust-lang-nursery/rust-clippy/wiki#a-word-of-warning):*
12284
Be sure that clippy was compiled with the same version of rustc that cargo invokes here!
12385

124-
### As a Compiler Plugin
125-
126-
*Note:* This is not a recommended installation method.
127-
128-
Since stable Rust is backwards compatible, you should be able to
129-
compile your stable programs with nightly Rust with clippy plugged in to
130-
circumvent this.
131-
132-
Add in your `Cargo.toml`:
133-
134-
```toml
135-
[dependencies]
136-
clippy = "*"
137-
```
138-
139-
You then need to add `#![feature(plugin)]` and `#![plugin(clippy)]` to the top
140-
of your crate entry point (`main.rs` or `lib.rs`).
141-
142-
Sample `main.rs`:
143-
144-
```rust
145-
#![feature(plugin)]
146-
147-
#![plugin(clippy)]
148-
149-
150-
fn main(){
151-
let x = Some(1u8);
152-
match x {
153-
Some(y) => println!("{:?}", y),
154-
_ => ()
155-
}
156-
}
157-
```
158-
159-
Produces this warning:
160-
161-
```terminal
162-
src/main.rs:8:5: 11:6 warning: you seem to be trying to use match for destructuring a single type. Consider using `if let`, #[warn(single_match)] on by default
163-
src/main.rs:8 match x {
164-
src/main.rs:9 Some(y) => println!("{:?}", y),
165-
src/main.rs:10 _ => ()
166-
src/main.rs:11 }
167-
src/main.rs:8:5: 11:6 help: Try
168-
if let Some(y) = x { println!("{:?}", y) }
169-
```
170-
17186
## Configuration
17287

17388
Some lints can be configured in a TOML file named with `clippy.toml` or `.clippy.toml`. It contains basic `variable = value` mapping eg.
@@ -180,12 +95,6 @@ cyclomatic-complexity-threshold = 30
18095
See the [list of lints](https://rust-lang-nursery.github.io/rust-clippy/master/index.html) for more information about which lints can be configured and the
18196
meaning of the variables.
18297

183-
You can also specify the path to the configuration file with:
184-
185-
```rust
186-
#![plugin(clippy(conf_file="path/to/clippy's/configuration"))]
187-
```
188-
18998
To deactivate the “for further information visit *lint-link*” message you can
19099
define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable.
191100

src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ extern crate clippy_lints;
1414
pub fn plugin_registrar(reg: &mut Registry) {
1515
reg.sess.lint_store.with_read_lock(|lint_store| {
1616
for (lint, _, _) in lint_store.get_lint_groups() {
17+
reg.sess
18+
.struct_warn("the clippy plugin is being deprecated, please use cargo clippy or rls with the clippy feature")
19+
.emit();
1720
if lint == "clippy" {
18-
reg.sess
19-
.struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
20-
.emit();
21+
// cargo clippy run on a crate that also uses the plugin
2122
return;
2223
}
2324
}

tests/conf_whitelisted.rs

-2
This file was deleted.

tests/cc_seme.rs renamed to tests/run-pass/cc_seme.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(plugin)]
2-
#![plugin(clippy)]
3-
41
#[allow(dead_code)]
52
enum Baz {
63
One,
@@ -12,7 +9,9 @@ struct Test {
129
b: Baz,
1310
}
1411

15-
fn main() {
12+
fn main() { }
13+
14+
pub fn foo() {
1615
use Baz::*;
1716
let x = Test { t: Some(0), b: One };
1817

tests/ice_exacte_size.rs renamed to tests/run-pass/ice_exacte_size.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(plugin)]
2-
#![plugin(clippy)]
31
#![deny(clippy)]
42

53
#[allow(dead_code)]
@@ -15,3 +13,5 @@ impl Iterator for Foo {
1513
}
1614

1715
impl ExactSizeIterator for Foo {}
16+
17+
fn main() {}

tests/issue-825.rs renamed to tests/run-pass/issue-825.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(plugin)]
2-
#![plugin(clippy)]
31
#![allow(warnings)]
42

53
// this should compile in a reasonable amount of time
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#![feature(plugin)]
2-
#![plugin(clippy)]
31
#![deny(mut_mut, zero_ptr, cmp_nan)]
42
#![allow(dead_code)]
53

6-
#[macro_use]
7-
extern crate lazy_static;
4+
// compiletest + extern crates doesn't work together
5+
//#[macro_use]
6+
//extern crate lazy_static;
87

9-
use std::collections::HashMap;
8+
//use std::collections::HashMap;
109

1110
// ensure that we don't suggest `is_nan` and `is_null` inside constants
1211
// FIXME: once const fn is stable, suggest these functions again in constants
@@ -17,6 +16,7 @@ static mut BUH: bool = 42.0 < std::f32::NAN;
1716

1817
#[allow(unused_variables, unused_mut)]
1918
fn main() {
19+
/*
2020
lazy_static! {
2121
static ref MUT_MAP : HashMap<usize, &'static str> = {
2222
let mut m = HashMap::new();
@@ -26,6 +26,7 @@ fn main() {
2626
static ref MUT_COUNT : usize = MUT_MAP.len();
2727
}
2828
assert_eq!(*MUT_COUNT, 1);
29+
*/
2930
// FIXME: don't lint in array length, requires `check_body`
3031
//let _ = [""; (42.0 < std::f32::NAN) as usize];
3132
}

tests/used_underscore_binding_macro.rs renamed to tests/run-pass/used_underscore_binding_macro.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#![feature(plugin)]
2-
#![plugin(clippy)]
1+
2+
33

44
#[macro_use]
55
extern crate serde_derive;
@@ -16,3 +16,5 @@ struct MacroAttributesTest {
1616
fn macro_attributes_test() {
1717
let _ = MacroAttributesTest { _foo: 0 };
1818
}
19+
20+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// error-pattern: error reading Clippy's configuration file
22

33

4-
#![plugin(clippy(conf_file="../ui/conf_bad_toml.toml"))]
4+
55

66
fn main() {}

tests/ui/bad_toml/conf_bad_toml.stderr

Whitespace-only changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a `Vec < String >` but is a `integer`
22

33

4-
#![plugin(clippy(conf_file="../ui/conf_bad_type.toml"))]
4+
55

66
fn main() {}

tests/ui/bad_toml_type/conf_bad_type.stderr

Whitespace-only changes.

tests/ui/conf_bad_arg.rs

-6
This file was deleted.

tests/ui/conf_bad_arg.stderr

-11
This file was deleted.

tests/ui/conf_bad_toml.stderr

-11
This file was deleted.

tests/ui/conf_bad_type.stderr

-11
This file was deleted.

tests/ui/conf_french_blacklisted_name.stderr

-11
This file was deleted.

tests/ui/conf_path_non_string.rs

-5
This file was deleted.

tests/ui/conf_path_non_string.stderr

-11
This file was deleted.

tests/ui/conf_unknown_key.stderr

-11
This file was deleted.

tests/ui/cyclomatic_complexity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, custom_attribute)]
1+
#![feature(custom_attribute)]
22

33
#![allow(clippy)]
44
#![warn(cyclomatic_complexity)]

tests/ui/cyclomatic_complexity_attr_used.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, custom_attribute)]
1+
#![feature(custom_attribute)]
22

33
#![warn(cyclomatic_complexity)]
44
#![warn(unused)]

tests/ui/diverging_sub_expression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, never_type)]
1+
#![feature(never_type)]
22

33
#![warn(diverging_sub_expression)]
44
#![allow(match_same_arms, logic_bug)]

tests/ui/dlist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, alloc)]
1+
#![feature(alloc)]
22
#![feature(associated_type_defaults)]
33

44

tests/ui/enum_variants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, non_ascii_idents)]
1+
#![feature(non_ascii_idents)]
22

33
#![warn(clippy, pub_enum_variant_names)]
44

tests/ui/escape_analysis.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, box_syntax)]
1+
#![feature(box_syntax)]
22

33
#![allow(warnings, clippy)]
44

tests/ui/excessive_precision.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, custom_attribute)]
1+
#![feature(custom_attribute)]
22
#![warn(excessive_precision)]
33
#![allow(print_literal)]
44

tests/ui/for_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, custom_attribute)]
1+
#![feature(custom_attribute)]
22

33

44
use std::collections::*;

tests/ui/mut_mut.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#![allow(unused, no_effect, unnecessary_operation)]
55
#![warn(mut_mut)]
66

7-
//#![plugin(regex_macros)]
8-
//extern crate regex;
7+
8+
99

1010
fn fun(x : &mut &mut u32) -> bool {
1111
**x > 0

tests/ui/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(plugin, const_fn)]
1+
#![feature(const_fn)]
22

33

44
#![allow(dead_code)]

0 commit comments

Comments
 (0)