From 94e35510aedb6248e3066300acb41efd2c8699c9 Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Wed, 30 Oct 2019 21:05:23 -0400 Subject: [PATCH 1/4] Fix #4748 - Deprecated lints don't expand - Move doc comments inside of declare_deprecated_lint macros so that they are picked up by lintlib.py --- clippy_lints/src/deprecated_lints.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index 97ae9c780888..ec349a23760c 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -4,85 +4,85 @@ macro_rules! declare_deprecated_lint { } } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011. -declare_deprecated_lint! { pub SHOULD_ASSERT_EQ, "`assert!()` will be more flexible with RFC 2011" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true. -declare_deprecated_lint! { pub EXTEND_FROM_SLICE, "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's /// an infinite iterator, which is better expressed by `iter::repeat`, /// but the method has been removed for `Iterator::step_by` which panics /// if given a zero -declare_deprecated_lint! { pub RANGE_STEP_BY_ZERO, "`iterator.step_by(0)` panics nowadays" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good /// stable alternatives. `Vec::as_slice` has now been stabilized. -declare_deprecated_lint! { pub UNSTABLE_AS_SLICE, "`Vec::as_slice` has been stabilized in 1.7" } - +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `Vec::as_mut_slice`, which was unstable with good /// stable alternatives. `Vec::as_mut_slice` has now been stabilized. -declare_deprecated_lint! { pub UNSTABLE_AS_MUT_SLICE, "`Vec::as_mut_slice` has been stabilized in 1.7" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `.to_string()` method calls on values /// of type `&str`. This is not unidiomatic and with specialization coming, `to_string` could be /// specialized to be as efficient as `to_owned`. -declare_deprecated_lint! { pub STR_TO_STRING, "using `str::to_string` is common even today and specialization will likely happen soon" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This used to check for `.to_string()` method calls on values /// of type `String`. This is not unidiomatic and with specialization coming, `to_string` could be /// specialized to be as efficient as `clone`. -declare_deprecated_lint! { pub STRING_TO_STRING, "using `string::to_string` is common even today and specialization will likely happen soon" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting /// between non-pointer types of differing alignment is well-defined behavior (it's semantically /// equivalent to a memcpy). This lint has thus been refactored into two separate lints: /// cast_ptr_alignment and transmute_ptr_to_ptr. -declare_deprecated_lint! { pub MISALIGNED_TRANSMUTE, "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. @@ -93,40 +93,40 @@ declare_deprecated_lint! { "using compound assignment operators (e.g., `+=`) is harmless" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** The original rule will only lint for `if let`. After /// making it support to lint `match`, naming as `if let` is not suitable for it. /// So, this lint is deprecated. -declare_deprecated_lint! { pub IF_LET_REDUNDANT_PATTERN_MATCHING, "this lint has been changed to redundant_pattern_matching" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint used to suggest replacing `let mut vec = /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The /// replacement has very different performance characteristics so the lint is /// deprecated. -declare_deprecated_lint! { pub UNSAFE_VECTOR_INITIALIZATION, "the replacement suggested by this lint had substantially different behavior" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint has been superseded by the warn-by-default /// `invalid_value` rustc lint. -declare_deprecated_lint! { pub INVALID_REF, "superseded by rustc lint `invalid_value`" } +declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint has been superseded by #[must_use] in rustc. -declare_deprecated_lint! { pub UNUSED_COLLECT, "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint" } From 1acea2e4fc231e4dd6229b6e0869f29e79b40edc Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Sat, 2 Nov 2019 14:09:41 -0400 Subject: [PATCH 2/4] deprecated_lints: remove extraneous `declare_deprecated_lint` --- clippy_lints/src/deprecated_lints.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index ec349a23760c..5156749e8657 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -82,7 +82,6 @@ declare_deprecated_lint! { "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr" } -declare_deprecated_lint! { /// **What it does:** Nothing. This lint has been deprecated. /// /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. From 9a2c968f9ff9826fb46e8b37036f904f303e064b Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Sat, 2 Nov 2019 14:10:59 -0400 Subject: [PATCH 3/4] deprecated_lints: align doc comment indents with `pub LINT_NAME` --- clippy_lints/src/deprecated_lints.rs | 112 +++++++++++++-------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index 5156749e8657..a7640b8e8ced 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -5,79 +5,79 @@ macro_rules! declare_deprecated_lint { } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend -/// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend + /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011. pub SHOULD_ASSERT_EQ, "`assert!()` will be more flexible with RFC 2011" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than -/// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than + /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true. pub EXTEND_FROM_SLICE, "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's -/// an infinite iterator, which is better expressed by `iter::repeat`, -/// but the method has been removed for `Iterator::step_by` which panics -/// if given a zero + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's + /// an infinite iterator, which is better expressed by `iter::repeat`, + /// but the method has been removed for `Iterator::step_by` which panics + /// if given a zero pub RANGE_STEP_BY_ZERO, "`iterator.step_by(0)` panics nowadays" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good -/// stable alternatives. `Vec::as_slice` has now been stabilized. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good + /// stable alternatives. `Vec::as_slice` has now been stabilized. pub UNSTABLE_AS_SLICE, "`Vec::as_slice` has been stabilized in 1.7" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `Vec::as_mut_slice`, which was unstable with good -/// stable alternatives. `Vec::as_mut_slice` has now been stabilized. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `Vec::as_mut_slice`, which was unstable with good + /// stable alternatives. `Vec::as_mut_slice` has now been stabilized. pub UNSTABLE_AS_MUT_SLICE, "`Vec::as_mut_slice` has been stabilized in 1.7" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `.to_string()` method calls on values -/// of type `&str`. This is not unidiomatic and with specialization coming, `to_string` could be -/// specialized to be as efficient as `to_owned`. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `.to_string()` method calls on values + /// of type `&str`. This is not unidiomatic and with specialization coming, `to_string` could be + /// specialized to be as efficient as `to_owned`. pub STR_TO_STRING, "using `str::to_string` is common even today and specialization will likely happen soon" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This used to check for `.to_string()` method calls on values -/// of type `String`. This is not unidiomatic and with specialization coming, `to_string` could be -/// specialized to be as efficient as `clone`. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This used to check for `.to_string()` method calls on values + /// of type `String`. This is not unidiomatic and with specialization coming, `to_string` could be + /// specialized to be as efficient as `clone`. pub STRING_TO_STRING, "using `string::to_string` is common even today and specialization will likely happen soon" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting -/// between non-pointer types of differing alignment is well-defined behavior (it's semantically -/// equivalent to a memcpy). This lint has thus been refactored into two separate lints: -/// cast_ptr_alignment and transmute_ptr_to_ptr. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting + /// between non-pointer types of differing alignment is well-defined behavior (it's semantically + /// equivalent to a memcpy). This lint has thus been refactored into two separate lints: + /// cast_ptr_alignment and transmute_ptr_to_ptr. pub MISALIGNED_TRANSMUTE, "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr" } @@ -93,39 +93,39 @@ declare_deprecated_lint! { } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** The original rule will only lint for `if let`. After -/// making it support to lint `match`, naming as `if let` is not suitable for it. -/// So, this lint is deprecated. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** The original rule will only lint for `if let`. After + /// making it support to lint `match`, naming as `if let` is not suitable for it. + /// So, this lint is deprecated. pub IF_LET_REDUNDANT_PATTERN_MATCHING, "this lint has been changed to redundant_pattern_matching" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This lint used to suggest replacing `let mut vec = -/// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The -/// replacement has very different performance characteristics so the lint is -/// deprecated. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This lint used to suggest replacing `let mut vec = + /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The + /// replacement has very different performance characteristics so the lint is + /// deprecated. pub UNSAFE_VECTOR_INITIALIZATION, "the replacement suggested by this lint had substantially different behavior" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This lint has been superseded by the warn-by-default -/// `invalid_value` rustc lint. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This lint has been superseded by the warn-by-default + /// `invalid_value` rustc lint. pub INVALID_REF, "superseded by rustc lint `invalid_value`" } declare_deprecated_lint! { -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This lint has been superseded by #[must_use] in rustc. + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This lint has been superseded by #[must_use] in rustc. pub UNUSED_COLLECT, "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint" } From 8ca9c237a069dc12db8073923ec0a4a83d0a1efc Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Sat, 2 Nov 2019 14:19:25 -0400 Subject: [PATCH 4/4] deprecated_lints: re-fix ASSIGN_OPS lint doc-comment --- clippy_lints/src/deprecated_lints.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index a7640b8e8ced..729c494d1dcc 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -82,12 +82,12 @@ declare_deprecated_lint! { "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr" } -/// **What it does:** Nothing. This lint has been deprecated. -/// -/// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. -/// Additionally, compound assignment operators may be overloaded separately from their non-assigning -/// counterparts, so this lint may suggest a change in behavior or the code may not compile. declare_deprecated_lint! { + /// **What it does:** Nothing. This lint has been deprecated. + /// + /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. + /// Additionally, compound assignment operators may be overloaded separately from their non-assigning + /// counterparts, so this lint may suggest a change in behavior or the code may not compile. pub ASSIGN_OPS, "using compound assignment operators (e.g., `+=`) is harmless" }