Skip to content

Commit 06430e7

Browse files
committed
Auto merge of #4363 - phansch:fix_lint_deprecation, r=flip1995
Update lint deprecation for tool lints changelog: Allow tool lints (`clippy::*`) to be deprecated Our lint deprecation previously didn't work for tool lints, because `register_removed` was registering lints to be removed _without_ the `clippy` prefix. Fixes #4349
2 parents 63d2d06 + e406ab5 commit 06430e7

File tree

8 files changed

+156
-39
lines changed

8 files changed

+156
-39
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ Released 2018-09-13
983983
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
984984
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
985985
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
986+
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
986987
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
987988
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
988989
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements

clippy_dev/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
126126
l.clone().deprecation.and_then(|depr_text| {
127127
Some(vec![
128128
" store.register_removed(".to_string(),
129-
format!(" \"{}\",", l.name),
129+
format!(" \"clippy::{}\",", l.name),
130130
format!(" \"{}\",", depr_text),
131131
" );".to_string(),
132132
])
@@ -442,11 +442,11 @@ fn test_gen_deprecated() {
442442
];
443443
let expected: Vec<String> = vec![
444444
" store.register_removed(",
445-
" \"should_assert_eq\",",
445+
" \"clippy::should_assert_eq\",",
446446
" \"has been superseded by should_assert_eq2\",",
447447
" );",
448448
" store.register_removed(",
449-
" \"another_deprecated\",",
449+
" \"clippy::another_deprecated\",",
450450
" \"will be removed\",",
451451
" );",
452452
]

clippy_lints/src/deprecated_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ declare_deprecated_lint! {
118118
///
119119
/// **Deprecation reason:** This lint has been superseded by the warn-by-default
120120
/// `invalid_value` rustc lint.
121-
declare_clippy_lint! {
121+
declare_deprecated_lint! {
122122
pub INVALID_REF,
123123
"superseded by rustc lint `invalid_value`"
124124
}

clippy_lints/src/lib.rs

+65-11
Original file line numberDiff line numberDiff line change
@@ -384,51 +384,57 @@ pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
384384
#[rustfmt::skip]
385385
pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
386386
let mut store = reg.sess.lint_store.borrow_mut();
387+
register_removed_non_tool_lints(&mut store);
388+
387389
// begin deprecated lints, do not remove this comment, it’s used in `update_lints`
388390
store.register_removed(
389-
"should_assert_eq",
391+
"clippy::should_assert_eq",
390392
"`assert!()` will be more flexible with RFC 2011",
391393
);
392394
store.register_removed(
393-
"extend_from_slice",
395+
"clippy::extend_from_slice",
394396
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
395397
);
396398
store.register_removed(
397-
"range_step_by_zero",
399+
"clippy::range_step_by_zero",
398400
"`iterator.step_by(0)` panics nowadays",
399401
);
400402
store.register_removed(
401-
"unstable_as_slice",
403+
"clippy::unstable_as_slice",
402404
"`Vec::as_slice` has been stabilized in 1.7",
403405
);
404406
store.register_removed(
405-
"unstable_as_mut_slice",
407+
"clippy::unstable_as_mut_slice",
406408
"`Vec::as_mut_slice` has been stabilized in 1.7",
407409
);
408410
store.register_removed(
409-
"str_to_string",
411+
"clippy::str_to_string",
410412
"using `str::to_string` is common even today and specialization will likely happen soon",
411413
);
412414
store.register_removed(
413-
"string_to_string",
415+
"clippy::string_to_string",
414416
"using `string::to_string` is common even today and specialization will likely happen soon",
415417
);
416418
store.register_removed(
417-
"misaligned_transmute",
419+
"clippy::misaligned_transmute",
418420
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
419421
);
420422
store.register_removed(
421-
"assign_ops",
423+
"clippy::assign_ops",
422424
"using compound assignment operators (e.g., `+=`) is harmless",
423425
);
424426
store.register_removed(
425-
"if_let_redundant_pattern_matching",
427+
"clippy::if_let_redundant_pattern_matching",
426428
"this lint has been changed to redundant_pattern_matching",
427429
);
428430
store.register_removed(
429-
"unsafe_vector_initialization",
431+
"clippy::unsafe_vector_initialization",
430432
"the replacement suggested by this lint had substantially different behavior",
431433
);
434+
store.register_removed(
435+
"clippy::invalid_ref",
436+
"superseded by rustc lint `invalid_value`",
437+
);
432438
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
433439

434440
reg.register_late_lint_pass(box serde_api::SerdeAPI);
@@ -1166,6 +1172,54 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
11661172
]);
11671173
}
11681174

1175+
#[rustfmt::skip]
1176+
fn register_removed_non_tool_lints(store: &mut rustc::lint::LintStore) {
1177+
store.register_removed(
1178+
"should_assert_eq",
1179+
"`assert!()` will be more flexible with RFC 2011",
1180+
);
1181+
store.register_removed(
1182+
"extend_from_slice",
1183+
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
1184+
);
1185+
store.register_removed(
1186+
"range_step_by_zero",
1187+
"`iterator.step_by(0)` panics nowadays",
1188+
);
1189+
store.register_removed(
1190+
"unstable_as_slice",
1191+
"`Vec::as_slice` has been stabilized in 1.7",
1192+
);
1193+
store.register_removed(
1194+
"unstable_as_mut_slice",
1195+
"`Vec::as_mut_slice` has been stabilized in 1.7",
1196+
);
1197+
store.register_removed(
1198+
"str_to_string",
1199+
"using `str::to_string` is common even today and specialization will likely happen soon",
1200+
);
1201+
store.register_removed(
1202+
"string_to_string",
1203+
"using `string::to_string` is common even today and specialization will likely happen soon",
1204+
);
1205+
store.register_removed(
1206+
"misaligned_transmute",
1207+
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
1208+
);
1209+
store.register_removed(
1210+
"assign_ops",
1211+
"using compound assignment operators (e.g., `+=`) is harmless",
1212+
);
1213+
store.register_removed(
1214+
"if_let_redundant_pattern_matching",
1215+
"this lint has been changed to redundant_pattern_matching",
1216+
);
1217+
store.register_removed(
1218+
"unsafe_vector_initialization",
1219+
"the replacement suggested by this lint had substantially different behavior",
1220+
);
1221+
}
1222+
11691223
/// Register renamed lints.
11701224
///
11711225
/// Used in `./src/driver.rs`.

tests/ui/deprecated.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#[warn(str_to_string)]
2-
#[warn(string_to_string)]
3-
#[warn(unstable_as_slice)]
4-
#[warn(unstable_as_mut_slice)]
5-
#[warn(misaligned_transmute)]
1+
#[warn(clippy::str_to_string)]
2+
#[warn(clippy::string_to_string)]
3+
#[warn(clippy::unstable_as_slice)]
4+
#[warn(clippy::unstable_as_mut_slice)]
5+
#[warn(clippy::misaligned_transmute)]
6+
#[warn(clippy::unused_collect)]
7+
#[warn(clippy::invalid_ref)]
68

79
fn main() {}

tests/ui/deprecated.stderr

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
1-
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
1+
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
22
--> $DIR/deprecated.rs:1:8
33
|
4-
LL | #[warn(str_to_string)]
5-
| ^^^^^^^^^^^^^
4+
LL | #[warn(clippy::str_to_string)]
5+
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
88

9-
error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon`
9+
error: lint `clippy::string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon`
1010
--> $DIR/deprecated.rs:2:8
1111
|
12-
LL | #[warn(string_to_string)]
13-
| ^^^^^^^^^^^^^^^^
12+
LL | #[warn(clippy::string_to_string)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1414

15-
error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7`
15+
error: lint `clippy::unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7`
1616
--> $DIR/deprecated.rs:3:8
1717
|
18-
LL | #[warn(unstable_as_slice)]
19-
| ^^^^^^^^^^^^^^^^^
18+
LL | #[warn(clippy::unstable_as_slice)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2020

21-
error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7`
21+
error: lint `clippy::unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7`
2222
--> $DIR/deprecated.rs:4:8
2323
|
24-
LL | #[warn(unstable_as_mut_slice)]
25-
| ^^^^^^^^^^^^^^^^^^^^^
24+
LL | #[warn(clippy::unstable_as_mut_slice)]
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

27-
error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr`
27+
error: lint `clippy::misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr`
2828
--> $DIR/deprecated.rs:5:8
2929
|
30-
LL | #[warn(misaligned_transmute)]
31-
| ^^^^^^^^^^^^^^^^^^^^
30+
LL | #[warn(clippy::misaligned_transmute)]
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232

33-
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
33+
error: lint `clippy::invalid_ref` has been removed: `superseded by rustc lint `invalid_value``
34+
--> $DIR/deprecated.rs:7:8
35+
|
36+
LL | #[warn(clippy::invalid_ref)]
37+
| ^^^^^^^^^^^^^^^^^^^
38+
39+
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
3440
--> $DIR/deprecated.rs:1:8
3541
|
36-
LL | #[warn(str_to_string)]
37-
| ^^^^^^^^^^^^^
42+
LL | #[warn(clippy::str_to_string)]
43+
| ^^^^^^^^^^^^^^^^^^^^^
3844

39-
error: aborting due to 6 previous errors
45+
error: aborting due to 7 previous errors
4046

tests/ui/deprecated_old.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#[warn(str_to_string)]
2+
#[warn(string_to_string)]
3+
#[warn(unstable_as_slice)]
4+
#[warn(unstable_as_mut_slice)]
5+
#[warn(misaligned_transmute)]
6+
#[warn(unused_collect)]
7+
8+
fn main() {}

tests/ui/deprecated_old.stderr

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
2+
--> $DIR/deprecated_old.rs:1:8
3+
|
4+
LL | #[warn(str_to_string)]
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
8+
9+
error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon`
10+
--> $DIR/deprecated_old.rs:2:8
11+
|
12+
LL | #[warn(string_to_string)]
13+
| ^^^^^^^^^^^^^^^^
14+
15+
error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7`
16+
--> $DIR/deprecated_old.rs:3:8
17+
|
18+
LL | #[warn(unstable_as_slice)]
19+
| ^^^^^^^^^^^^^^^^^
20+
21+
error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7`
22+
--> $DIR/deprecated_old.rs:4:8
23+
|
24+
LL | #[warn(unstable_as_mut_slice)]
25+
| ^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr`
28+
--> $DIR/deprecated_old.rs:5:8
29+
|
30+
LL | #[warn(misaligned_transmute)]
31+
| ^^^^^^^^^^^^^^^^^^^^
32+
33+
error: lint name `unused_collect` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
34+
--> $DIR/deprecated_old.rs:6:8
35+
|
36+
LL | #[warn(unused_collect)]
37+
| ^^^^^^^^^^^^^^ help: change it to: `clippy::unused_collect`
38+
39+
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
40+
--> $DIR/deprecated_old.rs:1:8
41+
|
42+
LL | #[warn(str_to_string)]
43+
| ^^^^^^^^^^^^^
44+
45+
error: aborting due to 7 previous errors
46+

0 commit comments

Comments
 (0)