Skip to content

Commit 67bb612

Browse files
committed
Update lint deprecation for tool lints
Our lint deprecation previously didn't work for tool lints, because `register_removed` was registering lints to be removed _without_ the `clippy` prefix.
1 parent 7a0ac4c commit 67bb612

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

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/lib.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -386,47 +386,47 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
386386
let mut store = reg.sess.lint_store.borrow_mut();
387387
// begin deprecated lints, do not remove this comment, it’s used in `update_lints`
388388
store.register_removed(
389-
"should_assert_eq",
389+
"clippy::should_assert_eq",
390390
"`assert!()` will be more flexible with RFC 2011",
391391
);
392392
store.register_removed(
393-
"extend_from_slice",
393+
"clippy::extend_from_slice",
394394
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
395395
);
396396
store.register_removed(
397-
"range_step_by_zero",
397+
"clippy::range_step_by_zero",
398398
"`iterator.step_by(0)` panics nowadays",
399399
);
400400
store.register_removed(
401-
"unstable_as_slice",
401+
"clippy::unstable_as_slice",
402402
"`Vec::as_slice` has been stabilized in 1.7",
403403
);
404404
store.register_removed(
405-
"unstable_as_mut_slice",
405+
"clippy::unstable_as_mut_slice",
406406
"`Vec::as_mut_slice` has been stabilized in 1.7",
407407
);
408408
store.register_removed(
409-
"str_to_string",
409+
"clippy::str_to_string",
410410
"using `str::to_string` is common even today and specialization will likely happen soon",
411411
);
412412
store.register_removed(
413-
"string_to_string",
413+
"clippy::string_to_string",
414414
"using `string::to_string` is common even today and specialization will likely happen soon",
415415
);
416416
store.register_removed(
417-
"misaligned_transmute",
417+
"clippy::misaligned_transmute",
418418
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
419419
);
420420
store.register_removed(
421-
"assign_ops",
421+
"clippy::assign_ops",
422422
"using compound assignment operators (e.g., `+=`) is harmless",
423423
);
424424
store.register_removed(
425-
"if_let_redundant_pattern_matching",
425+
"clippy::if_let_redundant_pattern_matching",
426426
"this lint has been changed to redundant_pattern_matching",
427427
);
428428
store.register_removed(
429-
"unsafe_vector_initialization",
429+
"clippy::unsafe_vector_initialization",
430430
"the replacement suggested by this lint had substantially different behavior",
431431
);
432432
// end deprecated lints, do not remove this comment, it’s used in `update_lints`

tests/ui/deprecated.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +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)]
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)]
67

78
fn main() {}

tests/ui/deprecated.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
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::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
3434
--> $DIR/deprecated.rs:1:8
3535
|
36-
LL | #[warn(str_to_string)]
37-
| ^^^^^^^^^^^^^
36+
LL | #[warn(clippy::str_to_string)]
37+
| ^^^^^^^^^^^^^^^^^^^^^
3838

3939
error: aborting due to 6 previous errors
4040

0 commit comments

Comments
 (0)