Skip to content

Update lint deprecation for tool lints #4363

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 5 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ Released 2018-09-13
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
Expand Down
6 changes: 3 additions & 3 deletions clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
l.clone().deprecation.and_then(|depr_text| {
Some(vec![
" store.register_removed(".to_string(),
format!(" \"{}\",", l.name),
format!(" \"clippy::{}\",", l.name),
format!(" \"{}\",", depr_text),
" );".to_string(),
])
Expand Down Expand Up @@ -442,11 +442,11 @@ fn test_gen_deprecated() {
];
let expected: Vec<String> = vec![
" store.register_removed(",
" \"should_assert_eq\",",
" \"clippy::should_assert_eq\",",
" \"has been superseded by should_assert_eq2\",",
" );",
" store.register_removed(",
" \"another_deprecated\",",
" \"clippy::another_deprecated\",",
" \"will be removed\",",
" );",
]
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ declare_deprecated_lint! {
///
/// **Deprecation reason:** This lint has been superseded by the warn-by-default
/// `invalid_value` rustc lint.
declare_clippy_lint! {
declare_deprecated_lint! {
pub INVALID_REF,
"superseded by rustc lint `invalid_value`"
}
76 changes: 65 additions & 11 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,51 +384,57 @@ pub fn read_conf(reg: &rustc_plugin::Registry<'_>) -> Conf {
#[rustfmt::skip]
pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
let mut store = reg.sess.lint_store.borrow_mut();
register_removed_non_tool_lints(&mut store);

// begin deprecated lints, do not remove this comment, it’s used in `update_lints`
store.register_removed(
"should_assert_eq",
"clippy::should_assert_eq",
"`assert!()` will be more flexible with RFC 2011",
);
store.register_removed(
"extend_from_slice",
"clippy::extend_from_slice",
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
);
store.register_removed(
"range_step_by_zero",
"clippy::range_step_by_zero",
"`iterator.step_by(0)` panics nowadays",
);
store.register_removed(
"unstable_as_slice",
"clippy::unstable_as_slice",
"`Vec::as_slice` has been stabilized in 1.7",
);
store.register_removed(
"unstable_as_mut_slice",
"clippy::unstable_as_mut_slice",
"`Vec::as_mut_slice` has been stabilized in 1.7",
);
store.register_removed(
"str_to_string",
"clippy::str_to_string",
"using `str::to_string` is common even today and specialization will likely happen soon",
Copy link
Member

Choose a reason for hiding this comment

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

"specialization will likely happen soon" 15e55f5 lol 😄

);
store.register_removed(
"string_to_string",
"clippy::string_to_string",
"using `string::to_string` is common even today and specialization will likely happen soon",
);
store.register_removed(
"misaligned_transmute",
"clippy::misaligned_transmute",
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
);
store.register_removed(
"assign_ops",
"clippy::assign_ops",
"using compound assignment operators (e.g., `+=`) is harmless",
);
store.register_removed(
"if_let_redundant_pattern_matching",
"clippy::if_let_redundant_pattern_matching",
"this lint has been changed to redundant_pattern_matching",
);
store.register_removed(
"unsafe_vector_initialization",
"clippy::unsafe_vector_initialization",
"the replacement suggested by this lint had substantially different behavior",
);
store.register_removed(
"clippy::invalid_ref",
"superseded by rustc lint `invalid_value`",
);
// end deprecated lints, do not remove this comment, it’s used in `update_lints`

reg.register_late_lint_pass(box serde_api::SerdeAPI);
Expand Down Expand Up @@ -1164,6 +1170,54 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
]);
}

#[rustfmt::skip]
fn register_removed_non_tool_lints(store: &mut rustc::lint::LintStore) {
store.register_removed(
"should_assert_eq",
"`assert!()` will be more flexible with RFC 2011",
);
store.register_removed(
"extend_from_slice",
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
);
store.register_removed(
"range_step_by_zero",
"`iterator.step_by(0)` panics nowadays",
);
store.register_removed(
"unstable_as_slice",
"`Vec::as_slice` has been stabilized in 1.7",
);
store.register_removed(
"unstable_as_mut_slice",
"`Vec::as_mut_slice` has been stabilized in 1.7",
);
store.register_removed(
"str_to_string",
"using `str::to_string` is common even today and specialization will likely happen soon",
);
store.register_removed(
"string_to_string",
"using `string::to_string` is common even today and specialization will likely happen soon",
);
store.register_removed(
"misaligned_transmute",
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
);
store.register_removed(
"assign_ops",
"using compound assignment operators (e.g., `+=`) is harmless",
);
store.register_removed(
"if_let_redundant_pattern_matching",
"this lint has been changed to redundant_pattern_matching",
);
store.register_removed(
"unsafe_vector_initialization",
"the replacement suggested by this lint had substantially different behavior",
);
}

/// Register renamed lints.
///
/// Used in `./src/driver.rs`.
Expand Down
12 changes: 7 additions & 5 deletions tests/ui/deprecated.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[warn(str_to_string)]
#[warn(string_to_string)]
#[warn(unstable_as_slice)]
#[warn(unstable_as_mut_slice)]
#[warn(misaligned_transmute)]
#[warn(clippy::str_to_string)]
#[warn(clippy::string_to_string)]
#[warn(clippy::unstable_as_slice)]
#[warn(clippy::unstable_as_mut_slice)]
#[warn(clippy::misaligned_transmute)]
#[warn(clippy::unused_collect)]
#[warn(clippy::invalid_ref)]

fn main() {}
44 changes: 25 additions & 19 deletions tests/ui/deprecated.stderr
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
--> $DIR/deprecated.rs:1:8
|
LL | #[warn(str_to_string)]
| ^^^^^^^^^^^^^
LL | #[warn(clippy::str_to_string)]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D renamed-and-removed-lints` implied by `-D warnings`

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

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

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

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

error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
error: lint `clippy::invalid_ref` has been removed: `superseded by rustc lint `invalid_value``
--> $DIR/deprecated.rs:7:8
|
LL | #[warn(clippy::invalid_ref)]
| ^^^^^^^^^^^^^^^^^^^

error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
--> $DIR/deprecated.rs:1:8
|
LL | #[warn(str_to_string)]
| ^^^^^^^^^^^^^
LL | #[warn(clippy::str_to_string)]
| ^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 6 previous errors
error: aborting due to 7 previous errors

8 changes: 8 additions & 0 deletions tests/ui/deprecated_old.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[warn(str_to_string)]
#[warn(string_to_string)]
#[warn(unstable_as_slice)]
#[warn(unstable_as_mut_slice)]
#[warn(misaligned_transmute)]
#[warn(unused_collect)]

fn main() {}
46 changes: 46 additions & 0 deletions tests/ui/deprecated_old.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
--> $DIR/deprecated_old.rs:1:8
|
LL | #[warn(str_to_string)]
| ^^^^^^^^^^^^^
|
= note: `-D renamed-and-removed-lints` implied by `-D warnings`

error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon`
--> $DIR/deprecated_old.rs:2:8
|
LL | #[warn(string_to_string)]
| ^^^^^^^^^^^^^^^^

error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7`
--> $DIR/deprecated_old.rs:3:8
|
LL | #[warn(unstable_as_slice)]
| ^^^^^^^^^^^^^^^^^

error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7`
--> $DIR/deprecated_old.rs:4:8
|
LL | #[warn(unstable_as_mut_slice)]
| ^^^^^^^^^^^^^^^^^^^^^

error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr`
--> $DIR/deprecated_old.rs:5:8
|
LL | #[warn(misaligned_transmute)]
| ^^^^^^^^^^^^^^^^^^^^

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
--> $DIR/deprecated_old.rs:6:8
|
LL | #[warn(unused_collect)]
| ^^^^^^^^^^^^^^ help: change it to: `clippy::unused_collect`

error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
--> $DIR/deprecated_old.rs:1:8
|
LL | #[warn(str_to_string)]
| ^^^^^^^^^^^^^

error: aborting due to 7 previous errors